Maurice Lombardi a écrit:
Tom Schneider a écrit:
I wrote before:
EOF is not true on a reset empty file.
for GPC.
gpc 20040516, based on gcc-3.3.3
I just found in the book PASCAL User Manual and Report, Fourth Edition ISO Pascal Standard, Kathleen Jensen and Niklaus Wirth 1991 page 158:
"A file is called \emph{empty} if its length is zero."
As you can see in the previous email, I created two empty files with echo -n "" > filename and then showed by three tests (file, ls and wc) that they were empty. In the GPC compiled program, I reset each file and then tested them and found that each was not at eof.
Strange. doing the same on DJGPP (W98se DOS box) with gpc 20041218 based on gcc 3.2.3 behaves as expected. All is done manually with suitable tools to binary visualize the true content of files, no shell scripts or functions which could be too intelligent (I have bash, no tcsh) and hide something "unimportant", for example no linefeed or ^Z (a DOS nicety on text files) added at the end.
An afterthought What if you eliminate the problems which may be due to the shell by creating the empty files by the pascal program itself e.g. ----------------------------------------------------------------------- program gpcbug2005jan27(namebook, namelist, output); (* Dr. Thomas D. Schneider National Cancer Institute Laboratory of Experimental and Computational Biology Molecular Information Theory Group Frederick, Maryland 21702-1201 toms@ncifcrf.gov permanent email: toms@alum.mit.edu (use only if first address fails) http://www.lecb.ncifcrf.gov/~toms/ *) const version = 1.00; (* of gpcbug2005jan27.p 2005 jan 27 *)
var namebook, namelist: text;
begin rewrite(namebook); close(namebook);
reset(namebook); if eof(namebook) then writeln(output,'eof of namebook') else writeln(output,'NOT eof of namebook');
rewrite(namelist); close(namelist);
reset(namelist); if eof(namelist) then writeln(output,'eof of namelist') else writeln(output,'NOT eof of namelist'); end. -----------------------------------------------------------
Files are created by the rewrite, and you can inspect the resulting files to be sure they are empty. You can also write a separate program to create the files.
Maurice