This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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;
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]