Update of bug #67698 (group groff):

                 Summary: [troff] withdraw "right-brace" warning category =>
[troff] withdraw "number" and "right-brace" warning categories

    _______________________________________________________

Follow-up Comment #1:

Actually we can toss the "number" category as well.  It had only one call
site, and that case is better handled as an error because with the following
code consolidation commit (in my working copy), this is a situation where GNU
_troff_'s grammar slightly differs from AT&T's, and therefore seems worthy of
the stronger category.


commit 64711b3a875ce9ea3a023401d641b9922de61cc8 (HEAD -> master)
Author: G. Branden Robinson <[email protected]>
Date:   Fri Nov 14 11:44:18 2025 -0600

    [troff]: Make numeric expression parser stricter.
    
    * src/roff/troff/number.cpp: Refactor numeric expression parser to
      simplify and heighten severity of diagnostics.  This isn't a behavior
      change; character sequences that were invalid as numeric expressions
      were ignored before and remain so.  But since we're aborting
      interpretation of an argument to a request or escape sequence, where
      in at least one case AT&T troff did not--it would read through
      spurious tab characters to reach a valid numeric expression
      afterward--an error seems more appropriate.
    
      (is_valid_expression_start): Drop special handling of tab and right-
      brace escape sequences.  These get handled anyway when the term at the
      start of the expression gets interpreted...
    
      (is_valid_term): ...thus.  Raise diagnostic severity from warning (in
      "number" category) to error.
    
    Illustration:
    
    Before
    ------
    $ printf '.nr a A2\n.tm a=\\na\n' | ~/groff-1.23.0/bin/groff -z -ww
    troff:<standard input>:1: warning: expected numeric expression, got 'A'
    a=troff:<standard input>:2: warning: register 'a' not defined
    0
    $ printf '.nr a \t2\n.tm a=\\na\n' | ~/groff-1.23.0/bin/groff -z -ww
    troff:<standard input>:1: warning: expected numeric expression, got a tab
character
    a=troff:<standard input>:2: warning: register 'a' not defined
    0
    $ printf '.nr a \\}2\n.tm a=\\na\n' | ~/groff-1.23.0/bin/groff -z -ww
    troff:<standard input>:1: warning: expected numeric expression, got
rightbrace escape sequence
    a=troff:<standard input>:2: warning: register 'a' not defined
    0
    
    After
    -----
    $ printf '.nr a A2\n.tm a=\\na\n' | ./build/test-groff -z -ww
    troff:<standard input>:1: error: ignoring invalid numeric expression
starting with character 'A'
    a=troff:<standard input>:2: warning: register 'a' not defined
    0
    $ printf '.nr a \t2\n.tm a=\\na\n' | ./build/test-groff -z -ww
    troff:<standard input>:1: error: ignoring invalid numeric expression
starting with a tab character
    a=troff:<standard input>:2: warning: register 'a' not defined
    0
    $ printf '.nr a \\}2\n.tm a=\\na\n' | ./build/test-groff -z -ww
    troff:<standard input>:1: error: ignoring invalid numeric expression
starting with an escaped '}'
    a=troff:<standard input>:2: warning: register 'a' not defined
    0
    
    DWB 3.3
    -------
    $ printf '.nr a A2\n.tm a=\\na\n' | DWBHOME=~/dwb ~/dwb/bin/nroff
>/dev/null
    a=0
    $ printf '.nr a \t2\n.tm a=\\na\n' | DWBHOME=~/dwb ~/dwb/bin/nroff
>/dev/null
    a=2
    $ printf '.nr a \\}2\n.tm a=\\na\n' | DWBHOME=~/dwb ~/dwb/bin/nroff
>/dev/null
    a=0

...
diff --git a/src/roff/troff/number.cpp b/src/roff/troff/number.cpp
index f17629d23..78b5de285 100644
--- a/src/roff/troff/number.cpp
+++ b/src/roff/troff/number.cpp
@@ -245,16 +245,6 @@ static bool is_valid_expression_start()
     warning(WARN_MISSING, "numeric expression missing");
     return false;
   }
-  if (tok.is_tab()) {
-    warning(WARN_TAB, "expected numeric expression, got %1",
-           tok.description());
-    return false;
-  }
-  if (tok.is_right_brace()) {
-    warning(WARN_RIGHT_BRACE, "expected numeric expression, got right"
-           " brace escape sequence");
-    return false;
-  }
   return true;
 }
 
@@ -512,8 +502,8 @@ static bool is_valid_term(units *u, int scaling_unit,
     *u = 0;
     return !is_mandatory;
   default:
-    warning(WARN_NUMBER, "expected numeric expression, got %1",
-           tok.description());
+    error("ignoring invalid numeric expression starting with %1",
+         tok.description());
     return false;
   }
   int divisor = 1;




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?67698>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to