[tlbuild] dvi test?
John Hawkinson
jhawk at alum.mit.edu
Mon Jan 31 05:11:10 CET 2022
Karl Berry <karl at freefriends.org> wrote on Sun, 30 Jan 2022
at 17:31:11 EST in <202201302231.20UMVBVp019498 at tug.org>:
> Seems like the system has decided not to (re)open the real file, and
> instead to return 0 0 0 0 0 ... as if one had seeked past the end or
> some such. Or an earlier error has made the fd invalid. Or ... ?
> It presumably has to be something in the OS operation.
>
> Could add some code at the point of the reread (sorry, I don't know
> where that is) to just read(2) some bytes and see what you get. I
> predict all zeros.
Indeed. I assume you're happy with fread()+fseek() since read() implies screwing over stdio.
diff --git a/texk/xdvik/dvi-init.c b/texk/xdvik/dvi-init.c
index 6126a08..d82d23e 100644
--- a/texk/xdvik/dvi-init.c
+++ b/texk/xdvik/dvi-init.c
@@ -777,6 +777,18 @@ process_preamble(FILE *fp, dviErrFlagT *errflag)
static char job_id[300];
TRACE_FILES((stderr, "process_preamble: fp = %p, errflag = %d", (void *)fp, *errflag));
+
+ 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]);
+ rv = fseek(fp, 0, SEEK_SET);
+ if (rv == -1) {
+ perror("fseek");
+ }
+
if (get_byte(fp) != PRE) {
*errflag = NOT_A_DVI_FILE;
I think you get the expected result:
jhawk at lrr xdvik % TEXMFROOT=/usr/local/texlive/2021 TEXMFCNF=$TEXMFROOT/texmf-dist/web2c ./xdvi-bin t2a.dvi
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
xdvi-bin: set_no_char: attempt to set character of unknown font, offset 42
xdvi-bin 22.87.05 (Xaw toolkit): ../../../texk/xdvik/dvi-draw.c:488: Shouldn't happen: I'll abort now, to help you debugging this.
zsh: abort TEXMFROOT=/usr/local/texlive/2021 TEXMFCNF=$TEXMFROOT/texmf-dist/web2c
The first two are before hitting shift-R and the 2nd two after after hitting it.
BTW, why isn't FILES debugging listed in the manpage? It stops at 131072, but xdvi-debug.h continues:
#define DBG_FIND 262144
#define DBG_FILES 524288
Anyhow, with -debug 524288, everything after hitting shift-R:
../../../texk/xdvik/dvi-init.c:1832: FILES: load_dvi_file: going to read 0x207f6ec10
../../../texk/xdvik/dvi-init.c:779: FILES: process_preamble: fp = 0x207f6ec10, errflag = 0
debug read 1 bytes from fp: -9 2 1 -125 -110 -64 28 59
../../../texk/xdvik/dvi-init.c:814: FILES: process_preamble: fp = 0x207f6ec10, errflag = 0, returning True
../../../texk/xdvik/dvi-init.c:833: FILES: find_postamble on fp: 0x207f6ec10
../../../texk/xdvik/dvi-init.c:867: FILES: find_postamble: returning TRUE
../../../texk/xdvik/dvi-init.c:958: FILES: read_postamble: reading 0x207f6ec10 (1)
../../../texk/xdvik/dvi-init.c:1076: FILES: read_postamble: returning TRUE
../../../texk/xdvik/dvi-init.c:1376: FILES: internal_open_dvi for |/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/t2a.dvi|
../../../texk/xdvik/dvi-init.c:1246: FILES: file_exists_p for |/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/t2a.dvi|
../../../texk/xdvik/dvi-init.c:1253: FILES: m_dvi_fp for |/Users/jhawk/src/xdvik-22.87.05/Work/texk/xdvik/t2a.dvi| = 0x207f6ec10
../../../texk/xdvik/dvi-init.c:1302: FILES: internal_init_dvi, globals.dvi_file.bak_fp = 0x207f6ed40
../../../texk/xdvik/dvi-init.c:779: FILES: process_preamble: fp = 0x207f6ed40, errflag = 14
debug read 1 bytes from fp: 0 0 0 0 0 0 0 0
../../../texk/xdvik/dvi-init.c:795: FILES: process_preamble: fp = 0x207f6ed40, errflag = 3, returning False
../../../texk/xdvik/events.c:6049: FILES: Redraw page on 0x207f6ed40
../../../texk/xdvik/events.c:6065: FILES: redraw_page: current_page = 0
../../../texk/xdvik/dvi-init.c:1718: FILES: dvi_file_changed: fp = 0x0?
../../../texk/xdvik/dvi-init.c:1722: FILES: m_dvi_fp == NULL
../../../texk/xdvik/dvi-init.c:1768: FILES: file not changed
xdvi-bin: set_no_char: attempt to set character of unknown font, offset 42
xdvi-bin 22.87.05 (Xaw toolkit): ../../../texk/xdvik/dvi-draw.c:488: Shouldn't happen: I'll abort now, to help you debugging this.
zsh: abort TEXMFROOT=/usr/local/texlive/2021 TEXMFCNF=$TEXMFROOT/texmf-dist/web2c -debu
And so of course this makes sense given:
../../../texk/xdvik/dvi-init.c:795: FILES: process_preamble: fp = 0x207f6ed40, errflag = 3, returning False
And I think Bruno pointed this out previously in https://tug.org/pipermail/tlbuild/2022q1/005100.html
"Hrmm."
--
jhawk at alum.mit.edu
John Hawkinson
More information about the tlbuild
mailing list.