iso7185.pp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. {
  2. This file is part of the Free Pascal Run time library.
  3. Copyright (c) 2010 by Florian Klaempfl
  4. This unit contain procedures specific for iso pascal mode.
  5. It should be platform independant.
  6. See the file COPYING.FPC, included in this distribution,
  7. For details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit iso7185;
  13. interface
  14. const
  15. MaxInt = MaxLongint;
  16. type
  17. Integer = Longint;
  18. Procedure Rewrite(var t : Text);
  19. Procedure Reset(var t : Text);
  20. Procedure Reset(var f : TypedFile); [INTERNPROC: fpc_in_Reset_TypedFile];
  21. Procedure Rewrite(var f : TypedFile); [INTERNPROC: fpc_in_Rewrite_TypedFile];
  22. Function Eof(Var t: Text): Boolean;
  23. Function Eof:Boolean;
  24. Function Eoln(Var t: Text): Boolean;
  25. Function Eoln:Boolean;
  26. Procedure Page;
  27. Procedure Page(Var t: Text);
  28. Procedure Get(Var t: Text);
  29. Procedure Put(Var t: Text);
  30. Function Eof(var f:TypedFile): Boolean;
  31. implementation
  32. {$i textrec.inc}
  33. {$i-}
  34. procedure DoAssign(var t : Text);
  35. begin
  36. Assign(t,'fpc_'+HexStr(random(1000000000),8)+'.tmp');
  37. end;
  38. Procedure Rewrite(var t : Text);[IOCheck];
  39. Begin
  40. { create file name? }
  41. if Textrec(t).mode=0 then
  42. DoAssign(t);
  43. System.Rewrite(t);
  44. End;
  45. Procedure Reset(var t : Text);[IOCheck];
  46. Begin
  47. case Textrec(t).mode of
  48. { create file name? }
  49. 0:
  50. DoAssign(t);
  51. fmOutput:
  52. Write(t,#26);
  53. end;
  54. System.Reset(t);
  55. End;
  56. Function Eof(Var t: Text): Boolean;[IOCheck];
  57. var
  58. OldCtrlZMarksEof : Boolean;
  59. Begin
  60. OldCtrlZMarksEof:=CtrlZMarksEOF;
  61. CtrlZMarksEof:=false;
  62. Eof:=System.Eof(t);
  63. CtrlZMarksEof:=OldCtrlZMarksEOF;
  64. end;
  65. Function Eof:Boolean;
  66. Begin
  67. Eof:=Eof(Input);
  68. End;
  69. Function Eoln(Var t: Text): Boolean;[IOCheck];
  70. var
  71. OldCtrlZMarksEof : Boolean;
  72. Begin
  73. OldCtrlZMarksEof:=CtrlZMarksEOF;
  74. CtrlZMarksEof:=true;
  75. Eoln:=System.Eoln(t);
  76. CtrlZMarksEof:=OldCtrlZMarksEOF;
  77. end;
  78. Function Eoln:Boolean;
  79. Begin
  80. Eoln:=Eoln(Input);
  81. End;
  82. Procedure Page;
  83. begin
  84. Page(Output);
  85. end;
  86. Procedure Page(var t : Text);
  87. Begin
  88. write(#12);
  89. End;
  90. procedure Get(var t : Text);
  91. var
  92. c : char;
  93. Begin
  94. Read(t,c);
  95. End;
  96. Procedure Put(var t : Text);
  97. type
  98. FileFunc = Procedure(var t : TextRec);
  99. begin
  100. inc(TextRec(t).BufPos);
  101. If TextRec(t).BufPos>=TextRec(t).BufSize Then
  102. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  103. end;
  104. Function Eof(var f:TypedFile): Boolean;
  105. Type
  106. UnTypedFile = File;
  107. Begin
  108. Eof:=System.Eof(UnTypedFile(f));
  109. End;
  110. begin
  111. { we shouldn't do this because it might confuse user programs, but for now it
  112. is good enough to get pretty unique tmp file names }
  113. Randomize;
  114. end.