Hi, unless i'm missing something, everything discussed in this thread should be fixed now, with the commit appended below.
Ingo Schwarze wrote on Thu, Dec 20, 2018 at 07:35:22PM +0100: > Raf Czlonka wrote on Thu, Dec 20, 2018 at 02:59:23PM +0000: [...] >> Rebuilding whatis databases: >> makewhatis: man7/cmake-properties.7: ERROR: No such file or directory [...] > 1. The line number is missing, even though it is relevant. > 2. Mentioning the .so request would be useful. > 3. Mentining the file that was not found would be useful. > 4. Most importantly, makewhatis(8) is not supposed > to print mandoc(1) errors in this manner. [...] > Bug number 6: duoplicate reporting, two messages about the same problem > in the input file, both with incomplete information. Not sure i can fix > that one, but i shall try. Fixing all that required much smaller code changes than i expected, but explaining why these small changes do the job needed a substantial commit message... Speak up if you still see issues! Thanks, Ingo Log Message: ----------- Move the full responsibility for reporting open(2) errors from mparse_open() to the caller. That is better because only the caller knows its preferred reporting method and format and only the caller has access to all the data that should be included - like the column number in .so processing or the current manpath in makewhatis(8). Moving the mandoc_msg() call out is possible because the caller can call strerror(3) just as easily as mparse_open() can. Move mandoc_msg_setinfilename() closer to the parsing of the file contents, to avoid problems *with* the file (like non-existence, lack of permissions, etc.) getting misreported as problems *in* the file. Fix the column number reported for .so failure: let it point to the beginning of the filename. Taken together, this prevents makewhatis(8) from spewing confusing messages about .so failures to stderr, a bug reported by Raf Czlonka <rczlonka at gmail dot com> on ports@. It also prevents mandoc(1) from issuing *two* messages for every single .so failure. Modified Files: -------------- mandoc: main.c read.c Revision Data ------------- Index: main.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/main.c,v retrieving revision 1.313 retrieving revision 1.314 diff -Lmain.c -Lmain.c -u -p -r1.313 -r1.314 --- main.c +++ main.c @@ -510,7 +510,6 @@ main(int argc, char *argv[]) } else thisarg = *argv; - mandoc_msg_setinfilename(thisarg); fd = mparse_open(curp.mp, thisarg); if (fd != -1) { if (use_pager) { @@ -523,11 +522,13 @@ main(int argc, char *argv[]) conf.output.tag : *argv; } + mandoc_msg_setinfilename(thisarg); if (resp == NULL || resp->form == FORM_SRC) parse(&curp, fd, thisarg); else passthrough(resp->file, fd, conf.output.synopsisonly); + mandoc_msg_setinfilename(NULL); if (ferror(stdout)) { if (tag_files != NULL) { @@ -545,8 +546,9 @@ main(int argc, char *argv[]) outdata_alloc(&curp); terminal_sepline(curp.outdata); } - } - mandoc_msg_setinfilename(NULL); + } else + mandoc_msg(MANDOCERR_FILE, 0, 0, + "%s", strerror(errno)); if (curp.wstop && mandoc_msg_getrc() != MANDOCLEVEL_OK) break; Index: read.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/read.c,v retrieving revision 1.207 retrieving revision 1.208 diff -Lread.c -Lread.c -u -p -r1.207 -r1.208 --- read.c +++ read.c @@ -372,8 +372,9 @@ rerun: mparse_readfd(curp, fd, ln.buf + of); close(fd); } else { - mandoc_msg(MANDOCERR_SO_FAIL, curp->line, - pos, ".so %s", ln.buf + of); + mandoc_msg(MANDOCERR_SO_FAIL, + curp->line, of, ".so %s: %s", + ln.buf + of, strerror(errno)); ln.sz = mandoc_asprintf(&cp, ".sp\nSee the file %s.\n.sp", ln.buf + of); @@ -633,7 +634,6 @@ mparse_open(struct mparse *curp, const c /* Neither worked, give up. */ - mandoc_msg(MANDOCERR_FILE, 0, 0, "%s", strerror(errno)); return -1; }