iso7185.pp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. implementation
  27. {$i textrec.inc}
  28. {$i-}
  29. procedure DoAssign(var t : Text);
  30. begin
  31. Assign(t,'fpc_'+HexStr(random(1000000000),8)+'.tmp');
  32. end;
  33. Procedure Rewrite(var t : Text);[IOCheck];
  34. Begin
  35. { create file name? }
  36. if Textrec(t).mode=0 then
  37. DoAssign(t);
  38. System.Rewrite(t);
  39. End;
  40. Procedure Reset(var t : Text);[IOCheck];
  41. Begin
  42. case Textrec(t).mode of
  43. { create file name? }
  44. 0:
  45. DoAssign(t);
  46. fmOutput:
  47. Write(t,#26);
  48. end;
  49. System.Reset(t);
  50. End;
  51. Function Eof(Var t: Text): Boolean;[IOCheck];
  52. var
  53. OldCtrlZMarksEof : Boolean;
  54. Begin
  55. OldCtrlZMarksEof:=CtrlZMarksEOF;
  56. CtrlZMarksEof:=false;
  57. Eof:=System.Eof(t);
  58. CtrlZMarksEof:=OldCtrlZMarksEOF;
  59. end;
  60. Function Eof:Boolean;
  61. Begin
  62. Eof:=Eof(Input);
  63. End;
  64. Function Eoln(Var t: Text): Boolean;[IOCheck];
  65. var
  66. OldCtrlZMarksEof : Boolean;
  67. Begin
  68. OldCtrlZMarksEof:=CtrlZMarksEOF;
  69. CtrlZMarksEof:=true;
  70. Eoln:=System.Eoln(t);
  71. CtrlZMarksEof:=OldCtrlZMarksEOF;
  72. end;
  73. Function Eoln:Boolean;
  74. Begin
  75. Eoln:=Eoln(Input);
  76. End;
  77. begin
  78. { we shouldn't do this because it might confuse user programs, but for now it
  79. is good enough to get pretty unique tmp file names }
  80. Randomize;
  81. end.