diff options
author | Bruno Haible <bruno@clisp.org> | 2006-06-01 11:58:56 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2009-06-23 12:13:22 +0200 |
commit | ccd9227fe12e0bc51451ffdcbf18b19fe11eb927 (patch) | |
tree | a5725847016c9be599f1303baf01e68ba2805a30 /gettext-tools/src/x-ycp.c | |
parent | b643a4dcd620b7b3e935c198f098196a69094b21 (diff) | |
download | external_gettext-ccd9227fe12e0bc51451ffdcbf18b19fe11eb927.zip external_gettext-ccd9227fe12e0bc51451ffdcbf18b19fe11eb927.tar.gz external_gettext-ccd9227fe12e0bc51451ffdcbf18b19fe11eb927.tar.bz2 |
Support string concatenation in YCP string extractor.
Diffstat (limited to 'gettext-tools/src/x-ycp.c')
-rw-r--r-- | gettext-tools/src/x-ycp.c | 61 |
1 files changed, 57 insertions, 4 deletions
diff --git a/gettext-tools/src/x-ycp.c b/gettext-tools/src/x-ycp.c index 9ea14e4..57fc91f 100644 --- a/gettext-tools/src/x-ycp.c +++ b/gettext-tools/src/x-ycp.c @@ -1,5 +1,5 @@ /* xgettext YCP backend. - Copyright (C) 2001-2003, 2005 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005-2006 Free Software Foundation, Inc. This file was written by Bruno Haible <haible@clisp.cons.org>, 2001. @@ -41,7 +41,8 @@ /* The YCP syntax is defined in libycp/doc/syntax.html. - See also libycp/src/scanner.ll. */ + See also libycp/src/scanner.ll. + Both are part of the yast2-core package in SuSE Linux distributions. */ void @@ -404,14 +405,22 @@ phase7_getc () /* Combine characters into tokens. Discard whitespace. */ +static token_ty phase5_pushback[1]; +static int phase5_pushback_length; + static void -x_ycp_lex (token_ty *tp) +phase5_get (token_ty *tp) { static char *buffer; static int bufmax; int bufpos; int c; + if (phase5_pushback_length) + { + *tp = phase5_pushback[--phase5_pushback_length]; + return; + } for (;;) { tp->line_number = line_number; @@ -545,6 +554,46 @@ x_ycp_lex (token_ty *tp) } } +/* Supports only one pushback token. */ +static void +phase5_unget (token_ty *tp) +{ + if (tp->type != token_type_eof) + { + if (phase5_pushback_length == SIZEOF (phase5_pushback)) + abort (); + phase5_pushback[phase5_pushback_length++] = *tp; + } +} + + +/* Concatenate adjacent string literals to form single string literals. + (See libycp/src/parser.yy, rule 'string' vs. terminal 'STRING'.) */ + +static void +phase8_get (token_ty *tp) +{ + phase5_get (tp); + if (tp->type != token_type_string_literal) + return; + for (;;) + { + token_ty tmp; + size_t len; + + phase5_get (&tmp); + if (tmp.type != token_type_string_literal) + { + phase5_unget (&tmp); + return; + } + len = strlen (tp->string); + tp->string = xrealloc (tp->string, len + strlen (tmp.string) + 1); + strcpy (tp->string + len, tmp.string); + free (tmp.string); + } +} + /* ========================= Extracting strings. ========================== */ @@ -594,7 +643,11 @@ extract_parenthesized (message_list_ty *mlp, { token_ty token; - x_ycp_lex (&token); + if (in_i18n) + phase8_get (&token); + else + phase5_get (&token); + switch (token.type) { case token_type_i18n: |