This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gccgo] Fix range over string with invalid UTF-8 character
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 07 Dec 2009 23:03:58 -0800
- Subject: [gccgo] Fix range over string with invalid UTF-8 character
In Go, a range over a string with an invalid UTF-8 character should
return the replacement character and advance the index by 1. The
runtime library function was incorrectly skipping to the end of the
string. This patch fixes it. Committed to gccgo branch.
Ian
Index: runtime/go-string-range.c
===================================================================
--- runtime/go-string-range.c (revision 154387)
+++ runtime/go-string-range.c (working copy)
@@ -36,7 +36,7 @@ __go_string_range (const struct __go_str
if (add > 0)
*pindex += add;
else
- *pindex = (int) length;
+ *pindex += 1;
return 1;
}