[tlbuild] dvi test?
Bruno Haible
bruno at clisp.org
Mon Jan 31 11:49:31 CET 2022
John Hawkinson wrote:
> + static char buf[8];
> + int rv = fread(&buf, sizeof(buf), 1, fp);
> + if (!rv) {
> + perror("fread");
> + }
> + printf("debug read %d bytes from fp: %d %d %d %d %d %d %d %d \n", rv, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
> debug read 1 bytes from fp: -9 2 1 -125 -110 -64 28 59
> debug read 1 bytes from fp: -9 2 1 -125 -110 -64 28 59
> debug read 1 bytes from fp: -9 2 1 -125 -110 -64 28 59
> debug read 1 bytes from fp: 0 0 0 0 0 0 0 0
Before this printout, it would be useful to also print the position
of the underlying file descriptor:
printf ("debug fd position: %ld, ", (long) lseek (fileno (fp), 0, SEEK_CUR));
Why? Because it could well be that the position stored in fp and the
position of fileno(fp) got out-of-sync. Various systems have bugs in
this area. Some known bugs exist around fflush(), some around ungetc()[1].
xdvi doesn't use either of the two. It might be a not-yet-known bug in macOS.
Bruno
[1] https://www.gnu.org/software/gnulib/manual/html_node/fflush.html
More information about the tlbuild
mailing list.