X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/d4bdb9167769a7247ac7c93c03fbe9ff7c238d34..5f340b4884a158f9d05e9325c4cfde2751f3e660:/src/scan-skel.l diff --git a/src/scan-skel.l b/src/scan-skel.l index aab570c6..d9ca8e28 100644 --- a/src/scan-skel.l +++ b/src/scan-skel.l @@ -53,7 +53,7 @@ static void fail_for_at_directive_too_few_args (void); static void fail_for_invalid_at (char const *at); /* In SC_AT_DIRECTIVE_ARG context, the name of the directive. */ -static char *at_directive_name = NULL; +static char *at_directive_name; /* Currently, only the @warn, @complain, @fatal, @warn_at, @complain_at, and @fatal_at directives take multiple arguments, and the last three already @@ -63,8 +63,7 @@ static int at_directive_argc = 0; static char *at_directive_argv[AT_DIRECTIVE_ARGC_MAX]; %} -%x SC_AT_GETTEXT_ARG -%x SC_AT_DIRECTIVE_ARGS +%x SC_AT_DIRECTIVE_ARG %x SC_AT_DIRECTIVE_SKIP_WS %% @@ -82,16 +81,14 @@ static char *at_directive_argv[AT_DIRECTIVE_ARGC_MAX]; "@ofile@" QPUTS (outname); "@dir_prefix@" QPUTS (dir_prefix); -"@gettext<" BEGIN SC_AT_GETTEXT_ARG; - @[a-z_]+"(" { yytext[yyleng-1] = '\0'; at_directive_name = xstrdup (yytext); - BEGIN SC_AT_DIRECTIVE_ARGS; + BEGIN SC_AT_DIRECTIVE_ARG; } /* This pattern must not match more than the previous @ patterns. */ -@[^<@{}(\n]* fail_for_invalid_at (yytext); +@[^@{}(\n]* fail_for_invalid_at (yytext); \n out_lineno++; ECHO; [^@\n]+ ECHO; @@ -104,48 +101,15 @@ static char *at_directive_argv[AT_DIRECTIVE_ARGC_MAX]; return EOF; } -{ - "@>" { - char *arg; - obstack_1grow (&obstack_for_string, '\0'); - arg = obstack_finish (&obstack_for_string); - if (!at_directive_name) - { - fprintf (yyout, "%s", _(arg)); - obstack_free (&obstack_for_string, arg); - BEGIN INITIAL; - } - else - { - char const *translated = _(arg); - size_t parent_size = strlen (at_directive_argv[at_directive_argc]); - size_t translated_size = strlen (translated); - char *copy = xmalloc (parent_size + translated_size + 1); - strcpy (copy, at_directive_argv[at_directive_argc]); - strcpy (copy + parent_size, translated); - obstack_free (&obstack_for_string, - at_directive_argv[at_directive_argc]); - obstack_grow (&obstack_for_string, copy, - parent_size + translated_size); - free (copy); - BEGIN SC_AT_DIRECTIVE_ARGS; - } - } -} +{ + [^@]+ { STRING_GROW; } -{ + "@@" { obstack_1grow (&obstack_for_string, '@'); } + "@{" { obstack_1grow (&obstack_for_string, '['); } + "@}" { obstack_1grow (&obstack_for_string, ']'); } "@`" /* Emtpy. Useful for starting an argument that begins with whitespace. */ - "@gettext<" { - if (at_directive_argc >= AT_DIRECTIVE_ARGC_MAX) - fail_for_at_directive_too_many_args (); - obstack_1grow (&obstack_for_string, '\0'); - at_directive_argv[at_directive_argc] = - obstack_finish (&obstack_for_string); - BEGIN SC_AT_GETTEXT_ARG; - } - @[,)] { if (at_directive_argc >= AT_DIRECTIVE_ARGC_MAX) fail_for_at_directive_too_many_args (); @@ -163,29 +127,21 @@ static char *at_directive_argv[AT_DIRECTIVE_ARGC_MAX]; obstack_free (&obstack_for_string, at_directive_argv[0]); at_directive_argc = 0; free (at_directive_name); - at_directive_name = NULL; BEGIN INITIAL; } } -} -{ - [^@]+ { STRING_GROW; } - "@@" { obstack_1grow (&obstack_for_string, '@'); } - "@{" { obstack_1grow (&obstack_for_string, '['); } - "@}" { obstack_1grow (&obstack_for_string, ']'); } @.? { fail_for_invalid_at (yytext); } } { [ \t\r\n] - . { yyless (0); BEGIN SC_AT_DIRECTIVE_ARGS; } + . { yyless (0); BEGIN SC_AT_DIRECTIVE_ARG; } } -{ +{ <> { - fatal (_("unclosed %s directive in skeleton"), - at_directive_name ? at_directive_name : "@gettext"); + fatal (_("unclosed %s directive in skeleton"), at_directive_name); } } @@ -241,21 +197,21 @@ void at_directive_perform (char **outnamep, int *out_linenop) switch (at_directive_argc) { case 1: - func (at_directive_argv[0]); + func (_(at_directive_argv[0])); break; case 2: - func (at_directive_argv[0], at_directive_argv[1]); + func (_(at_directive_argv[0]), at_directive_argv[1]); break; case 3: - func (at_directive_argv[0], at_directive_argv[1], + func (_(at_directive_argv[0]), at_directive_argv[1], at_directive_argv[2]); break; case 4: - func (at_directive_argv[0], at_directive_argv[1], + func (_(at_directive_argv[0]), at_directive_argv[1], at_directive_argv[2], at_directive_argv[3]); break; case 5: - func (at_directive_argv[0], at_directive_argv[1], + func (_(at_directive_argv[0]), at_directive_argv[1], at_directive_argv[2], at_directive_argv[3], at_directive_argv[4]); break; @@ -284,21 +240,21 @@ void at_directive_perform (char **outnamep, int *out_linenop) switch (at_directive_argc) { case 3: - func (loc, at_directive_argv[2]); + func (loc, _(at_directive_argv[2])); break; case 4: - func (loc, at_directive_argv[2], at_directive_argv[3]); + func (loc, _(at_directive_argv[2]), at_directive_argv[3]); break; case 5: - func (loc, at_directive_argv[2], at_directive_argv[3], + func (loc, _(at_directive_argv[2]), at_directive_argv[3], at_directive_argv[4]); break; case 6: - func (loc, at_directive_argv[2], at_directive_argv[3], + func (loc, _(at_directive_argv[2]), at_directive_argv[3], at_directive_argv[4], at_directive_argv[5]); break; case 7: - func (loc, at_directive_argv[2], at_directive_argv[3], + func (loc, _(at_directive_argv[2]), at_directive_argv[3], at_directive_argv[4], at_directive_argv[5], at_directive_argv[6]); break;