Hello,
My name is Scott A. Moore, I am the person who performed
some of the ISO 7185 compliance testing on GPC. I have
done a minor update to some of my ISO 7185 compliance testing
material, and reran this against the current version of GPC
(2.95). In the process, I have discovered a compliance
problem with GPC.
Please reference the program:
==============================================================
program test(output);
var f: text;
c: char;
begin
rewrite(f);
writeln(f, 'how now');
writeln(f, 'brown cow');
reset(f);
write('''');
while not eof(f) do begin
if eoln(f) then write('<eoln>');
read(f, c);
write(c)
end;
write('''');
writeln(' s/b ''how now<eoln> brown cow<eoln> ''');
rewrite(f);
writeln(f, 'too much');
write(f, 'too soon');
reset(f);
write('''');
while not eof(f) do begin
if eoln(f) then write('<eoln>');
read(f, c);
write(c)
end;
write('''');
writeln(' s/b ''too much<eoln> too soon<eoln> ''');
end.
================================================================
The results from GPC for running this command are as follows:
================================================================
C:\TEST>test
'how now<eoln> brown cow<eoln> ' s/b 'how now<eoln> brown cow<eoln> '
'too much<eoln> too soon' s/b 'too much<eoln> too soon<eoln> '
C:\TEST>
================================================================
The first section of the test verifies that eoln in text file
is replaced with space, GPC passes this.
The second section of the test verifies that eoln is automatically
inserted at the end of a text file if it was terminated without
a eoln. See ISO 7185 section 6.4.3.5:
=====================================================================
There shall be a file-type that is denoted by the required
structured-type-identifier text. The structure of the type denoted
by text shall de ne an additional sequence-type whose values shall be
designated lines. A line shall be a sequence cs ~S(end-of-line),
where cs is a sequence of components possessing the char-type, and
end-of-line shall represent a special component-value. Any assertion
in clause 6 that the end-of-line value is attributed to a variable
other than a component of a sequence shall be construed as an
assertion that the variable has attributed to it the char-type value
space. If l is a line, then no component of l other than l.last
shall be an end-of-line. There shall be an implementation-defined
subset of the set of char-type values, designated characters
prohibited from text les; the effect of causing a character in that
subset to be attributed to a component of either t.L or t.R for any
text le t shall be implementation-dependent. A line-sequence, ls,
shall be either the empty sequence or the sequence l ~ ls' where l
is a line and ls' is a line-sequence. Every value t of the type
denoted by text shall satisfy the following two rules:
a) If t.M = Inspection, then t.L ~t.R shall be a line-sequence.
b) If t.M = Generation, then t.L ~t.R shall be ls ~cs, where ls is
a line-sequence and cs is a sequence of components possessing the
char-type.
====================================================================
Basically, the rules say that a text file shall consist of either
whole lines, or be entirely empty. Whole lines are defined as
"~S(end of line)", or a series of arbitrary characters terminated
by end of line.
In effect, the program processor must arrange for eoln to be true
at the end of a file, either by faking it while reading, or by
forcing an eoln to be written at the end of a file during generation.
Thank you for your attention.