perl uncovers Ultrix 1.2 bug?

Brain in Neutral bin at rhesus.primate.wisc.edu
Fri Feb 5 01:16:54 AEST 1988


This is on a VAX 8200 running Ultrix 1.2.  It seems to me that file
reads after eof mess up the file pointer.  If ftell is called after eof
on a file is reached, it returns the correct answer.  If fgets (fgetc,
etc.) is called again, it returns NULL (as it should), but ftell
returns a different value!  I discovered this because it makes perl
fail the io.tell validation program, tests 3 and 12.

The problem is illustrated by the following short program.

# include	<stdio.h>

main ()
{
FILE	*f;
char	buf[BUFSIZ];
int	i;

	f = fopen ("/etc/passwd", "r");
	while (fgets (buf, BUFSIZ, f) != NULL) { /* empty */ }
	printf ("tell = %D\n", ftell (f));
	for (i = 0; i < 10; ++i)
	{
		fgets (buf, BUFSIZ, f);
		printf ("tell = %D\n", ftell (f));
	}
}


On our system /etc/passwd look like this:

-rw-r--r--  1 root         8783 Feb  3 14:38 /etc/passwd

The result of running the above program is:

	tell = 8783
	tell = 8784
	tell = 8785
	tell = 8786
	tell = 8787
	tell = 8788
	tell = 8789
	tell = 8790
	tell = 8791
	tell = 8792
	tell = 8793



More information about the Comp.sources.bugs mailing list