]> git.imager.perl.org - imager.git/commitdiff
break out of the search loop early when we find the right utf8 code
authorTony Cook <tony@develop=help.com>
Wed, 25 Oct 2006 13:24:25 +0000 (13:24 +0000)
committerTony Cook <tony@develop=help.com>
Wed, 25 Oct 2006 13:24:25 +0000 (13:24 +0000)
length

io.c

diff --git a/io.c b/io.c
index 333e2b18c65a79644e07745f064331e5e6369db0..375cc39cb3b64892feb853db731326258c33e8a5 100644 (file)
--- a/io.c
+++ b/io.c
@@ -351,10 +351,14 @@ Modifies *p and *len to indicate the consumed characters.
 This doesn't support the extended UTF8 encoding used by later versions
 of Perl.
 
+This doesn't check that the UTF8 charecter is using the shortest
+possible representation.
+
 =cut
 */
 
-unsigned long i_utf8_advance(char const **p, int *len) {
+unsigned long 
+i_utf8_advance(char const **p, int *len) {
   unsigned char c;
   int i, ci, clen = 0;
   unsigned char codes[3];
@@ -365,6 +369,7 @@ unsigned long i_utf8_advance(char const **p, int *len) {
   for (i = 0; i < sizeof(utf8_sizes)/sizeof(*utf8_sizes); ++i) {
     if ((c & utf8_sizes[i].mask) == utf8_sizes[i].expect) {
       clen = utf8_sizes[i].size;
+      break;
     }
   }
   if (clen == 0 || *len < clen-1) {