----- Original Message ----- From: "Frank Heckenbach" ih8mj@fjf.gnu.de To: gpc@gnu.de Sent: Tuesday, March 23, 2004 5:20 AM Subject: Re: ISO 7185 compliance issue for GPC
Scott Moore wrote:
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.
BTW, 2.95 is the backend (GCC) version number. For Pascal-level reports (as opposed to code-generation issues), usually the GPC version number is more important. `gpc -v' will tell both. But in this case, I think it applies to all recent GPC versions, anyway ...
Appreciate the info.
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:
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.
(BTW, I'm not even sure if the latter would be sufficient, since the condition then wouldn't be satisfied for files written in other ways.)
For the example of IP Pascal, the support library corrects input from text files both as far detecting the lack of proper trailing eoln, and corrects it, as well as allowing any form of eoln to appear, including cr/lf, lf/cf, cr or lf alone. A state variable is used to perform all of this, ie., the state of input is tracked, and corrected as needed. The utility of this really shows when I move from Windows to Linux to Mac. All of them use different line endings, but none of the programs compiled with IP Pascal care, they can input from any system at any time. For example, I can move a file from Unix to Windows, and it reads properly without any special options or other arrangements.
Well, first I must say that this is a point where I consider the standard broken. (E.g., I have a text editor written in Pascal, and I want it to be able to handle files with or without trailing EOLn's, without appending them either when reading or writing the files.)
I agree, and heartly recommend the method used in IP Pascal for this, which is completely ISO 7185 compatible. The ISO rules only specify the special handling on files of "text". A declaration "file of char" (which text was originally defined to be equivalent to in Wirth prestandard) is, as allowed in the standard, truly a linear file of characters. This gives any program wanting %100 control of its output format that ability.
So I've fixed it now, but only in the standard Pascal modes (`--classic-pascal', `--extended-pascal'). Though usually we try to avoid changing the behaviour based on the dialect options (only restrict extensions), there are some cases where this seems preferable (such as default width for writing Booleans, or no compile-time error for division by zero) ...
I'm not attaching a patch here, since it requires changes spread over several source files which might conflict with other changes I've made meanwhile. But it will be ok in the next GPC release.
Ok, I'll look for that. Thanks for the fast turnaround.
If you don't mind, I'll put your test program in the test suite for regression testing (scott1.pas, with `{$classic-pascal}' inserted).
With my complements.
Frank
-- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: 51FF C1F0 1A77 C6C2 4482 4DDC 117A 9773 7F88 1707