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

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

Re: xgettext doesn't handle escapes properly for bash


From: Bruno Haible
Subject: Re: xgettext doesn't handle escapes properly for bash
Date: Mon, 2 May 2005 13:53:07 +0200
User-agent: KMail/1.5

Jakub Bogusz wrote:
> When using bash $"" translations, bash requires backslash-escaped
> characters to be included with escapes in msgid/msgstr strings.
> `bash --dump-po-strings` handles this properly, but xgettext doesn't
> - it just omits backslash character.
> Here is short test (using bash 3.0 and gettext 0.14.4):
>
> $ cat xgt-test
> #!/bin/bash
> echo $"quoted \`"
>
> $ bash --dump-po-strings xgt-test
> #: xgt-test:3
> msgid "quoted \\`"
> msgstr ""
>
> $ LC_ALL=C xgettext --omit-header -L shell -d -  xgt-test
> xgt-test:3: warning: the syntax $"..." is deprecated due to security
> reasons; use eval_gettext instead #: xgt-test:3
> msgid "quoted `"
> msgstr ""

Thanks for the report. This fix will be contained in gettext-0.15.

Bruno


diff -r -c3 --exclude='*.po*' --exclude='*.info*' --exclude='*_*.html' 
--exclude='*.*.html' --exclude='*.[13]' --exclude='*.1.in' 
--exclude=Makefile.in --exclude=aclocal.m4 --exclude=configure 
--exclude=version.texi --exclude=stamp-vti --exclude='po-*-gen*.[ch]' 
--exclude='*.o' --exclude='*.lo' --exclude='*.gmo' --exclude=ABOUT-NLS 
--exclude='javadoc[12]' --exclude=CVS gettext-cvs/gettext-tools/src/x-sh.c 
gettext-6/gettext-tools/src/x-sh.c
*** gettext-cvs/gettext-tools/src/x-sh.c        Tue Dec 30 12:30:01 2003
--- gettext-6/gettext-tools/src/x-sh.c  Sun May  1 20:51:01 2005
***************
*** 362,367 ****
--- 362,371 ----
     innermost backquotes nesting.  */
  static bool open_singlequote;
  
+ /* The expected terminator of the currently open single-quote.
+    Usually '\'', but can be '"' for i18n-quotes.  */
+ static char open_singlequote_terminator;
+ 
  
  /* Functions to update the state.  */
  
***************
*** 407,412 ****
--- 411,417 ----
    if (open_doublequote || open_singlequote)
      abort ();
    open_singlequote = true;
+   open_singlequote_terminator = '\'';
  }
  
  static inline void
***************
*** 529,536 ****
    if (c == EOF)
      return c;
    if (c == '\'')
!     return (open_doublequote ? QUOTED (c) : c);
!   if (!open_singlequote)
      {
        if (c == '"' || c == '$')
        return c;
--- 534,549 ----
    if (c == EOF)
      return c;
    if (c == '\'')
!     return ((open_doublequote
!            || (open_singlequote && open_singlequote_terminator != c))
!           ? QUOTED (c)
!           : c);
!   if (open_singlequote)
!     {
!       if (c == open_singlequote_terminator)
!       return c;
!     }
!   else
      {
        if (c == '"' || c == '$')
        return c;
***************
*** 573,579 ****
              return '\\';
            }
          else
!           return (open_doublequote ? QUOTED (c) : c);
        }
        else if (c == '"')
        {
--- 586,595 ----
              return '\\';
            }
          else
!           return ((open_doublequote
!                    || (open_singlequote && open_singlequote_terminator != c))
!                   ? QUOTED (c)
!                   : c);
        }
        else if (c == '"')
        {
***************
*** 590,596 ****
                  return '\\';
                }
              else
!               return QUOTED (c);
            }
          else
            {
--- 606,612 ----
                  return '\\';
                }
              else
!               return (open_singlequote_terminator != c ? QUOTED (c) : c);
            }
          else
            {
***************
*** 990,996 ****
              lex_pos_ty pos;
              struct token string;
  
!             saw_opening_doublequote ();
              pos.file_name = logical_file_name;
              pos.line_number = line_number;
              init_token (&string);
--- 1006,1013 ----
              lex_pos_ty pos;
              struct token string;
  
!             saw_opening_singlequote ();
!             open_singlequote_terminator = '"';
              pos.file_name = logical_file_name;
              pos.line_number = line_number;
              init_token (&string);
***************
*** 1001,1007 ****
                    break;
                  if (c == '"')
                    {
!                     saw_closing_doublequote ();
                      break;
                    }
                  grow_token (&string);
--- 1018,1024 ----
                    break;
                  if (c == '"')
                    {
!                     saw_closing_singlequote ();
                      break;
                    }
                  grow_token (&string);
***************
*** 1042,1048 ****
  
        if (c == '"')
        {
!         if (!open_doublequote)
            {
              /* Handle an opening double quote.  */
              saw_opening_doublequote ();
--- 1059,1070 ----
  
        if (c == '"')
        {
!         if (open_singlequote && open_singlequote_terminator == '"')
!           {
!             /* Handle a closing i18n quote.  */
!             saw_closing_singlequote ();
!           }
!         else if (!open_doublequote)
            {
              /* Handle an opening double quote.  */
              saw_opening_doublequote ();





reply via email to

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