Don Simons wrote:
> Thanks for the explanation. And of course I do know how PMX knows it's at
> the end of the input, i.e.,  when there are no more lines of input to
> read.
> The thing I still don't understand is exactly this: if someone sends me a
> file generated in their favorite OS, and I look at its binary image using
> the PC command line program debug, is there any specific binary character
> or characters that announces "this is the end of the file"?

No - the location of the end of data is indicated by the file's meta-data in 
the OS (i.e. it's the end of the file because you've read the x bytes listed in 
the directory tree as belonging to that file). That's the case right back to 
MS-DOS 1.00. There have been user-level conventions which involve using other 
markers (usually Control-Z) but that's either for compatibility with (very 
very) old and retired operating systems or for programs receiving input from 
standard input, rather than a file, where EOF is not a possible condition.

> I think that in PC OS's the answer is "no", because after the last "0D 0A"
> (CR LF),

Note that a text file, certainly on Windows, is not even guaranteed to end with 
CRLF - Windows Notepad, for example, does not insert CRLF at the end of a text 
file unless you explicitly put a newline.

Personally, my preference when reading text files (which eliminates all these 
headaches) is to use a small lex script, rather than any underlying language 
functions, so that you can treat the regular expression \r?\n as the end of 
file marker - that copes with mixed-mode files (where a text editor has managed 
to mix LF and CRLF endings) and is Windows/Unix neutral[*]. Equally, assuming 
there are no lexer generators for Fortran, then as long as you have support for 
opening files in binary mode, the state machine required is pretty simple.


David 


[*] yes, I don't give the smallest damn about Mac OS 9 and earlier...

-------------------------------
TeX-music@tug.org mailing list
If you want to unsubscribe or look at the archives, go to 
http://tug.org/mailman/listinfo/tex-music

Reply via email to