]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Support string concatenation in YCP string extractor.
authorBruno Haible <bruno@clisp.org>
Thu, 1 Jun 2006 11:58:56 +0000 (11:58 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:13:22 +0000 (12:13 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/x-ycp.c
gettext-tools/tests/ChangeLog
gettext-tools/tests/Makefile.am

index 7b31356af66bd183f3319c1752cda13acdb42269..2c3ba88fa4d0d18752388080812b356249ee14a9 100644 (file)
@@ -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.
index 9ea14e45bec91e146a700fa6a6c7d7565367736c..57fc91f19e887a6d2a4499c4a3fc2fc37fc5d48e 100644 (file)
@@ -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:
index af1099dedd6447705b554679a3a26fd5099ce129..8b54fabf69cc9cdc68aef485e45c54fba38428b8 100644 (file)
@@ -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.
index 568b727258b0a83d3b5fc910c055222ce2a50f69..8b6529ee5a41268bf4f1368711b4f7243ff53ad2 100644 (file)
@@ -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 \