diff mbox

Fix for UTF-16 string encoding

Message ID 51E1C9FE.8010603@jaredparsons.com
State New
Headers show

Commit Message

Jared Parsons July 13, 2013, 9:43 p.m. UTC
Hello everyone,

Attached is a patch to fix bug 41698 
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41698) and a second patch 
with extends test suite coverage for it.

No unexpected failures on the g++ test suite.




libcpp/Changelog:

2013-07-13  Jared Parsons  <jaredpar@gmail.com>

     * charset.c: Fixed UTF-16 encoding of U+FFFF.

gcc/testsuite/Changelog:

2013-07-13  Jared Parsons  <jaredpar@gmail.com>

     * g++.dg/ext/utf16-1.C: Extended test case.




- Jared

--- gcc/testsuite/g++.dg/ext/utf16-1.C.old	2013-07-13 16:56:08.500387672 -0400
+++ gcc/testsuite/g++.dg/ext/utf16-1.C	2013-07-13 16:58:06.633726139 -0400
@@ -19,11 +19,15 @@ const static char16_t	c9 = L'a';
 const static char16_t	ca = L'\u2029';
 const static char16_t	cb = L'\u8010';
 
+const static char16_t   cc = u'\uFFFF';
+
 #define A	0x0061
 #define D	0x0024
 #define X	0x2029
 #define Y	0x8010
 
+#define Z   0xFFFF
+
 int main ()
 {
     if (sizeof (u'a') != sizeof (char16_t))
@@ -62,4 +66,7 @@ int main ()
 	abort ();
     if (cb != Y)
 	abort ();
+
+    if (cc != Z)
+        abort();
 }
diff mbox

Patch

--- libcpp/charset.c.old	2013-07-13 02:05:15.008064713 -0400
+++ libcpp/charset.c	2013-07-13 02:05:43.688066468 -0400
@@ -353,7 +353,7 @@  one_utf8_to_utf16 (iconv_t bigend, const
       return EILSEQ;
     }
 
-  if (s < 0xFFFF)
+  if (s <= 0xFFFF)
     {
       if (*outbytesleftp < 2)
 	{