gbranden pushed a commit to branch master
in repository groff.

commit 8f8c710fb575a63e4b94fd702bc647d7f1ccb183
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Nov 16 10:49:26 2026 -0600

    src/preproc/pic/lex.cpp: Slightly refactor.
    
    * src/preproc/pic/lex.cpp: Boolify argument to `get_token()` and rename
      it from `lookup_flag` to `want_macro_expansion`, to make its purpose
      clearer.
    
      (get_token): Use new parameter name.
    
      (do_define)
      (do_undef)
      (do_lookahead)
      (yylex): Update call sites to use Boolean, not integer, literals.
    
    Continues the long process of fixing Savannah #66672.
---
 ChangeLog               | 14 ++++++++++++++
 src/preproc/pic/lex.cpp | 38 +++++++++++++++++++-------------------
 2 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9534181a9..2a94ac5e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2026-11-16  G. Branden Robinson <[email protected]>
+
+       * src/preproc/pic/lex.cpp: Slightly refactor.  Boolify argument
+       to `get_token()` and rename it from `lookup_flag` to
+       `want_macro_expansion`, to make its purpose clearer.
+       (get_token): Use new parameter name.
+       (do_define)
+       (do_undef)
+       (do_lookahead)
+       (yylex): Update call sites to use Boolean, not integer,
+       literals.
+
+       Continues the long process of fixing Savannah #66672.
+
 2026-11-16  G. Branden Robinson <[email protected]>
 
        * src/preproc/pic/lex.cpp: Trivially refactor.  Rename
diff --git a/src/preproc/pic/lex.cpp b/src/preproc/pic/lex.cpp
index 45511b6a6..f3e0f6583 100644
--- a/src/preproc/pic/lex.cpp
+++ b/src/preproc/pic/lex.cpp
@@ -949,7 +949,7 @@ static int get_token_after_dot(int c)
 
 // Return encoded token value, which is selected from a bunch of
 // preprocessor-defined integer literals, not a proper type.
-static int get_token(int lookup_flag /* TODO: boolify */)
+static int get_token(bool want_macro_expansion)
 {
   context_buffer.clear();
   for (;;) {
@@ -1318,7 +1318,7 @@ static int get_token(int lookup_flag /* TODO: boolify */)
          return tok;
        }
        char *def = 0;
-       if (lookup_flag) {
+       if (want_macro_expansion) {
          token_buffer += '\0';
          def = macro_table.lookup(token_buffer.contents());
          token_buffer.set_length(token_buffer.length() - 1);
@@ -1420,7 +1420,7 @@ static int get_delimited()
 
 static void do_define()
 {
-  int t = get_token(0);                // do not expand what we are defining
+  int t = get_token(false /* want_macro_expansion */);
   if (t != VARIABLE && t != LABEL) {
     lex_error("can only define variable or placename");
     return;
@@ -1436,7 +1436,7 @@ static void do_define()
 
 static void do_undef()
 {
-  int t = get_token(0);                // do not expand what we are undefining
+  int t = get_token(false /* want_macro_expansion */);
   if (t != VARIABLE && t != LABEL) {
     lex_error("can only define variable or placename");
     return;
@@ -1861,7 +1861,7 @@ void do_lookahead()
 {
   if (lookahead_token == -1) {
     old_context_buffer = context_buffer;
-    lookahead_token = get_token(1);
+    lookahead_token = get_token(true /* want_macro_expansion */);
   }
 }
 
@@ -1894,7 +1894,7 @@ int yylex()
       lookahead_token = -1;
     }
     else
-      t = get_token(1);
+      t = get_token(true /* want_macro_expansion */);
     switch (t) {
     case '\n':
       return ';';
@@ -1930,7 +1930,7 @@ int yylex()
     case LEFT:
       // change LEFT to LEFT_CORNER when followed by OF
       old_context_buffer = context_buffer;
-      lookahead_token = get_token(1);
+      lookahead_token = get_token(true /* want_macro_expansion */);
       if (lookahead_token == OF)
        return LEFT_CORNER;
       else
@@ -1938,7 +1938,7 @@ int yylex()
     case RIGHT:
       // change RIGHT to RIGHT_CORNER when followed by OF
       old_context_buffer = context_buffer;
-      lookahead_token = get_token(1);
+      lookahead_token = get_token(true /* want_macro_expansion */);
       if (lookahead_token == OF)
        return RIGHT_CORNER;
       else
@@ -1946,7 +1946,7 @@ int yylex()
     case UPPER:
       // recognise UPPER only before LEFT or RIGHT
       old_context_buffer = context_buffer;
-      lookahead_token = get_token(1);
+      lookahead_token = get_token(true /* want_macro_expansion */);
       if (lookahead_token != LEFT && lookahead_token != RIGHT) {
        yylval.str = strsave("upper");
        return VARIABLE;
@@ -1956,7 +1956,7 @@ int yylex()
     case LOWER:
       // recognise LOWER only before LEFT or RIGHT
       old_context_buffer = context_buffer;
-      lookahead_token = get_token(1);
+      lookahead_token = get_token(true /* want_macro_expansion */);
       if (lookahead_token != LEFT && lookahead_token != RIGHT) {
        yylval.str = strsave("lower");
        return VARIABLE;
@@ -1966,7 +1966,7 @@ int yylex()
     case NORTH:
       // recognise NORTH only before OF
       old_context_buffer = context_buffer;
-      lookahead_token = get_token(1);
+      lookahead_token = get_token(true /* want_macro_expansion */);
       if (lookahead_token != OF) {
        yylval.str = strsave("north");
        return VARIABLE;
@@ -1976,7 +1976,7 @@ int yylex()
     case SOUTH:
       // recognise SOUTH only before OF
       old_context_buffer = context_buffer;
-      lookahead_token = get_token(1);
+      lookahead_token = get_token(true /* want_macro_expansion */);
       if (lookahead_token != OF) {
        yylval.str = strsave("south");
        return VARIABLE;
@@ -1986,7 +1986,7 @@ int yylex()
     case EAST:
       // recognise EAST only before OF
       old_context_buffer = context_buffer;
-      lookahead_token = get_token(1);
+      lookahead_token = get_token(true /* want_macro_expansion */);
       if (lookahead_token != OF) {
        yylval.str = strsave("east");
        return VARIABLE;
@@ -1996,7 +1996,7 @@ int yylex()
     case WEST:
       // recognise WEST only before OF
       old_context_buffer = context_buffer;
-      lookahead_token = get_token(1);
+      lookahead_token = get_token(true /* want_macro_expansion */);
       if (lookahead_token != OF) {
        yylval.str = strsave("west");
        return VARIABLE;
@@ -2006,7 +2006,7 @@ int yylex()
     case TOP:
       // recognise TOP only before OF
       old_context_buffer = context_buffer;
-      lookahead_token = get_token(1);
+      lookahead_token = get_token(true /* want_macro_expansion */);
       if (lookahead_token != OF) {
        yylval.str = strsave("top");
        return VARIABLE;
@@ -2016,7 +2016,7 @@ int yylex()
     case BOTTOM:
       // recognise BOTTOM only before OF
       old_context_buffer = context_buffer;
-      lookahead_token = get_token(1);
+      lookahead_token = get_token(true /* want_macro_expansion */);
       if (lookahead_token != OF) {
        yylval.str = strsave("bottom");
        return VARIABLE;
@@ -2026,7 +2026,7 @@ int yylex()
     case CENTER:
       // recognise CENTER only before OF
       old_context_buffer = context_buffer;
-      lookahead_token = get_token(1);
+      lookahead_token = get_token(true /* want_macro_expansion */);
       if (lookahead_token != OF) {
        yylval.str = strsave("center");
        return VARIABLE;
@@ -2036,7 +2036,7 @@ int yylex()
     case START:
       // recognise START only before OF
       old_context_buffer = context_buffer;
-      lookahead_token = get_token(1);
+      lookahead_token = get_token(true /* want_macro_expansion */);
       if (lookahead_token != OF) {
        yylval.str = strsave("start");
        return VARIABLE;
@@ -2046,7 +2046,7 @@ int yylex()
     case END:
       // recognise END only before OF
       old_context_buffer = context_buffer;
-      lookahead_token = get_token(1);
+      lookahead_token = get_token(true /* want_macro_expansion */);
       if (lookahead_token != OF) {
        yylval.str = strsave("end");
        return VARIABLE;

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to