bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: xgettext: ycp with string literal concatenation


From: Bruno Haible
Subject: Re: xgettext: ycp with string literal concatenation
Date: Thu, 1 Jun 2006 13:52:45 +0200
User-agent: KMail/1.5

Karl Eichwalder wrote:

> ycp also allows string literal concatenation

More precisely, string literal concatenation is performed in the arguments
of the _() operator. This is not documented. I would expect it to be
documented in the file tdg/id_ycp_data_locale.html in yast-documentation.tgz
at http://forge.novell.com/modules/xfmod/project/?yast .

Find attached a patch, relative to gettext-0.14.5.

Bruno


*** gettext-0.14.5/gettext-tools/src/x-ycp.c.orig       2005-05-20 
22:47:36.000000000 +0200
--- gettext-0.14.5/gettext-tools/src/x-ycp.c    2006-06-01 01:32:52.000000000 
+0200
***************
*** 1,5 ****
  /* xgettext YCP backend.
!    Copyright (C) 2001-2003 Free Software Foundation, Inc.
  
     This file was written by Bruno Haible <address@hidden>, 2001.
  
--- 1,5 ----
  /* xgettext YCP backend.
!    Copyright (C) 2001-2003, 2006 Free Software Foundation, Inc.
  
     This file was written by Bruno Haible <address@hidden>, 2001.
  
***************
*** 42,48 ****
  
  
  /* The YCP syntax is defined in libycp/doc/syntax.html.
!    See also libycp/src/scanner.ll.  */
  
  
  void
--- 42,49 ----
  
  
  /* The YCP syntax is defined in libycp/doc/syntax.html.
!    See also libycp/src/scanner.ll.
!    Both are part of the yast2-core package in SuSE Linux distributions.  */
  
  
  void
***************
*** 405,418 ****
  
  /* Combine characters into tokens.  Discard whitespace.  */
  
  static void
! x_ycp_lex (token_ty *tp)
  {
    static char *buffer;
    static int bufmax;
    int bufpos;
    int c;
  
    for (;;)
      {
        tp->line_number = line_number;
--- 406,427 ----
  
  /* Combine characters into tokens.  Discard whitespace.  */
  
+ static token_ty phase5_pushback[1];
+ static int phase5_pushback_length;
+ 
  static void
! 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;
***************
*** 546,551 ****
--- 555,600 ----
      }
  }
  
+ /* 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.  ========================== 
*/
  
***************
*** 595,601 ****
      {
        token_ty token;
  
!       x_ycp_lex (&token);
        switch (token.type)
        {
        case token_type_i18n:
--- 644,654 ----
      {
        token_ty token;
  
!       if (in_i18n)
!       phase8_get (&token);
!       else
!       phase5_get (&token);
! 
        switch (token.type)
        {
        case token_type_i18n:





reply via email to

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