[tlbuild] dvi test? [fstat check]
Karl Berry
karl at freefriends.org
Tue Feb 1 00:20:53 CET 2022
- if (fstat(fileno(m_dvi_fp), &fstatbuf) != 0 || S_ISDIR(fstatbuf.st_mode)) { /* if it's a directory */
+ int rv = fstat(fileno(m_dvi_fp), &fstatbuf);
+ if (rv == -1) {
+ perror("fstat");
+ }
+ if (S_ISDIR(fstatbuf.st_mode)) { /* if it's a directory */
I committed the following change (r61830), following yours, except
returning if the fstat fails. (I have no clue as to why the fstat is
failing, but maybe that is the system-dependent change made in the newer
macos's?)
I didn't use the intermediate rv variable since mid-block declarations
cause portability problems. (Although probably not on systems that can
compile xdvi, but anyway ...)
xdvi already calls perror in many places, with no particular consistency
about the arg string format, so I just went with it.
Paul, I suppose this or something similar (please advise) should be
installed upstream ... --thanks, karl.
--- dvi-init.c (revision 61828)
+++ dvi-init.c (working copy)
@@ -1242,7 +1242,13 @@
/* fprintf(stderr, "after internal_open_dvi2: xfopen\n"); */
/* shouldn't happen */
- if (fstat(fileno(m_dvi_fp), &fstatbuf) != 0 || S_ISDIR(fstatbuf.st_mode)) { /* if it's a directory */
+ if (fstat(fileno(m_dvi_fp), &fstatbuf) == -1) {
+ perror("xdvi: file_exists_p: fstat");
+ fclose(m_dvi_fp);
+ m_dvi_fp = NULL;
+ return False;
+ }
+ if (S_ISDIR(fstatbuf.st_mode)) { /* if it's a directory */
*errflag = FILE_IS_DIRECTORY;
fclose(m_dvi_fp);
m_dvi_fp = NULL;
More information about the tlbuild
mailing list.