From d3c103dfd7f5fb72af14c05ebc97ae070791746a Mon Sep 17 00:00:00 2001 From: Tomas Hajny Date: Sun, 3 Apr 2005 21:10:59 +0000 Subject: [PATCH] * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug #2453) --- rtl/atari/system.pas | 6 +++- rtl/beos/system.pp | 9 +++--- rtl/emx/system.pas | 8 +++-- rtl/go32v2/system.pp | 8 +++-- rtl/inc/text.inc | 73 ++++++++++++++++++++++++++---------------- rtl/macos/system.pp | 6 +++- rtl/morphos/system.pp | 6 +++- rtl/netware/system.pp | 6 +++- rtl/netwlibc/system.pp | 6 +++- rtl/os2/system.pas | 8 +++-- rtl/palmos/system.pp | 6 +++- rtl/unix/sysunixh.inc | 6 +++- rtl/watcom/system.pp | 8 +++-- rtl/win32/system.pp | 9 +++--- 14 files changed, 111 insertions(+), 54 deletions(-) diff --git a/rtl/atari/system.pas b/rtl/atari/system.pas index 8fce3a6968..3a3b5317b2 100644 --- a/rtl/atari/system.pas +++ b/rtl/atari/system.pas @@ -39,6 +39,7 @@ type const LineEnding = #10; LFNSupport = true; + CtrlZMarksEOF: boolean = false; (* #26 not considered as end of file *) DirectorySeparator = '/'; DriveSeparator = ':'; PathSeparator = ';'; @@ -772,7 +773,10 @@ end. { $Log$ - Revision 1.13 2005-02-14 17:13:21 peter + Revision 1.14 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.13 2005/02/14 17:13:21 peter * truncate log } diff --git a/rtl/beos/system.pp b/rtl/beos/system.pp index 449129d062..afa0ebb939 100644 --- a/rtl/beos/system.pp +++ b/rtl/beos/system.pp @@ -45,6 +45,7 @@ const const FileNameCaseSensitive : boolean = true; + CtrlZMarksEOF: boolean = false; (* #26 not considered as end of file *) sLineBreak : string[1] = LineEnding; DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsLF; @@ -348,9 +349,6 @@ end; Text File Handling *****************************************************************************} -{ should we consider #26 as the end of a file ? } -{?? $DEFINE EOF_CTRLZ} - {$i text.inc} {***************************************************************************** @@ -549,7 +547,10 @@ begin end. { $Log$ - Revision 1.21 2005-02-14 17:13:21 peter + Revision 1.22 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.21 2005/02/14 17:13:21 peter * truncate log Revision 1.20 2005/02/01 20:22:49 florian diff --git a/rtl/emx/system.pas b/rtl/emx/system.pas index 8cc5aa1532..c42d3da73a 100644 --- a/rtl/emx/system.pas +++ b/rtl/emx/system.pas @@ -27,8 +27,6 @@ interface {$l prt1.o} {$endif} -{$DEFINE EOF_CTRLZ} - {$I systemh.inc} const @@ -87,6 +85,7 @@ const UnusedHandle=-1; LFNSupport: boolean = true; FileNameCaseSensitive: boolean = false; + CtrlZMarksEOF: boolean = true; (* #26 is considered as end of file *) sLineBreak = LineEnding; DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF; @@ -592,7 +591,10 @@ begin end. { $Log$ - Revision 1.34 2005-02-14 17:13:22 peter + Revision 1.35 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.34 2005/02/14 17:13:22 peter * truncate log Revision 1.33 2005/02/06 16:57:18 peter diff --git a/rtl/go32v2/system.pp b/rtl/go32v2/system.pp index c56abaf5ad..35099392f9 100644 --- a/rtl/go32v2/system.pp +++ b/rtl/go32v2/system.pp @@ -29,8 +29,6 @@ interface {$define EXCEPTIONS_IN_SYSTEM} {$endif NO_EXCEPTIONS_IN_SYSTEM} -{$DEFINE EOF_CTRLZ} - { include system-independent routine headers } @@ -55,6 +53,7 @@ const StdErrorHandle = 2; FileNameCaseSensitive : boolean = false; + CtrlZMarksEOF: boolean = true; (* #26 is considered as end of file *) sLineBreak = LineEnding; DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF; @@ -654,7 +653,10 @@ Begin End. { $Log$ - Revision 1.49 2005-02-14 17:13:22 peter + Revision 1.50 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.49 2005/02/14 17:13:22 peter * truncate log Revision 1.48 2005/02/06 16:57:18 peter diff --git a/rtl/inc/text.inc b/rtl/inc/text.inc index b69332222c..3f5af3632b 100644 --- a/rtl/inc/text.inc +++ b/rtl/inc/text.inc @@ -12,11 +12,6 @@ **********************************************************************} -{ - Possible Defines: - - EOF_CTRLZ Is Ctrl-Z (#26) a EOF mark for textfiles -} {**************************************************************************** subroutines For TextFile handling @@ -257,11 +252,7 @@ Begin If TextRec(t).BufPos>=TextRec(t).BufEnd Then exit(true); end; -{$ifdef EOF_CTRLZ} - Eof:=(TextRec(t).Bufptr^[TextRec(t).BufPos]=#26); -{$else} - Eof:=false; -{$endif EOL_CTRLZ} + Eof:=CtrlZMarksEOF and (TextRec(t).Bufptr^[TextRec(t).BufPos]=#26); end; @@ -316,13 +307,11 @@ Begin end; end; case TextRec(t).Bufptr^[TextRec(t).BufPos] of -{$ifdef EOF_CTRLZ} - #26 : - begin - SeekEof := true; - break; - end; -{$endif EOF_CTRLZ} + #26 : if CtrlZMarksEOF then + begin + SeekEof := true; + break; + end; #10,#13, #9,' ' : ; else @@ -378,6 +367,8 @@ Begin If TextRec(t).BufPos>=TextRec(t).BufEnd Then exit(true); end; + if CtrlZMarksEOF and (TextRec (T).BufPtr^[TextRec (T).BufPos] = #26) then + exit (true); Eoln:=(TextRec(t).Bufptr^[TextRec(t).BufPos] in [#10,#13]); End; @@ -408,7 +399,8 @@ Begin exit(true); end; case TextRec(t).Bufptr^[TextRec(t).BufPos] of - #26, + #26: if CtrlZMarksEOF then + exit (true); #10,#13 : exit(true); #9,' ' : ; else @@ -763,8 +755,9 @@ End; Function NextChar(var f:Text;var s:string):Boolean; begin - if TextRec(f).BufPos#26) then + begin if length(s)=TextRec(f).BufEnd) then exit; - while (TextRec(f).Bufptr^[TextRec(f).BufPos] in [#9,#10,#13,' ']) do +(* Check performed separately to avoid accessing memory outside buffer *) + if CtrlZMarksEOF and (TextRec(f).Bufptr^[TextRec(f).BufPos]=#26) then + exit; + while (TextRec(f).Bufptr^[TextRec(f).BufPos] <= ' ') do begin if not NextChar(f,s) then exit; { EOF? } if (TextRec(f).BufPos>=TextRec(f).BufEnd) then break; + if CtrlZMarksEOF and (TextRec(f).Bufptr^[TextRec(f).BufPos]=#26) then + break; end; IgnoreSpaces:=true; end; @@ -813,7 +811,7 @@ begin repeat if not NextChar(f,s) then exit; - until (length(s)=high(s)) or (TextRec(f).BufPtr^[TextRec(f).BufPos] in [#9,#10,#13,' ']); + until (length(s)=high(s)) or (TextRec(f).BufPtr^[TextRec(f).BufPos] <= ' '); end; @@ -851,6 +849,8 @@ Begin exit; end; end; + if CtrlZMarksEOF and (TextRec (F).BufPtr^ [TextRec (F).BufPos] = #26) then + Exit; repeat prev := TextRec(f).BufPtr^[TextRec(f).BufPos]; inc(TextRec(f).BufPos); @@ -875,6 +875,8 @@ Begin exit; end; end; + if CtrlZMarksEOF and (TextRec (F).BufPtr^ [TextRec (F).BufPos] = #26) then + Exit; if (prev=#13) then { is there also a #10 after it? } begin @@ -1058,15 +1060,29 @@ Begin then we return 0 } if (TextRec(f).BufPos>=TextRec(f).BufEnd) then exit; + if CtrlZMarksEOF and (TextRec(f).Bufptr^[TextRec(f).BufPos]=#26) then + exit; ReadNumeric(f,hs); end; {$ifdef hascompilerproc} - Val(hs,l,code); + if (hs = '') then + L := 0 + else + begin + Val(hs,l,code); + if Code <> 0 then + InOutRes:=106; + end; {$else hascompilerproc} - Val(hs,fpc_Read_Text_SInt,code); + if (hs = '') then + fpc_Read_Text_SInt := 0 + else + begin + Val(hs,fpc_Read_Text_SInt,code); + if Code <> 0 then + InOutRes:=106; + end; {$endif hascompilerproc} - If code<>0 Then - InOutRes:=106; End; @@ -1291,7 +1307,10 @@ end; { $Log$ - Revision 1.29 2005-02-14 17:13:29 peter + Revision 1.30 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.29 2005/02/14 17:13:29 peter * truncate log } diff --git a/rtl/macos/system.pp b/rtl/macos/system.pp index 423d3f2c6a..d65c444faf 100644 --- a/rtl/macos/system.pp +++ b/rtl/macos/system.pp @@ -27,6 +27,7 @@ const DriveSeparator = ':'; PathSeparator = ','; {Is used in MPW and OzTeX} FileNameCaseSensitive = false; + CtrlZMarksEOF: boolean = false; (* #26 not considered as end of file *) maxExitCode = 65535; @@ -559,7 +560,10 @@ end. { $Log$ - Revision 1.31 2005-03-20 19:37:31 olle + Revision 1.32 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.31 2005/03/20 19:37:31 olle + Added optional path translation mechanism Revision 1.30 2005/02/14 17:13:30 peter diff --git a/rtl/morphos/system.pp b/rtl/morphos/system.pp index f15b8621d5..9323d4dfa9 100644 --- a/rtl/morphos/system.pp +++ b/rtl/morphos/system.pp @@ -43,6 +43,7 @@ const StdErrorHandle : LongInt = 0; FileNameCaseSensitive : Boolean = False; + CtrlZMarksEOF: boolean = false; (* #26 not considered as end of file *) sLineBreak : string[1] = LineEnding; DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsLF; @@ -335,7 +336,10 @@ end. { $Log$ - Revision 1.32 2005-02-14 17:13:30 peter + Revision 1.33 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.32 2005/02/14 17:13:30 peter * truncate log Revision 1.31 2005/02/07 21:30:12 peter diff --git a/rtl/netware/system.pp b/rtl/netware/system.pp index 69bacfdf95..7317b364eb 100644 --- a/rtl/netware/system.pp +++ b/rtl/netware/system.pp @@ -52,6 +52,7 @@ CONST StdErrorHandle : THandle = 0; FileNameCaseSensitive : boolean = false; + CtrlZMarksEOF: boolean = false; (* #26 not considered as end of file *) sLineBreak = LineEnding; DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF; @@ -488,7 +489,10 @@ Begin End. { $Log$ - Revision 1.36 2005-02-14 17:13:30 peter + Revision 1.37 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.36 2005/02/14 17:13:30 peter * truncate log Revision 1.35 2005/02/06 16:57:18 peter diff --git a/rtl/netwlibc/system.pp b/rtl/netwlibc/system.pp index 44d4de8c29..4a861071ba 100644 --- a/rtl/netwlibc/system.pp +++ b/rtl/netwlibc/system.pp @@ -58,6 +58,7 @@ CONST StdErrorHandle : THandle = 0; FileNameCaseSensitive : boolean = false; + CtrlZMarksEOF: boolean = false; (* #26 not considered as end of file *) sLineBreak = LineEnding; DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF; @@ -559,7 +560,10 @@ Begin End. { $Log$ - Revision 1.14 2005-02-14 17:13:30 peter + Revision 1.15 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.14 2005/02/14 17:13:30 peter * truncate log Revision 1.13 2005/02/06 16:57:18 peter diff --git a/rtl/os2/system.pas b/rtl/os2/system.pas index 816865e490..6992f3bea9 100644 --- a/rtl/os2/system.pas +++ b/rtl/os2/system.pas @@ -27,8 +27,6 @@ interface {.$define DEBUGARGUMENTS} {$endif SYSTEMDEBUG} -{$DEFINE EOF_CTRLZ} - { $DEFINE OS2EXCEPTIONS} {$I systemh.inc} @@ -104,6 +102,7 @@ const UnusedHandle=-1; LFNSupport: boolean = true; FileNameCaseSensitive: boolean = false; + CtrlZMarksEOF: boolean = true; (* #26 is considered as end of file *) sLineBreak = LineEnding; DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF; @@ -771,7 +770,10 @@ begin end. { $Log$ - Revision 1.82 2005-03-27 20:50:35 hajny + Revision 1.83 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.82 2005/03/27 20:50:35 hajny * correction of previous mistyping Revision 1.81 2005/03/27 20:40:54 hajny diff --git a/rtl/palmos/system.pp b/rtl/palmos/system.pp index e12b53b7d7..981c5f1d8b 100644 --- a/rtl/palmos/system.pp +++ b/rtl/palmos/system.pp @@ -30,6 +30,7 @@ const DriveSeparator = ':'; PathSeparator = ';'; FileNameCaseSensitive = false; + CtrlZMarksEOF: boolean = false; (* #26 not considered as end of file *) maxExitCode = 255; {$ERROR TODO: CONFIRM THIS} Type @@ -109,7 +110,10 @@ end. { $Log$ - Revision 1.7 2005-02-14 17:13:31 peter + Revision 1.8 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.7 2005/02/14 17:13:31 peter * truncate log } diff --git a/rtl/unix/sysunixh.inc b/rtl/unix/sysunixh.inc index 3392753abf..a3029b459a 100644 --- a/rtl/unix/sysunixh.inc +++ b/rtl/unix/sysunixh.inc @@ -41,6 +41,7 @@ const StdErrorHandle = 2; FileNameCaseSensitive : boolean = true; + CtrlZMarksEOF: boolean = false; (* #26 not considered as end of file *) sLineBreak = LineEnding; DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsLF; @@ -55,7 +56,10 @@ var argc:longint;external name 'operatingsystem_parameter_argc'; { $Log$ - Revision 1.25 2005-02-14 17:13:31 peter + Revision 1.26 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.25 2005/02/14 17:13:31 peter * truncate log Revision 1.24 2005/02/14 16:32:41 peter diff --git a/rtl/watcom/system.pp b/rtl/watcom/system.pp index 7af35e5f98..442612df84 100644 --- a/rtl/watcom/system.pp +++ b/rtl/watcom/system.pp @@ -52,6 +52,7 @@ const StdErrorHandle = 2; FileNameCaseSensitive : boolean = false; + CtrlZMarksEOF: boolean = true; (* #26 is considered as end of file *) sLineBreak = LineEnding; DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF; @@ -1305,8 +1306,6 @@ end; Text File Handling *****************************************************************************} -{$DEFINE EOF_CTRLZ} - {$i text.inc} @@ -1541,7 +1540,10 @@ End. { $Log$ - Revision 1.20 2005-02-14 17:13:32 peter + Revision 1.21 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.20 2005/02/14 17:13:32 peter * truncate log Revision 1.19 2005/02/01 20:22:50 florian diff --git a/rtl/win32/system.pp b/rtl/win32/system.pp index 62a5f6f9e1..aca0375402 100644 --- a/rtl/win32/system.pp +++ b/rtl/win32/system.pp @@ -28,9 +28,6 @@ interface {$define Set_i386_Exception_handler} {$endif cpui386} -{ Ctrl-Z means EOF } -{$DEFINE EOF_CTRLZ} - { include system-independent routine headers } {$I systemh.inc} @@ -58,6 +55,7 @@ const StdErrorHandle : THandle = 0; FileNameCaseSensitive : boolean = true; + CtrlZMarksEOF: boolean = true; (* #26 not considered as end of file *) sLineBreak = LineEnding; DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF; @@ -1110,7 +1108,10 @@ end. { $Log$ - Revision 1.72 2005-03-21 16:31:33 peter + Revision 1.73 2005-04-03 21:10:59 hajny + * EOF_CTRLZ conditional define replaced with CtrlZMarksEOF, #26 handling made more consistent (fix for bug 2453) + + Revision 1.72 2005/03/21 16:31:33 peter * fix crash under win32 with previous reallocmem fix Revision 1.71 2005/03/02 19:18:42 florian