groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 10/35: [troff]: `cf`, `trf` now accept spacey file names.


From: G. Branden Robinson
Subject: [groff] 10/35: [troff]: `cf`, `trf` now accept spacey file names.
Date: Tue, 10 Dec 2024 16:35:32 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit f0871659336bece1831c0de3b099d67f70e81bf5
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Dec 7 09:51:55 2024 -0600

    [troff]: `cf`, `trf` now accept spacey file names.
    
    The `cf` and `trf` requests now accept leading and embedded spaces in
    their "file" arguments, just like `so`.
    
    * src/roff/troff/input.cpp (copy_file, transparent_file): Gather the
      argument with `read_string()` (which reads a potentially spaceful
      argument including a discardable leading double quote), not
      `get_long_name()` (which reads a GNU troff identifier).  Call
      `tok.next()` afterwards.
    
    * doc/groff.texi.in (I/O):
    * man/groff_diff.7.man (New requests, Altered requests): Document it.
    
    * NEWS: Update existing items.
    
    A more general revision to groff(7) will follow.
---
 ChangeLog                | 17 +++++++++++++++++
 NEWS                     |  9 +++++----
 doc/groff.texi.in        |  4 ++--
 man/groff_diff.7.man     | 15 ++++++++++++++-
 src/roff/troff/input.cpp | 25 +++++++++++--------------
 5 files changed, 49 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5436b213a..1571008b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2024-12-07  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [troff]: The `cf` and `trf` requests now accept leading and
+       embedded spaces in their "file" arguments, just like `so`.
+
+       * src/roff/troff/input.cpp (copy_file, transparent_file): Gather
+       the argument with `read_string()` (which reads a potentially
+       spaceful argument including a discardable leading double quote),
+       not `get_long_name()` (which reads a GNU troff identifier).
+       Call `tok.next()` afterwards.
+
+       * doc/groff.texi.in (I/O):
+       * man/groff.7.man (Request short reference):
+       * man/groff_diff.7.man (New requests): Document it.
+
+       * NEWS: Update existing items.
+
 2024-12-07  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [nroff]: Rename test script to better fit recent conventions.
diff --git a/NEWS b/NEWS
index 055daf6f5..9004c1cec 100644
--- a/NEWS
+++ b/NEWS
@@ -57,11 +57,12 @@ troff
    warning diagnostic in the "range" category.
 
 *  GNU troff now strips a leading neutral double quote from the argument
-   to the `mso`, `msoquiet`, `pi`, `pso`, `so`, `soquiet`, and `sy`
-   requests, allowing it to contain embedded leading spaces.
+   to the `cf`, `mso`, `msoquiet`, `pi`, `pso`, `so`, `soquiet`, `sy`,
+   and `trf` requests, allowing it to contain embedded leading spaces.
 
-*  GNU troff now accepts space characters in the argument to the `mso`,
-   `msoquiet`, `so`, and `soquiet` requests.  See "soelim" below.
+*  GNU troff now accepts space characters in the argument to the `cf`,
+   `mso`, `msoquiet`, `so`, `soquiet`, `trf` requests.  See "soelim"
+   below.
 
 *  The "el" warning category has been withdrawn.  If enabled (which it
    was not by default), the formatter would emit a diagnostic if it
diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index 785edcc48..17b7c8196 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -16328,8 +16328,8 @@ the same directories as macro files for the @option{-m} 
command-line
 option.
 @endDefreq
 
-@DefreqList {trf, file}
-@DefreqListEndx {cf, file}
+@DefreqList {trf, [@code{"}]@Var{file}}
+@DefreqListEndx {cf, [@code{"}]@Var{file}}
 @cindex transparent output (@code{cf}, @code{trf})
 @cindex output, transparent (@code{cf}, @code{trf})
 @cindex @code{cf} request, and copy mode
diff --git a/man/groff_diff.7.man b/man/groff_diff.7.man
index f893dc013..211eb2ad1 100644
--- a/man/groff_diff.7.man
+++ b/man/groff_diff.7.man
@@ -4061,7 +4061,8 @@ are read in copy mode.
 .\" ====================================================================
 .
 .TP
-.BI .cf\~ file
+.BR .cf\~ [ \[dq] ]\c
+.I file
 In a diversion,
 embed an object which,
 when interpolated,
@@ -4078,6 +4079,18 @@ is being written to;
 this behavior is so anomalous that it must be considered a bug.
 .
 .
+.IP
+GNU
+.I troff \" GNU
+strips a leading neutral double quote from the argument,
+allowing it to contain embedded leading spaces.
+.
+Further,
+spaces in
+.I file
+are accepted as part of the file name.
+.
+.
 .br
 .ne 6v
 .TP
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index d1cff0340..e0066cdfa 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8535,7 +8535,7 @@ void system_request()
 
 void copy_file()
 {
-  if (!has_arg()) {
+  if (!has_arg(true /* peek */)) {
     warning(WARN_MISSING, "file throughput request expects a file name"
            " as argument");
     skip_line();
@@ -8545,13 +8545,12 @@ void copy_file()
     handle_initial_request(COPY_FILE_REQUEST);
     return;
   }
-  symbol filename = get_long_name(true /* required */);
-  while (!tok.is_newline() && !tok.is_eof())
-    tok.next();
+  char *filename = read_string();
+  tok.next();
   if (want_break)
     curenv->do_break();
-  if (!filename.is_null())
-    curdiv->copy_file(filename.contents());
+  if (filename != 0 /* nullptr */)
+    curdiv->copy_file(filename);
   tok.next();
 }
 
@@ -8579,7 +8578,7 @@ void vjustify()
 
 void transparent_file()
 {
-  if (!has_arg()) {
+  if (!has_arg(true /* peek */)) {
     warning(WARN_MISSING, "transparent file throughput request expects"
            " a file name as argument");
     skip_line();
@@ -8589,17 +8588,15 @@ void transparent_file()
     handle_initial_request(TRANSPARENT_FILE_REQUEST);
     return;
   }
-  symbol filename = get_long_name(true /* required */);
-  while (!tok.is_newline() && !tok.is_eof())
-    tok.next();
+  char *filename = read_string();
+  tok.next();
   if (want_break)
     curenv->do_break();
-  if (!filename.is_null()) {
+  if (filename != 0 /* nullptr */) {
     errno = 0;
-    FILE *fp = include_search_path.open_file_cautious(filename.contents());
+    FILE *fp = include_search_path.open_file_cautious(filename);
     if (0 /* nullptr */ == fp)
-      error("cannot open '%1': %2", filename.contents(),
-           strerror(errno));
+      error("cannot open '%1': %2", filename, strerror(errno));
     else {
       int bol = 1;
       for (;;) {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]