iso7185.pp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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-}
  33. procedure DoAssign(var t : Text);
  34. begin
  35. Assign(t,'fpc_'+HexStr(random(1000000000),8)+'.tmp');
  36. end;
  37. Procedure Rewrite(var t : Text);[IOCheck];
  38. Begin
  39. { create file name? }
  40. if Textrec(t).mode=0 then
  41. DoAssign(t);
  42. System.Rewrite(t);
  43. End;
  44. Procedure Reset(var t : Text);[IOCheck];
  45. Begin
  46. case Textrec(t).mode of
  47. { create file name? }
  48. 0:
  49. DoAssign(t);
  50. fmOutput:
  51. Write(t,#26);
  52. end;
  53. System.Reset(t);
  54. End;
  55. Function Eof(Var t: Text): Boolean;[IOCheck];
  56. var
  57. OldCtrlZMarksEof : Boolean;
  58. Begin
  59. OldCtrlZMarksEof:=CtrlZMarksEOF;
  60. CtrlZMarksEof:=false;
  61. Eof:=System.Eof(t);
  62. CtrlZMarksEof:=OldCtrlZMarksEOF;
  63. end;
  64. Function Eof:Boolean;
  65. Begin
  66. Eof:=Eof(Input);
  67. End;
  68. Function Eoln(Var t: Text): Boolean;[IOCheck];
  69. var
  70. OldCtrlZMarksEof : Boolean;
  71. Begin
  72. OldCtrlZMarksEof:=CtrlZMarksEOF;
  73. CtrlZMarksEof:=true;
  74. Eoln:=System.Eoln(t);
  75. CtrlZMarksEof:=OldCtrlZMarksEOF;
  76. end;
  77. Function Eoln:Boolean;
  78. Begin
  79. Eoln:=Eoln(Input);
  80. End;
  81. Procedure Page;
  82. begin
  83. Page(Output);
  84. end;
  85. Procedure Page(var t : Text);
  86. Begin
  87. write(#12);
  88. End;
  89. procedure Get(var t : Text);
  90. var
  91. c : char;
  92. Begin
  93. Read(t,c);
  94. End;
  95. Procedure Put(var t : Text);
  96. type
  97. FileFunc = Procedure(var t : TextRec);
  98. begin
  99. inc(TextRec(t).BufPos);
  100. If TextRec(t).BufPos>=TextRec(t).BufSize Then
  101. FileFunc(TextRec(t).InOutFunc)(TextRec(t));
  102. end;
  103. Function Eof(var f:TypedFile): Boolean;
  104. Type
  105. UnTypedFile = File;
  106. Begin
  107. Eof:=System.Eof(UnTypedFile(f));
  108. End;
  109. begin
  110. { we shouldn't do this because it might confuse user programs, but for now it
  111. is good enough to get pretty unique tmp file names }
  112. Randomize;
  113. end.