pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] q2c: Eliminate many translations for generated .c files.


From: Ben Pfaff
Subject: [PATCH] q2c: Eliminate many translations for generated .c files.
Date: Sat, 19 Mar 2011 17:45:50 -0700

Most of the %s directives used in msg() format strings that q2c
generates don't have to be substituted at q2c translation time.  By
translating them later, we can eliminate a lot of the work that
translators need to do for q2c-generated fiels.
---
This seems correct to me but I'd like to have another set of eyes
look it over before I push it.

 src/language/lexer/q2c.c    |   30 ++++++++++++++----------------
 tests/language/lexer/q2c.at |    4 ++--
 2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/src/language/lexer/q2c.c b/src/language/lexer/q2c.c
index d578dbc..37dad5a 100644
--- a/src/language/lexer/q2c.c
+++ b/src/language/lexer/q2c.c
@@ -1500,8 +1500,8 @@ dump_specifier_parse (const specifier *spec, const 
subcommand *sbc)
                {
                  dump (1, "if (!lex_match (lexer, T_LPAREN))");
                  dump (1, "{");
-                 dump (0, "msg (SE, _(\"`(' expected after %s "
-                       "specifier of %s subcommand.\"));",
+                 dump (0, "msg (SE, _(\"`(' expected after %%s "
+                       "specifier of %%s subcommand.\"), \"%s\", \"%s\");",
                        s->specname, sbc->name);
                  dump (0, "goto lossage;");
                  dump (-1, "}");
@@ -1513,8 +1513,8 @@ dump_specifier_parse (const specifier *spec, const 
subcommand *sbc)
            {
              dump (1, "if (!lex_is_integer (lexer))");
              dump (1, "{");
-             dump (0, "msg (SE, _(\"%s specifier of %s subcommand "
-                   "requires an integer argument.\"));",
+             dump (0, "msg (SE, _(\"%%s specifier of %%s subcommand "
+                   "requires an integer argument.\"), \"%s\", \"%s\");",
                    s->specname, sbc->name);
              dump (0, "goto lossage;");
              dump (-1, "}");
@@ -1525,8 +1525,8 @@ dump_specifier_parse (const specifier *spec, const 
subcommand *sbc)
            {
              dump (1, "if (!lex_is_number (lexer))");
              dump (1, "{");
-             dump (0, "msg (SE, _(\"Number expected after %s "
-                   "specifier of %s subcommand.\"));",
+             dump (0, "msg (SE, _(\"Number expected after %%s "
+                   "specifier of %%s subcommand.\"), \"%s\", \"%s\");",
                    s->specname, sbc->name);
              dump (0, "goto lossage;");
              dump (-1, "}");
@@ -1538,8 +1538,8 @@ dump_specifier_parse (const specifier *spec, const 
subcommand *sbc)
               dump (1, "if (lex_token (lexer) != T_ID "
                     "&& !lex_is_string (lexer))");
               dump (1, "{");
-              dump (0, "msg (SE, _(\"%s specifier of %s subcommand "
-                    "requires a string argument.\"));",
+              dump (0, "msg (SE, _(\"%%s specifier of %%s subcommand "
+                    "requires a string argument.\"), \"%s\", \"%s\");",
                    s->specname, sbc->name);
              dump (0, "goto lossage;");
              dump (-1, "}");
@@ -1565,8 +1565,8 @@ dump_specifier_parse (const specifier *spec, const 
subcommand *sbc)
              }
 
              dump (1, "{");
-             dump (0, "msg (SE, _(\"Bad argument for %s "
-                   "specifier of %s subcommand.\"));",
+             dump (0, "msg (SE, _(\"Bad argument for %%s "
+                   "specifier of %%s subcommand.\"), \"%s\", \"%s\");",
                    s->specname, sbc->name);
              dump (0, "goto lossage;");
              dump (-1, "}");
@@ -1580,7 +1580,7 @@ dump_specifier_parse (const specifier *spec, const 
subcommand *sbc)
              dump (1, "if (!lex_match (lexer, T_RPAREN))");
              dump (1, "{");
              dump (0, "msg (SE, _(\"`)' expected after argument for "
-                   "%s specifier of %s.\"));",
+                   "%%s specifier of %%s.\"), \"%s\", \"%s\");",
                    s->specname, sbc->name);
              dump (0, "goto lossage;");
              dump (-1, "}");
@@ -1710,7 +1710,7 @@ dump_subcommand (const subcommand *sbc)
          dump (0, "x = ss_length (lex_tokss (lexer));");
          dump (1, "if (!(%s))", sbc->restriction);
          dump (1, "{");
-         dump (0, "msg (SE, _(\"String for %s must be %s.\"));",
+         dump (0, "msg (SE, _(\"String for %%s must be %s.\"), \"%s\");",
                sbc->name, sbc->message);
          dump (0, "goto lossage;");
          dump (-1, "}");
@@ -1891,8 +1891,7 @@ dump_parser (int persistent)
          {
            dump (1, "if (p->sbc_%s > 1)", st_lower (sbc->name));
            dump (1, "{");
-           dump (0, "msg (SE, _(\"%s subcommand may be given only once.\"));",
-                 sbc->name);
+           dump (0, "lex_sbc_only_once (\"%s\");", sbc->name);
            dump (0, "goto lossage;");
            dump (-1, "}");
            outdent ();
@@ -1946,8 +1945,7 @@ dump_parser (int persistent)
          {
            dump (0, "if ( 0 == p->sbc_%s)", st_lower (sbc->name));
            dump (1, "{");
-           dump (0, "msg (SE, _(\"%s subcommand must be given.\"));",
-                 sbc->name);
+           dump (0, "lex_sbc_missing (lexer, \"%s\");", sbc->name);
            dump (0, "goto lossage;");
            dump (-1, "}");
            dump_blank_line (0);
diff --git a/tests/language/lexer/q2c.at b/tests/language/lexer/q2c.at
index eeeed8d..3e4eb68 100644
--- a/tests/language/lexer/q2c.at
+++ b/tests/language/lexer/q2c.at
@@ -14,10 +14,10 @@ ONEWAY.
 CROSSTABS.
 ])
 AT_CHECK([pspp -O format=csv q2c.sps], [1], [dnl
-q2c.sps:8: error: EXAMINE: VARIABLES subcommand must be given.
+q2c.sps:8: error: EXAMINE: Syntax error at end of command: missing required 
subcommand VARIABLES.
 
 q2c.sps:9: error: ONEWAY: Syntax error at end of command: expecting variable 
name.
 
-q2c.sps:10: error: CROSSTABS: TABLES subcommand must be given.
+q2c.sps:10: error: CROSSTABS: Syntax error at end of command: missing required 
subcommand TABLES.
 ])
 AT_CLEANUP
-- 
1.7.2.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]