/[pcre]/code/trunk/pcre_valid_utf8.c
ViewVC logotype

Diff of /code/trunk/pcre_valid_utf8.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1032 by ph10, Sat Sep 8 16:05:38 2012 UTC revision 1098 by chpe, Tue Oct 16 15:56:18 2012 UTC
# Line 92  PCRE_UTF8_ERR18  Overlong 5-byte sequenc Line 92  PCRE_UTF8_ERR18  Overlong 5-byte sequenc
92  PCRE_UTF8_ERR19  Overlong 6-byte sequence (won't ever occur)  PCRE_UTF8_ERR19  Overlong 6-byte sequence (won't ever occur)
93  PCRE_UTF8_ERR20  Isolated 0x80 byte (not within UTF-8 character)  PCRE_UTF8_ERR20  Isolated 0x80 byte (not within UTF-8 character)
94  PCRE_UTF8_ERR21  Byte with the illegal value 0xfe or 0xff  PCRE_UTF8_ERR21  Byte with the illegal value 0xfe or 0xff
95    PCRE_UTF8_ERR22  Non-character
96    
97  Arguments:  Arguments:
98    string       points to the string    string       points to the string
# Line 116  if (length < 0) Line 117  if (length < 0)
117    
118  for (p = string; length-- > 0; p++)  for (p = string; length-- > 0; p++)
119    {    {
120    register int ab, c, d;    register pcre_uchar ab, c, d;
121      pcre_uint32 v = 0;
122    
123    c = *p;    c = *p;
124    if (c < 128) continue;                /* ASCII character */    if (c < 128) continue;                /* ASCII character */
# Line 185  for (p = string; length-- > 0; p++) Line 187  for (p = string; length-- > 0; p++)
187        *erroroffset = (int)(p - string) - 2;        *erroroffset = (int)(p - string) - 2;
188        return PCRE_UTF8_ERR14;        return PCRE_UTF8_ERR14;
189        }        }
190        v = ((c & 0x0f) << 12) | ((d & 0x3f) << 6) | (*p & 0x3f);
191      break;      break;
192    
193      /* 4-byte character. Check 3rd and 4th bytes for 0x80. Then check first 2      /* 4-byte character. Check 3rd and 4th bytes for 0x80. Then check first 2
# Line 212  for (p = string; length-- > 0; p++) Line 215  for (p = string; length-- > 0; p++)
215        *erroroffset = (int)(p - string) - 3;        *erroroffset = (int)(p - string) - 3;
216        return PCRE_UTF8_ERR13;        return PCRE_UTF8_ERR13;
217        }        }
218        v = ((c & 0x07) << 18) | ((d & 0x3f) << 12) | ((p[-1] & 0x3f) << 6) | (*p & 0x3f);
219      break;      break;
220    
221      /* 5-byte and 6-byte characters are not allowed by RFC 3629, and will be      /* 5-byte and 6-byte characters are not allowed by RFC 3629, and will be
# Line 286  for (p = string; length-- > 0; p++) Line 290  for (p = string; length-- > 0; p++)
290      *erroroffset = (int)(p - string) - ab;      *erroroffset = (int)(p - string) - ab;
291      return (ab == 4)? PCRE_UTF8_ERR11 : PCRE_UTF8_ERR12;      return (ab == 4)? PCRE_UTF8_ERR11 : PCRE_UTF8_ERR12;
292      }      }
293    
294      /* Reject non-characters. The pointer p is currently at the last byte of the
295      character. */
296      if ((v & 0xfffeu) == 0xfffeu || (v >= 0xfdd0 && v <= 0xfdef))
297        {
298        *erroroffset = (int)(p - string) - ab;
299        return PCRE_UTF8_ERR22;
300        }
301    }    }
302    
303  #else  /* Not SUPPORT_UTF */  #else  /* Not SUPPORT_UTF */

Legend:
Removed from v.1032  
changed lines
  Added in v.1098

  ViewVC Help
Powered by ViewVC 1.1.5