This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [libcpp] [PATCH] Handle DOS EOF character for DJGPP


dj@redhat.com (DJ Delorie)  wrote on 18.04.05 in <200504181857.j3IIvf4s032621@greed.delorie.com>:

> > ^Z can legitimately appear in the middle of a file even under DJGPP.
>
> Microsoft disagrees with you.
>
> ^Z can NOT legitimately appear in the middle of a text file under
> MS-DOS derivatives, because by definition, it marks the end of the
> text.  Bytes after the ^Z are not technically part of the file, but
> part of the disk buffers used to hold that file.  It's a stupid
> design, left over from the CP/M days, but that's the way it is
> nonetheless.

Actually, the CP/M-design was to fill the space between end of file and  
end of last record with ^Z, because every file had to be an integral  
multiple of the record size - it was a filesystem deficiency. (That space  
could be empty.)

Current best practices is to (1) *never* write a ^Z as EOF-marker, and
(2) only accept one as the exact last byte of a file. Pretty much all  
software I know does either that, or gives no special meaning to ^Z at  
all.

It should come as no surprise that Microsoft occasionally does not follow  
best practices; that doesn't make the practices they follow (which aren't  
consistent in any case) any better.

Really: reacting to ^Z in the middle of a file is *WRONG*.

> Note that all DJGPP programs reading files in text mode *will* stop at
> the first ^Z character,

I consider this a bug.

MfG Kai


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]