2
0

iso7185.pp 2.0 KB

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