groff-commit
[Top][All Lists]
Advanced

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

[groff] 02/03: Revert "src/roff/troff/input.cpp: Report bad digits."


From: G. Branden Robinson
Subject: [groff] 02/03: Revert "src/roff/troff/input.cpp: Report bad digits."
Date: Tue, 31 Mar 2020 23:30:23 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit f92683fea0f43a5f9cde806b67a2f0fcb731f07c
Author: G. Branden Robinson <address@hidden>
AuthorDate: Wed Apr 1 14:15:52 2020 +1100

    Revert "src/roff/troff/input.cpp: Report bad digits."
    
    This reverts commit f23fb69b7b1c6d30c2a3ca12ea871f42e4e3a61a.
---
 ChangeLog                | 11 ----------
 src/roff/troff/input.cpp | 56 ++++++++++++++++--------------------------------
 2 files changed, 19 insertions(+), 48 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e7f9743..d965739 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,17 +13,6 @@
        * src/roff/groff/tests/string_case_xform_errors.sh: Update
        diagnostic message expectation.
 
-2020-03-31  G. Branden Robinson <address@hidden>
-
-       * src/roff/troff/input.cpp (read_size): Improve bad digit
-       diagnostic by reporting what the bad digit actually is;
-       literally if it is a printable character, and by numerical code
-       otherwise.  Also replace repeated two-line idiom with no
-       stream-validity error-checking with call to...
-       (read_size_next_byte): Add helper function to perform EOF and
-       newline checking every time read_size() takes a byte from the
-       input stream; issue a diagnostic if either is found.
-
 2020-02-10  G. Branden Robinson <address@hidden>
 
        * doc/groff.texi:
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index ba3842b..bc34031 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5027,60 +5027,45 @@ static int get_line_arg(units *n, unsigned char si, 
charinfo **cp)
   return 0;
 }
 
-// In groff prior to 1.22.5, read_size() (below) had an idiom of doing:
-//   tok.next();
-//   c = tok.ch();
-// ...without checking the token for EOF or newline.  Let's do better.
-static int read_size_next_byte(void)
-{
-  int saved_lineno;
-  const char *saved_filename;
-  // Reading the next token could discard the filename (EOF) or change
-  // the line number (newline); save them.
-  if (!input_stack::get_location(0, &saved_filename, &saved_lineno))
-    // This should never happen.
-    fatal("I don't know where I am!");
-  tok.next();
-  int eof = tok.eof();
-  if (eof || tok.newline())
-      error_with_file_and_line(saved_filename, saved_lineno,
-                               "expected digit in point size; got %1",
-                               eof ? "end of file" : "newline");
-  return tok.ch();
-}
-
 static int read_size(int *x)
 {
-  int c = read_size_next_byte();
+  tok.next();
+  int c = tok.ch();
   int inc = 0;
   if (c == '-') {
     inc = -1;
-    c = read_size_next_byte();
+    tok.next();
+    c = tok.ch();
   }
   else if (c == '+') {
     inc = 1;
-    c = read_size_next_byte();
+    tok.next();
+    c = tok.ch();
   }
   int val = 0;         // pacify compiler
   int bad = 0;
   if (c == '(') {
-    c = read_size_next_byte();
+    tok.next();
+    c = tok.ch();
     if (!inc) {
       // allow an increment either before or after the left parenthesis
       if (c == '-') {
        inc = -1;
-       c = read_size_next_byte();
+       tok.next();
+       c = tok.ch();
       }
       else if (c == '+') {
        inc = 1;
-       c = read_size_next_byte();
+       tok.next();
+       c = tok.ch();
       }
     }
     if (!csdigit(c))
       bad = 1;
     else {
       val = c - '0';
-      c = read_size_next_byte();
+      tok.next();
+      c = tok.ch();
       if (!csdigit(c))
        bad = 1;
       else {
@@ -5092,7 +5077,8 @@ static int read_size(int *x)
   else if (csdigit(c)) {
     val = c - '0';
     if (!inc && c != '0' && c < '4') {
-      c = read_size_next_byte();
+      tok.next();
+      c = tok.ch();
       if (!csdigit(c))
        bad = 1;
       else
@@ -5104,7 +5090,8 @@ static int read_size(int *x)
     return 0;
   else {
     token start(tok);
-    c = read_size_next_byte();
+    tok.next();
+    c = tok.ch();
     if (!inc && (c == '-' || c == '+')) {
       inc = c == '+' ? 1 : -1;
       tok.next();
@@ -5146,12 +5133,7 @@ static int read_size(int *x)
     return 1;
   }
   else {
-    // read_size_next_byte() already threw an error on EOF or newline.
-    if (!tok.eof() && !tok.newline())
-      if (csprint(c))
-        error("bad digit '%1' in point size", (char) c);
-      else
-        error("bad digit (character code %1) in point size", c);
+    error("bad digit in point size");
     return 0;
   }
 }



reply via email to

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