]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Fix interpretation of backslashes in $"..." strings.
authorBruno Haible <bruno@clisp.org>
Tue, 3 May 2005 10:49:47 +0000 (10:49 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:12:33 +0000 (12:12 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/x-sh.c
gettext-tools/tests/ChangeLog
gettext-tools/tests/Makefile.am

index 0036cab678f50beca541de6b11d8cc513df7f18b..9b3c88191a95c026b7be9e70db4ebd3b028dc1ce 100644 (file)
@@ -1,3 +1,12 @@
+2005-05-01  Bruno Haible  <bruno@clisp.org>
+
+       * x-sh.c (open_singlequote_terminator): New variable.
+       (saw_opening_singlequote): Set it.
+       (phase2_getc): Handle the case of open_singlequote_terminator == '"'.
+       (read_word): Likewise. Treat i18n quotes like single quotes with
+       terminator '"'.
+       Reported by Jakub Bogusz <qboosh@pld-linux.org>.
+
 2005-05-01  Bruno Haible  <bruno@clisp.org>
 
        Improved error message.
index 66faadd78288d93d24c2553c8956b6a2b3ce4c99..cd66eac33559c9e5393a5ce7f98c7acf6e6a7c49 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext sh backend.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software; you can redistribute it and/or modify
@@ -362,6 +362,10 @@ static bool open_doublequote;
    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,6 +411,7 @@ saw_opening_singlequote ()
   if (open_doublequote || open_singlequote)
     abort ();
   open_singlequote = true;
+  open_singlequote_terminator = '\'';
 }
 
 static inline void
@@ -529,8 +534,16 @@ phase2_getc ()
   if (c == EOF)
     return c;
   if (c == '\'')
-    return (open_doublequote ? QUOTED (c) : c);
-  if (!open_singlequote)
+    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,7 +586,10 @@ phase2_getc ()
              return '\\';
            }
          else
-           return (open_doublequote ? QUOTED (c) : c);
+           return ((open_doublequote
+                    || (open_singlequote && open_singlequote_terminator != c))
+                   ? QUOTED (c)
+                   : c);
        }
       else if (c == '"')
        {
@@ -590,7 +606,7 @@ phase2_getc ()
                  return '\\';
                }
              else
-               return QUOTED (c);
+               return (open_singlequote_terminator != c ? QUOTED (c) : c);
            }
          else
            {
@@ -990,7 +1006,8 @@ read_word (struct word *wp, int looking_for, flag_context_ty context)
              lex_pos_ty pos;
              struct token string;
 
-             saw_opening_doublequote ();
+             saw_opening_singlequote ();
+             open_singlequote_terminator = '"';
              pos.file_name = logical_file_name;
              pos.line_number = line_number;
              init_token (&string);
@@ -1001,7 +1018,7 @@ read_word (struct word *wp, int looking_for, flag_context_ty context)
                    break;
                  if (c == '"')
                    {
-                     saw_closing_doublequote ();
+                     saw_closing_singlequote ();
                      break;
                    }
                  grow_token (&string);
@@ -1042,7 +1059,12 @@ read_word (struct word *wp, int looking_for, flag_context_ty context)
 
       if (c == '"')
        {
-         if (!open_doublequote)
+         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 ();
index 7b45ca8e521d11f733c7dc3027df096113b016bb..2d6200da0d335d2c46642c92cd2c0659dfceab60 100644 (file)
@@ -1,3 +1,8 @@
+2005-05-01  Bruno Haible  <bruno@clisp.org>
+
+       * xgettext-sh-4: New file.
+       * Makefile.am (TESTS): Add it.
+
 2005-03-20  Bruno Haible  <bruno@clisp.org>
 
        * gettext-6: New file.
index 542270175614f9f4bf26a33b8aa289726eca5eb1..2ac99534d945ef3578fe4323444db6fda6a3c79b 100644 (file)
@@ -78,7 +78,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \
        xgettext-properties-1 \
        xgettext-python-1 xgettext-python-2 \
        xgettext-scheme-1 \
-       xgettext-sh-1 xgettext-sh-2 xgettext-sh-3 \
+       xgettext-sh-1 xgettext-sh-2 xgettext-sh-3 xgettext-sh-4 \
        xgettext-smalltalk-1 \
        xgettext-stringtable-1 \
        xgettext-tcl-1 xgettext-tcl-2 \