]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Fix handling of octal and hexadecimal escapes inside u"..." strings.
authorBruno Haible <bruno@clisp.org>
Mon, 27 Aug 2007 23:33:08 +0000 (23:33 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:15:01 +0000 (12:15 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/x-python.c

index 8ade3d7cb2e1b9841258aa67be4ef2c62a9699d7..ef394fddf5d5e0147571118679667ac68ba095e0 100644 (file)
@@ -1,3 +1,9 @@
+2007-08-27  Bruno Haible  <bruno@clisp.org>
+
+       * x-python.c (phase7_getuc): Interpret octal and hexadecimal escapes
+       as Unicode code points inside Unicode strings.
+       Reported and patch by Jakub Wilk <ubanus@users.sf.net>.
+
 2007-08-23  Bruno Haible  <bruno@clisp.org>
 
        * file-list.c: Don't include getline.h.
index 45915f9b1e6b3230d85cc00b41f9086852f33afc..1eb337949014f9b0cfa6119c7aab839ee48d41fe 100644 (file)
@@ -1002,7 +1002,8 @@ struct token_ty
     u"abc"    \<nl> \\ \' \" \a\b\f\n\r\t\v \ooo \xnn \unnnn \Unnnnnnnn \N{...}
     ur"abc"                                           \unnnn
    The \unnnn values are UTF-16 values; a single \Unnnnnnnn can expand to two
-   \unnnn items.  The \ooo and \xnn values are in the current source encoding.
+   \unnnn items.  The \ooo and \xnn values are in the current source encoding
+   for byte strings, and Unicode code points for Unicode strings.
  */
 
 static int
@@ -1140,7 +1141,10 @@ phase7_getuc (int quote_char,
                    phase2_ungetc (c);
                }
              *backslash_counter = 0;
-             return (unsigned char) n;
+             if (interpret_unicode)
+               return UNICODE (n);
+             else
+               return (unsigned char) n;
            }
          case 'x':
            {
@@ -1172,8 +1176,12 @@ phase7_getuc (int quote_char,
 
                  if (n2 >= 0)
                    {
+                     int n = (n1 << 4) + n2;
                      *backslash_counter = 0;
-                     return (unsigned char) ((n1 << 4) + n2);
+                     if (interpret_unicode)
+                       return UNICODE (n);
+                     else
+                       return (unsigned char) n;
                    }
 
                  phase2_ungetc (c2);