From 412f8a597541a83259f22f0013494cfd0d34f7c5 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 13 Nov 2002 06:40:35 +0000 Subject: [PATCH] Revamp regular expressions so that " and ' do not confuse xgettext. --- src/scan-gram.l | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/scan-gram.l b/src/scan-gram.l index 4e2e1942..caad580f 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -259,7 +259,10 @@ splice (\\[ \f\t\v]*\n)* YY_STEP; } - ^"#line "{int}" \""[^\"]*"\"\n" handle_syncline (yytext + strlen ("#line "), yylloc); YY_STEP; + ^"#line "{int}" \"".*"\"\n" { + handle_syncline (yytext + sizeof "#line " - 1, yylloc); + YY_STEP; + } "=" return EQUAL; ":" rule_length = 0; return COLON; @@ -450,7 +453,10 @@ splice (\\[ \f\t\v]*\n)* \\r obstack_1grow (&string_obstack, '\r'); \\t obstack_1grow (&string_obstack, '\t'); \\v obstack_1grow (&string_obstack, '\v'); - \\[\"\'?\\] obstack_1grow (&string_obstack, yytext[1]); + + /* \\[\"\'?\\] would be shorter, but it confuses xgettext. */ + \\("\""|"'"|"?"|"\\") obstack_1grow (&string_obstack, yytext[1]); + \\(u|U[0-9a-fA-F]{4})[0-9a-fA-F]{4} { int c = convert_ucn_to_byte (yytext); if (c < 0) @@ -477,9 +483,9 @@ splice (\\[ \f\t\v]*\n)* { - "'" YY_OBS_GROW; BEGIN c_context; - \\{splice}[\'\\] YY_OBS_GROW; - <> unexpected_end_of_file (yylloc, "'"); + "'" YY_OBS_GROW; BEGIN c_context; + \\{splice}[^$@\[\]] YY_OBS_GROW; + <> unexpected_end_of_file (yylloc, "'"); } @@ -490,9 +496,9 @@ splice (\\[ \f\t\v]*\n)* { - "\"" YY_OBS_GROW; BEGIN c_context; - \\{splice}[\"\\] YY_OBS_GROW; - <> unexpected_end_of_file (yylloc, "\""); + "\"" YY_OBS_GROW; BEGIN c_context; + \\{splice}[^$@\[\]] YY_OBS_GROW; + <> unexpected_end_of_file (yylloc, "\""); } -- 2.47.2