From: Bruno Haible Date: Mon, 27 Aug 2007 23:33:08 +0000 (+0000) Subject: Fix handling of octal and hexadecimal escapes inside u"..." strings. X-Git-Tag: v0.17~285 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a65e056d7347c739ad932c254a128649cf8f3cb3;p=thirdparty%2Fgettext.git Fix handling of octal and hexadecimal escapes inside u"..." strings. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 8ade3d7cb..ef394fddf 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,9 @@ +2007-08-27 Bruno Haible + + * x-python.c (phase7_getuc): Interpret octal and hexadecimal escapes + as Unicode code points inside Unicode strings. + Reported and patch by Jakub Wilk . + 2007-08-23 Bruno Haible * file-list.c: Don't include getline.h. diff --git a/gettext-tools/src/x-python.c b/gettext-tools/src/x-python.c index 45915f9b1..1eb337949 100644 --- a/gettext-tools/src/x-python.c +++ b/gettext-tools/src/x-python.c @@ -1002,7 +1002,8 @@ struct token_ty u"abc" \ \\ \' \" \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);