Emil Jerabek wrote:
On Fri, Apr 02, 2004 at 12:59:30PM +0200, Frank Heckenbach wrote:
Hi,
there's a strange case when using relative file names and changing the directory. (Incidentally I was made aware of this by a bugfix in the ncurses library (C code) some while ago ... ;-) Consider this program:
program Foo;
var i: Integer; f: Text;
begin Assign (f, 'test.dat'); Rewrite (f); WriteLn (f, 42); Close (f); ChDir ('..'); Reset (f); ReadLn (f, i); WriteLn (i) end.
It fails under both GPC and BP because `Reset' tries to open a file `test.dat' in a different directory than it was created.
[...]
How do other compilers behave? What would be the expected behaviour of code like above if it actually occurs in practice?
Frank
IMHO this is quite natural. There's no reason to close the file if I want its "identity" to be preserved.
I'm not sure. I'd rather consider `Assign' to be "identity giving" in this context. BTW, without closing it works under GPC and still fails under BP.
Frank