diff options
Diffstat (limited to 'gettext-tools')
-rw-r--r-- | gettext-tools/src/ChangeLog | 10 | ||||
-rw-r--r-- | gettext-tools/src/x-ycp.c | 61 | ||||
-rw-r--r-- | gettext-tools/tests/ChangeLog | 5 | ||||
-rw-r--r-- | gettext-tools/tests/Makefile.am | 2 |
4 files changed, 73 insertions, 5 deletions
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 7b31356..2c3ba88 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,13 @@ +2006-05-31 Bruno Haible <bruno@clisp.org> + + * x-ycp.c (phase5_pushback, phase5_pushback_length): New variables. + (phase5_get): Renamed from x_ycp_lex. + (phase5_unget): New function. + (phase8_get): New function. + (extract_parenthesized): Inside i18n construct, use phase8_get + instead of phase5_get. + Reported by Karl Eichwalder <ke@suse.de>. + 2006-05-22 Bruno Haible <bruno@clisp.org> * msgfilter.c: Include <sys/select.h> also on Minix. 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: diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index af1099d..8b54fab 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,8 @@ +2006-05-31 Bruno Haible <bruno@clisp.org> + + * xgettext-ycp-3: New file, from Karl Eichwalder <ke@suse.de>. + * Makefile.am (TESTS): Add it. + 2006-05-16 Bruno Haible <bruno@clisp.org> * gettext-4-prg.c: Set the LC_ALL environment variable, not just LANG. diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index 568b727..8b6529e 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -88,7 +88,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \ xgettext-smalltalk-1 \ xgettext-stringtable-1 \ xgettext-tcl-1 xgettext-tcl-2 \ - xgettext-ycp-1 xgettext-ycp-2 \ + xgettext-ycp-1 xgettext-ycp-2 xgettext-ycp-3 \ format-awk-1 format-awk-2 \ format-boost-1 format-boost-2 \ format-c-1 format-c-2 format-c-3 format-c-4 format-c-5 \ |