style: introduce & use STRING_1GROW

* src/flex-scanner.h (STRING_1GROW): New.
* src/scan-gram.l, src/scan-skel.l: Use it.
This commit is contained in:
Akim Demaille
2020-06-13 08:41:47 +02:00
parent e088b4f90f
commit b7fbfd050e
3 changed files with 19 additions and 16 deletions

View File

@@ -109,6 +109,9 @@ static struct obstack obstack_for_string;
# define STRING_FINISH() \ # define STRING_FINISH() \
(last_string = obstack_finish0 (&obstack_for_string)) (last_string = obstack_finish0 (&obstack_for_string))
# define STRING_1GROW(Char) \
obstack_1grow (&obstack_for_string, Char)
# define STRING_FREE() \ # define STRING_FREE() \
obstack_free (&obstack_for_string, last_string) obstack_free (&obstack_for_string, last_string)

View File

@@ -89,14 +89,14 @@ static boundary scanner_cursor;
verify (UCHAR_MAX < ULONG_MAX); \ verify (UCHAR_MAX < ULONG_MAX); \
long c = Char; \ long c = Char; \
if (0 < c && c <= UCHAR_MAX) \ if (0 < c && c <= UCHAR_MAX) \
obstack_1grow (&obstack_for_string, c); \ STRING_1GROW (c); \
else \ else \
{ \ { \
complain (loc, complaint, \ complain (loc, complaint, \
_("invalid number after \\-escape: %s"), \ _("invalid number after \\-escape: %s"), \
yytext + 1); \ yytext + 1); \
/* Avoid additional errors about empty char literal. */ \ /* Avoid additional errors about empty char literal. */ \
obstack_1grow (&obstack_for_string, '?'); \ STRING_1GROW ('?'); \
} \ } \
} while (0) } while (0)
@@ -661,16 +661,16 @@ eqopt ({sp}=)?
STRING_GROW_ESCAPE (strtol (yytext + 2, NULL, 16)); STRING_GROW_ESCAPE (strtol (yytext + 2, NULL, 16));
} }
\\a obstack_1grow (&obstack_for_string, '\a'); \\a STRING_1GROW ('\a');
\\b obstack_1grow (&obstack_for_string, '\b'); \\b STRING_1GROW ('\b');
\\f obstack_1grow (&obstack_for_string, '\f'); \\f STRING_1GROW ('\f');
\\n obstack_1grow (&obstack_for_string, '\n'); \\n STRING_1GROW ('\n');
\\r obstack_1grow (&obstack_for_string, '\r'); \\r STRING_1GROW ('\r');
\\t obstack_1grow (&obstack_for_string, '\t'); \\t STRING_1GROW ('\t');
\\v obstack_1grow (&obstack_for_string, '\v'); \\v STRING_1GROW ('\v');
/* \\[\"\'?\\] would be shorter, but it confuses xgettext. */ /* \\[\"\'?\\] 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} { \\(u|U[0-9abcdefABCDEF]{4})[0-9abcdefABCDEF]{4} {
STRING_GROW_ESCAPE (convert_ucn_to_byte (yytext)); STRING_GROW_ESCAPE (convert_ucn_to_byte (yytext));
@@ -685,7 +685,7 @@ eqopt ({sp}=)?
p = quotearg_style_mem (escape_quoting_style, p, 1); p = quotearg_style_mem (escape_quoting_style, p, 1);
complain (loc, complaint, _("invalid character after \\-escape: %s"), complain (loc, complaint, _("invalid character after \\-escape: %s"),
p); p);
obstack_1grow (&obstack_for_string, '?'); STRING_1GROW ('?');
} }
} }
@@ -766,7 +766,7 @@ eqopt ({sp}=)?
<SC_BRACED_CODE> <SC_BRACED_CODE>
{ {
"}" { "}" {
obstack_1grow (&obstack_for_string, '}'); STRING_1GROW ('}');
--nesting; --nesting;
if (nesting < 0) if (nesting < 0)
@@ -791,7 +791,7 @@ eqopt ({sp}=)?
RETURN_VALUE (BRACED_PREDICATE, last_string); RETURN_VALUE (BRACED_PREDICATE, last_string);
} }
else else
obstack_1grow (&obstack_for_string, '}'); STRING_1GROW ('}');
} }
} }

View File

@@ -102,9 +102,9 @@ static void output_mapped_file (char const *name);
{ {
[^@]+ STRING_GROW (); [^@]+ STRING_GROW ();
"@@" obstack_1grow (&obstack_for_string, '@'); "@@" STRING_1GROW ('@');
"@{" obstack_1grow (&obstack_for_string, '['); "@{" STRING_1GROW ('[');
"@}" obstack_1grow (&obstack_for_string, ']'); "@}" STRING_1GROW (']');
"@'" continue; /* For starting an argument that begins with whitespace. */ "@'" continue; /* For starting an argument that begins with whitespace. */
@\n continue; @\n continue;