[PATCH 3/9] style: introduce & use STRING_1GROW

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>
* src/flex-scanner.h (STRING_1GROW): New.
* src/scan-gram.l, src/scan-skel.l: Use it.
---
 src/flex-scanner.h |  3 +++
 src/scan-gram.l    | 26 +++++++++++++-------------
 src/scan-skel.l    |  6 +++---
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/src/flex-scanner.h b/src/flex-scanner.h
index f0f3ae17..56ca7ce3 100644
--- a/src/flex-scanner.h
+++ b/src/flex-scanner.h
@@ -109,6 +109,9 @@ static struct obstack obstack_for_string;
 # define STRING_FINISH()                                \
   (last_string = obstack_finish0 (&obstack_for_string))
 
+# define STRING_1GROW(Char)                     \
+  obstack_1grow (&obstack_for_string, Char)
+
 # define STRING_FREE()                                  \
   obstack_free (&obstack_for_string, last_string)
 
diff --git a/src/scan-gram.l b/src/scan-gram.l
index 655eee70..3b03923a 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -89,14 +89,14 @@ static boundary scanner_cursor;
     verify (UCHAR_MAX < ULONG_MAX);                             \
     long c = Char;                                              \
     if (0 < c && c <= UCHAR_MAX)                                \
-      obstack_1grow (&obstack_for_string, c);                   \
+      STRING_1GROW (c);                                         \
     else                                                        \
       {                                                         \
         complain (loc, complaint,                               \
                   _("invalid number after \\-escape: %s"),      \
                   yytext + 1);                                  \
         /* Avoid additional errors about empty char literal. */ \
-        obstack_1grow (&obstack_for_string, '?');               \
+        STRING_1GROW ('?');                                     \
       }                                                         \
   } while (0)
 
@@ -661,16 +661,16 @@ eqopt    ({sp}=)?
     STRING_GROW_ESCAPE (strtol (yytext + 2, NULL, 16));
   }
 
-  \\a   obstack_1grow (&obstack_for_string, '\a');
-  \\b   obstack_1grow (&obstack_for_string, '\b');
-  \\f   obstack_1grow (&obstack_for_string, '\f');
-  \\n   obstack_1grow (&obstack_for_string, '\n');
-  \\r   obstack_1grow (&obstack_for_string, '\r');
-  \\t   obstack_1grow (&obstack_for_string, '\t');
-  \\v   obstack_1grow (&obstack_for_string, '\v');
+  \\a   STRING_1GROW ('\a');
+  \\b   STRING_1GROW ('\b');
+  \\f   STRING_1GROW ('\f');
+  \\n   STRING_1GROW ('\n');
+  \\r   STRING_1GROW ('\r');
+  \\t   STRING_1GROW ('\t');
+  \\v   STRING_1GROW ('\v');
 
   /* \\[\"\'?\\] would be shorter, but it confuses xgettext.  */
-  \\("\""|"'"|"?"|"\\")  obstack_1grow (&obstack_for_string, yytext[1]);
+  \\("\""|"'"|"?"|"\\")  STRING_1GROW (yytext[1]);
 
   \\(u|U[0-9abcdefABCDEF]{4})[0-9abcdefABCDEF]{4} {
     STRING_GROW_ESCAPE (convert_ucn_to_byte (yytext));
@@ -685,7 +685,7 @@ eqopt    ({sp}=)?
       p = quotearg_style_mem (escape_quoting_style, p, 1);
     complain (loc, complaint, _("invalid character after \\-escape: %s"),
               p);
-    obstack_1grow (&obstack_for_string, '?');
+    STRING_1GROW ('?');
   }
 }
 
@@ -766,7 +766,7 @@ eqopt    ({sp}=)?
 <SC_BRACED_CODE>
 {
   "}" {
-    obstack_1grow (&obstack_for_string, '}');
+    STRING_1GROW ('}');
 
     --nesting;
     if (nesting < 0)
@@ -791,7 +791,7 @@ eqopt    ({sp}=)?
         RETURN_VALUE (BRACED_PREDICATE, last_string);
       }
     else
-      obstack_1grow (&obstack_for_string, '}');
+      STRING_1GROW ('}');
   }
 }
 
diff --git a/src/scan-skel.l b/src/scan-skel.l
index a5771639..4c524584 100644
--- a/src/scan-skel.l
+++ b/src/scan-skel.l
@@ -102,9 +102,9 @@ static void output_mapped_file (char const *name);
 {
   [^@]+  STRING_GROW ();
 
-  "@@"   obstack_1grow (&obstack_for_string, '@');
-  "@{"   obstack_1grow (&obstack_for_string, '[');
-  "@}"   obstack_1grow (&obstack_for_string, ']');
+  "@@"   STRING_1GROW ('@');
+  "@{"   STRING_1GROW ('[');
+  "@}"   STRING_1GROW (']');
   "@'"   continue; /* For starting an argument that begins with whitespace. */
   @\n    continue;
 
-- 
2.27.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.