gbranden pushed a commit to branch master in repository groff. commit 25ef9f6bdad8f410749388e20caaa5c2d5e9ddee Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Wed Feb 26 04:55:59 2025 -0600
[eqn,pic,preconv,refer,soelim,tbl]: Fix lf reqs. Use `lf` requests _even more_ carefully. * src/preproc/eqn/main.cpp (do_file): * src/preproc/pic/troff.cpp (troff_output::set_location): * src/preproc/preconv/preconv.cpp (do_file): * src/preproc/refer/refer.cpp (do_file, output_pending_line): * src/preproc/soelim/soelim.cpp (set_location): * src/preproc/tbl/main.cpp (main): * src/preproc/tbl/table.cpp (set_troff_location): Output file name with leading double quote in generated `lf` request only if it doesn't already start with one. Avoids misleading output like: troff: backtrace: file '"man/groff_char.7':1062 troff:"man/groff_char.7:1062: warning: special character '.j' not defined --- ChangeLog | 15 +++++++++++++++ src/preproc/eqn/main.cpp | 3 ++- src/preproc/pic/troff.cpp | 3 ++- src/preproc/preconv/preconv.cpp | 3 ++- src/preproc/refer/refer.cpp | 7 ++++--- src/preproc/soelim/soelim.cpp | 3 ++- src/preproc/tbl/main.cpp | 10 +++++++--- src/preproc/tbl/table.cpp | 4 +++- 8 files changed, 37 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 05d4eaeae..6e1dc1271 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2025-02-26 G. Branden Robinson <g.branden.robin...@gmail.com> + + [eqn,pic,preconv,refer,soelim,tbl]: Use `lf` requests _even + more_ carefully. + + * src/preproc/eqn/main.cpp (do_file): + * src/preproc/pic/troff.cpp (troff_output::set_location): + * src/preproc/preconv/preconv.cpp (do_file): + * src/preproc/refer/refer.cpp (do_file, output_pending_line): + * src/preproc/soelim/soelim.cpp (set_location): + * src/preproc/tbl/main.cpp (main): + * src/preproc/tbl/table.cpp (set_troff_location): Output file + name with leading double quote in generated `lf` request only if + it doesn't already start with one. + 2025-02-24 G. Branden Robinson <g.branden.robin...@gmail.com> Implement approximate (`troff -a`) output of zero-width nodes diff --git a/src/preproc/eqn/main.cpp b/src/preproc/eqn/main.cpp index e537d206a..35f7a0550 100644 --- a/src/preproc/eqn/main.cpp +++ b/src/preproc/eqn/main.cpp @@ -106,7 +106,8 @@ void do_file(FILE *fp, const char *filename) current_lineno = 1; current_filename = fn.contents(); if (output_format == troff) - (void) printf(".lf %d \"%s\n", current_lineno, current_filename); + (void) printf(".lf %d %s%s\n", current_lineno, + ('"' == current_filename[0]) ? "" : "\"", current_filename); while (read_line(fp, &linebuf)) { if (linebuf.length() >= 4 && linebuf[0] == '.' && linebuf[1] == 'l' && linebuf[2] == 'f' diff --git a/src/preproc/pic/troff.cpp b/src/preproc/pic/troff.cpp index 2a416780e..0687b0ff0 100644 --- a/src/preproc/pic/troff.cpp +++ b/src/preproc/pic/troff.cpp @@ -600,7 +600,8 @@ void troff_output::set_location(const char *s, int n) } } if (update_file_name) - printf(".lf %d \"%s\n", n, s); + printf(".lf %d %s%s\n", current_lineno, + ('"' == current_filename[0]) ? "" : "\"", current_filename); else printf(".lf %d\n", n); } diff --git a/src/preproc/preconv/preconv.cpp b/src/preproc/preconv/preconv.cpp index cd3d34a2a..b8517389f 100644 --- a/src/preproc/preconv/preconv.cpp +++ b/src/preproc/preconv/preconv.cpp @@ -1197,7 +1197,8 @@ do_file(const char *filename) string fn(filename); fn += '\0'; normalize_for_lf(fn); - (void) printf(".lf 1 \"%s\n", fn.contents()); + (void) printf(".lf 1 %s%s\n", ('"' == filename[0]) ? "" : "\"", + fn.contents()); } int success = 1; // Call converter (converters write to stdout). diff --git a/src/preproc/refer/refer.cpp b/src/preproc/refer/refer.cpp index a51518360..66eeda84f 100644 --- a/src/preproc/refer/refer.cpp +++ b/src/preproc/refer/refer.cpp @@ -475,8 +475,8 @@ static void do_file(const char *filename) normalize_for_lf(fn); current_lineno = 1; current_filename = fn.contents(); - (void) fprintf(outfp, ".lf %d \"%s\n", current_lineno, - current_filename); + (void) fprintf(outfp, ".lf %d %s%s\n", current_lineno, + ('"' == current_filename[0]) ? "" : "\"", current_filename); string line; for (;;) { line.clear(); @@ -691,7 +691,8 @@ static void output_pending_line() if (!accumulate) immediately_output_references(); if (need_syncing) { - fprintf(outfp, ".lf %d \"%s\n", current_lineno, current_filename); + fprintf(outfp, ".lf %d %s%s\n", current_lineno, + ('"' == current_filename[0]) ? "" : "\"", current_filename); need_syncing = 0; } } diff --git a/src/preproc/soelim/soelim.cpp b/src/preproc/soelim/soelim.cpp index 4364d335d..1f66cc395 100644 --- a/src/preproc/soelim/soelim.cpp +++ b/src/preproc/soelim/soelim.cpp @@ -130,7 +130,8 @@ void set_location() { if (!want_raw_output) { if (!want_tex_output) - printf(".lf %d \"%s\n", current_lineno, current_filename); + printf(".lf %d %s%s\n", current_lineno, + ('"' == current_filename[0]) ? "" : "\"", current_filename); else // XXX: Should we quote the file name? What's TeX-conventional? printf("%% file %s, line %d\n", current_filename, current_lineno); diff --git a/src/preproc/tbl/main.cpp b/src/preproc/tbl/main.cpp index d068d1f08..00c37fb71 100644 --- a/src/preproc/tbl/main.cpp +++ b/src/preproc/tbl/main.cpp @@ -1708,7 +1708,8 @@ int main(int argc, char **argv) if (argv[i][0] == '-' && argv[i][1] == '\0') { current_lineno = 1; current_filename = "-"; - (void) printf(".lf %d \"\%s\n", current_lineno, + (void) printf(".lf %d %s%s\n", current_lineno, + ('"' == current_filename[0]) ? "" : "\"", current_filename); process_input_file(stdin); } @@ -1725,7 +1726,8 @@ int main(int argc, char **argv) normalize_for_lf(fn); current_lineno = 1; current_filename = fn.contents(); - (void) printf(".lf %d \"\%s\n", current_lineno, + (void) printf(".lf %d %s%s\n", current_lineno, + ('"' == current_filename[0]) ? "" : "\"", current_filename); process_input_file(fp); } @@ -1734,7 +1736,9 @@ int main(int argc, char **argv) else { current_lineno = 1; current_filename = "-"; - (void) printf(".lf %d \"\%s\n", current_lineno, current_filename); + (void) printf(".lf %d %s%s\n", current_lineno, + ('"' == current_filename[0]) ? "" : "\"", + current_filename); process_input_file(stdin); } if (ferror(stdout)) diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp index fa12d1af2..a6e8d229d 100644 --- a/src/preproc/tbl/table.cpp +++ b/src/preproc/tbl/table.cpp @@ -3208,7 +3208,9 @@ void set_troff_location(const char *fn, int ln) string filename(fn); filename += '\0'; normalize_for_lf(filename); - printfs(".lf %1 \"%2\n", as_string(ln), filename.contents()); + printfs(".lf 1 %1%2\n", ('"' == filename[0]) ? "" : "\"", + filename.contents()); + last_filename = fn; location_force_filename = 0; } _______________________________________________ groff-commit mailing list groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit