In a continuation of the thread:
http://www.gnu-pascal.de/crystal/gpc/en/raw-mail10017.html
Regarding conformance to the ISO 7185. It seems that GPC will correctly report EOLN before EOF even when none exists in the file. However, after successfully reading the end of line character, EOLN will still return true while EOF also simultaneously returns true.
This has a tendency to give odd results. EOF and EOLN should be mutually exclusive. If the file doesn't properly have it's end of line marker before the end of the file, GPC can, should, and does currently insert the end of line into the buffer. But once it's been read, EOF should return true, and EOLN should not.
I'm unfortunately not familiar enough with how gpc source is organized, so I'm not sure where to make the needed correction, in order to submit the patch. I would be willing to work on it however, if someone could point me in the right direction.
Thanks, Chad Simmons
The following program demonstrates the unusual behavior:
PROGRAM GRADES (INPUT,OUTPUT);
VAR SUM, COUNT, GRADE : INTEGER;
BEGIN SUM := 0; COUNT := 0;
WRITELN('ENTER GRADES AND PRESS CTRL-D WHEN FINISHED'); READ(GRADE);
WHILE NOT EOF DO BEGIN SUM := SUM + GRADE; COUNT := COUNT + 1;
IF EOLN THEN READ(CH);
WRITELN('EOLN? ', EOLN); WRITELN('EOF? ', EOF);
IF NOT EOF THEN READ(GRADE); END;
WRITELN('TOTAL STUDENTS ', COUNT); WRITELN('CLASS AVERAGE ', SUM DIV COUNT); END.
The output:
$ ./grades ENTER GRADES AND PRESS CTRL-D WHEN FINISHED 20 30 40EOLN? False EOF? False EOLN? False EOF? False EOLN? True EOF? True TOTAL STUDENTS 3 CLASS AVERAGE 30
gpc -v output: $ gpc -v Using built-in specs. Configured with: ../src/configure -v --enable-languages=c,pascal --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --disable-libmudflap --enable-checking=release x86_64-linux-gnu Thread model: posix gpc version 20070904, based on gcc-4.1.3 20080301 (prerelease) (Ubuntu 2.1-4.1.2-19ubuntu1)