groff-commit
[Top][All Lists]
Advanced

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

[groff] 12/26: [troff]: Recognize " at start of `pi`, `sy` args.


From: G. Branden Robinson
Subject: [groff] 12/26: [troff]: Recognize " at start of `pi`, `sy` args.
Date: Thu, 14 Nov 2024 11:54:09 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 88f003641ff7fa290dd773490adad5740913e76c
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Nov 12 08:29:14 2024 -0600

    [troff]: Recognize " at start of `pi`, `sy` args.
    
    * src/roff/troff/input.cpp (read_string): Recognize a leading double
      quote in the argument and handle it like other "contents"-reading
      requests do; the best known of these is the string-definition request,
      `ds`, which however uses its own logic.  This change affects only the
      `pi` and `sy` requests.
    
    * doc/groff.texi.in (I/O) <pi, sy>:
      (Other Differences):
    * man/groff.7.man (Request short reference) <pi, sy>:
    * man/groff_diff.7.man (Other differences): Document it.
    
    * NEWS: Add item.
---
 ChangeLog                |  8 ++++++++
 NEWS                     |  4 ++++
 doc/groff.texi.in        | 16 ++++++++++++++--
 man/groff.7.man          | 10 ++++++++++
 man/groff_diff.7.man     | 11 +++++++++++
 src/roff/troff/input.cpp | 11 ++++++++---
 6 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 37da1a70f..02336f0ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-11-12  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/roff/troff/input.cpp (read_string): Recognize a leading
+       double quote in the argument and handle it like other
+       "contents"-reading requests do; the best known of these is the
+       string-definition request, `ds`, which however uses its own
+       logic.  This change affects only the `pi` and `sy` requests.
+
 2024-11-12  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/troff/input.cpp: Trivially refactor.
diff --git a/NEWS b/NEWS
index cbc7cfa25..a40ed64fe 100644
--- a/NEWS
+++ b/NEWS
@@ -56,6 +56,10 @@ troff
    and abort evaluation of the expression, the formatter now emits a
    warning diagnostic in the "range" category.
 
+*  GNU troff now strips a leading neutral double quote from the argument
+   to the `pi` and `sy` requests, allowing it to contain embedded
+   leading spaces.
+
 *  The "el" warning category has been withdrawn.  If enabled (which it
    was not by default), the formatter would emit a diagnostic if it
    inferred an imbalance between `ie` and `el` requests.  Unfortunately
diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index 770e13c71..41f5eaa9e 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -16430,7 +16430,7 @@ Dear Mr. Adollar,
 .ex
 @endExample
 
-@Defreq {pi, contents}
+@Defreq {pi, [@code{"}]@Var{contents}}
 Use GNU @command{troff}'s device-independent output as the input to the
 commands specified in @var{pipe} and emit their output to the standard
 output stream instead of GNU @command{troff}'s usual output.
@@ -16445,6 +16445,9 @@ The formatter reads the remainder of the input line 
into @var{contents}
 and passes it to @cite{popen@r{(3)}}.  Output produced by the
 command(s) is not captured by GNU @command{troff}.
 
+GNU @command{troff} strips a leading neutral double quote from the
+argument, allowing embedded leading spaces in @var{contents}.
+
 Multiple @code{pi} requests construct a multi-stage pipeline in the same
 order as the formatter encounters the requests.
 
@@ -16473,13 +16476,16 @@ is the same as @w{@samp{.pi foo | bar}}.
 
 @cindex system commands, running
 @cindex running system commands
-@DefreqList {sy, contents}
+@DefreqList {sy, [@code{"}]@Var{contents}}
 @DefregListEndx {systat}
 Execute the specified shell command(s).  The formatter reads the
 remainder of the input line into @var{contents} and passes it to
 @cite{system@r{(3)}}.  Output produced by the command(s) is not captured
 by GNU @command{troff}.
 
+GNU @command{troff} strips a leading neutral double quote from the
+argument, allowing embedded leading spaces in @var{contents}.
+
 @cindex safer mode
 @cindex mode, safer
 @cindex unsafe mode
@@ -17948,6 +17954,12 @@ Unlike @acronym{AT&T} @code{troff}, GNU @code{troff} 
does not ignore the
 values of minimum inter-word and additional inter-sentence space are
 each rounded down to the nearest multiple of@tie{}12.
 
+@cindex @code{pi} request, incompatibilities with @acronym{AT&T} @code{troff}
+@cindex @code{sy} request, incompatibilities with @acronym{AT&T} @code{troff}
+GNU @command{troff} strips a leading neutral double quote from the
+argument to the @code{pi} and @code{sy} requests, allowing it to contain
+embedded leading spaces.
+
 @cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
 @cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
 @cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
diff --git a/man/groff.7.man b/man/groff.7.man
index 39d2fb773..80b921ab1 100644
--- a/man/groff.7.man
+++ b/man/groff.7.man
@@ -4037,6 +4037,11 @@ output through
 by passing it to
 .MR popen 3 .
 .
+A leading neutral double quote is stripped from the argument,
+allowing embedded leading spaces in
+.I contents,
+which is read in copy mode and continues to the end of the input line.
+.
 Multiple
 .B pi
 requests construct a multi-stage pipeline in the same order as the
@@ -4522,6 +4527,11 @@ in the operating environment
 by passing it to
 .MR system 3 .
 .
+A leading neutral double quote is stripped from the argument,
+allowing embedded leading spaces in
+.I contents,
+which is read in copy mode and continues to the end of the input line.
+.
 Unsafe request;
 disabled by default.
 .
diff --git a/man/groff_diff.7.man b/man/groff_diff.7.man
index f0c54c846..2a6049cac 100644
--- a/man/groff_diff.7.man
+++ b/man/groff_diff.7.man
@@ -6049,6 +6049,17 @@ inter-sentence space each to the nearest multiple of\~12.
 .
 .
 .P
+GNU
+.I troff \" GNU
+strips a leading neutral double quote from the argument to the
+.B pi
+and
+.B sy
+requests,
+allowing it to contain embedded leading spaces.
+.
+.
+.P
 In GNU
 .I troff \" GNU
 there is a fundamental difference between (unformatted) characters and
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index c7fc21e44..0c284bf5e 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8409,14 +8409,19 @@ void abort_request()
   cleanup_and_exit(EXIT_FAILURE);
 }
 
+// Consume the rest of the input line in copy mode; if, after spaces,
+// the argument starts with a `"`, discard it, letting any immediately
+// subsequent spaces populate the returned string.
 char *read_string()
 {
   int len = 256;
   char *s = new char[len]; // C++03: new char[len]();
   (void) memset(s, 0, (len * sizeof(char)));
-  int c;
-  while ((c = get_copy(0 /* nullptr */)) == ' ')
-    ;
+  int c = get_copy(0 /* nullptr */);
+  while (c == ' ')
+    c = get_copy(0 /* nullptr */);
+  if (c == '"')
+    c = get_copy(0 /* nullptr */);
   int i = 0;
   while (c != '\n' && c != EOF) {
     if (!is_invalid_input_char(c)) {



reply via email to

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