I'm not sure what the correct behaviour should be in the attached program, but GPC's behaviour is different from the previous extended Pascal compiler I used (I'm not saying that the previous compiler was right).
The previous compiler allowed one to write to a text file that had been opened with 'reset' and then 'extend'ed. GPC says:
./daj13: cannot write to read only file `daj13.pas' (error #422)
===== program daj13(input,output);
var f:text;
begin reset(f,'daj13.pas'); extend(f); writeln(f,'extra text'); end.
David James wrote:
[...] The previous compiler allowed one to write to a text file that had been opened with 'reset' and then 'extend'ed. GPC says:
./daj13: cannot write to read only file `daj13.pas' (error #422)
===== program daj13(input,output);
var f:text;
begin reset(f,'daj13.pas'); extend(f); writeln(f,'extra text'); end.
If you `close' the file before the `extend', it works.
Do you happen to know what Extended Pascal thinks about how `close' should work?
Peter
On 11 Dec 99, at 12:43, Peter Gerwinski wrote:
If you `close' the file before the `extend', it works.
Do you happen to know what Extended Pascal thinks about how `close' should work?
Yes, but "close" isn't part of Extended Pascal. (Well, to be honest, David's program isn't Extended Pascal either, as there is no second argument to "reset" in EP either. However, if this is rewritten in EP to use bindings, it still fails improperly.)
By the way, a related bug is that GPC accepts the "close" function as predefined in EP (i.e., with --extended-pascal), which it shouldn't. It should give a compilation error.
-- Dave
J. David Bryan wrote:
By the way, a related bug is that GPC accepts the "close" function as predefined in EP (i.e., with --extended-pascal), which it shouldn't. It should give a compilation error.
This will be fixed in the next snapshot.
Peter