gbranden pushed a commit to branch master
in repository groff.

commit b6bb2641f1a17f02b78eacec7ca381688c5acca5
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
AuthorDate: Sun Feb 23 20:28:46 2025 -0600

    [eqn,pic,preconv,refer,soelim,tbl]: Adapt lf reqs.
    
    Use `lf` requests 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 `lf` request, in case the name starts with a
      space or double quote.
---
 ChangeLog                       | 15 +++++++++++++++
 src/preproc/eqn/main.cpp        |  4 ++--
 src/preproc/pic/troff.cpp       |  4 ++--
 src/preproc/preconv/preconv.cpp |  2 +-
 src/preproc/refer/refer.cpp     |  6 +++---
 src/preproc/soelim/soelim.cpp   |  5 +++--
 src/preproc/tbl/main.cpp        |  2 +-
 src/preproc/tbl/table.cpp       |  4 ++--
 8 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e6f81b1a0..cffd7a755 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2025-02-23  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       [eqn,pic,preconv,refer,soelim,tbl]: Use `lf` requests 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 `lf` request, in case the name
+       starts with a space or double quote.
+
 2025-02-23  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        [troff]: Treat `lf`'s second argument, if present, like string
diff --git a/src/preproc/eqn/main.cpp b/src/preproc/eqn/main.cpp
index a6e0fa8d2..9e78c85c7 100644
--- a/src/preproc/eqn/main.cpp
+++ b/src/preproc/eqn/main.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2025 Free Software Foundation, Inc.
      Written by James Clark (j...@jclark.com)
 
 This file is part of groff.
@@ -105,7 +105,7 @@ void do_file(FILE *fp, const char *filename)
   normalize_for_lf(fn);
   current_filename = fn.contents();
   if (output_format == troff)
-    printf(".lf 1 %s\n", current_filename);
+    printf(".lf 1 \"%s\n", current_filename);
   current_lineno = 1;
   while (read_line(fp, &linebuf)) {
     if (linebuf.length() >= 4
diff --git a/src/preproc/pic/troff.cpp b/src/preproc/pic/troff.cpp
index aa5e00250..2a416780e 100644
--- a/src/preproc/pic/troff.cpp
+++ b/src/preproc/pic/troff.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2025 Free Software Foundation, Inc.
      Written by James Clark (j...@jclark.com)
 
 This file is part of groff.
@@ -600,7 +600,7 @@ 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\n", n, s);
   else
     printf(".lf %d\n", n);
 }
diff --git a/src/preproc/preconv/preconv.cpp b/src/preproc/preconv/preconv.cpp
index a5bf6905d..ca9d43983 100644
--- a/src/preproc/preconv/preconv.cpp
+++ b/src/preproc/preconv/preconv.cpp
@@ -1197,7 +1197,7 @@ do_file(const char *filename)
     string fn(filename);
     fn += '\0';
     normalize_for_lf(fn);
-    printf(".lf 1 %s\n", fn.contents());
+    printf(".lf 1 \"%s\n", 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 5fff37ce6..38a74d61a 100644
--- a/src/preproc/refer/refer.cpp
+++ b/src/preproc/refer/refer.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2025 Free Software Foundation, Inc.
      Written by James Clark (j...@jclark.com)
 
 This file is part of groff.
@@ -474,7 +474,7 @@ static void do_file(const char *filename)
   fn += '\0';
   normalize_for_lf(fn);
   current_filename = fn.contents();
-  fprintf(outfp, ".lf 1 %s\n", current_filename);
+  fprintf(outfp, ".lf 1 \"%s\n", current_filename);
   current_lineno = 1;
   string line;
   for (;;) {
@@ -690,7 +690,7 @@ 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\n", current_lineno, current_filename);
     need_syncing = 0;
   }
 }
diff --git a/src/preproc/soelim/soelim.cpp b/src/preproc/soelim/soelim.cpp
index 40848b2d4..4364d335d 100644
--- a/src/preproc/soelim/soelim.cpp
+++ b/src/preproc/soelim/soelim.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2025 Free Software Foundation, Inc.
      Written by James Clark (j...@jclark.com)
 
 This file is part of groff.
@@ -130,8 +130,9 @@ void set_location()
 {
   if (!want_raw_output) {
     if (!want_tex_output)
-      printf(".lf %d %s\n", current_lineno, current_filename);
+      printf(".lf %d \"%s\n", current_lineno, 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 f8b95749d..17d4fca0b 100644
--- a/src/preproc/tbl/main.cpp
+++ b/src/preproc/tbl/main.cpp
@@ -1724,7 +1724,7 @@ int main(int argc, char **argv)
          fn += '\0';
          normalize_for_lf(fn);
          current_filename = fn.contents();
-         printf(".lf 1 %s\n", current_filename);
+         printf(".lf 1 \"%s\n", current_filename);
          process_input_file(fp);
        }
       }
diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index 16a69abca..fa12d1af2 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2025 Free Software Foundation, Inc.
      Written by James Clark (j...@jclark.com)
 
 This file is part of groff.
@@ -3208,7 +3208,7 @@ 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 \"%2\n", as_string(ln), 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

Reply via email to