|
version 1.1.1.1, 2012/02/21 23:05:51
|
version 1.1.1.3, 2013/07/22 08:25:56
|
|
Line 6
|
Line 6
|
| and semantics are as close as possible to those of the Perl 5 language. |
and semantics are as close as possible to those of the Perl 5 language. |
| |
|
| Written by Philip Hazel |
Written by Philip Hazel |
| Copyright (c) 1997-2009 University of Cambridge | Copyright (c) 1997-2013 University of Cambridge |
| |
|
| ----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
| Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
|
Line 92 PCRE_UTF8_ERR18 Overlong 5-byte sequence (won't ever
|
Line 92 PCRE_UTF8_ERR18 Overlong 5-byte sequence (won't ever
|
| PCRE_UTF8_ERR19 Overlong 6-byte sequence (won't ever occur) |
PCRE_UTF8_ERR19 Overlong 6-byte sequence (won't ever occur) |
| PCRE_UTF8_ERR20 Isolated 0x80 byte (not within UTF-8 character) |
PCRE_UTF8_ERR20 Isolated 0x80 byte (not within UTF-8 character) |
| PCRE_UTF8_ERR21 Byte with the illegal value 0xfe or 0xff |
PCRE_UTF8_ERR21 Byte with the illegal value 0xfe or 0xff |
| |
PCRE_UTF8_ERR22 Unused (was non-character) |
| |
|
| Arguments: |
Arguments: |
| string points to the string |
string points to the string |
|
Line 103 Returns: = 0 if the string is a valid UTF-8 s
|
Line 104 Returns: = 0 if the string is a valid UTF-8 s
|
| */ |
*/ |
| |
|
| int |
int |
| _pcre_valid_utf8(USPTR string, int length, int *erroroffset) | PRIV(valid_utf)(PCRE_PUCHAR string, int length, int *erroroffset) |
| { |
{ |
| #ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF |
| register USPTR p; | register PCRE_PUCHAR p; |
| |
|
| if (length < 0) |
if (length < 0) |
| { |
{ |
|
Line 116 if (length < 0)
|
Line 117 if (length < 0)
|
| |
|
| for (p = string; length-- > 0; p++) |
for (p = string; length-- > 0; p++) |
| { |
{ |
| register int ab, c, d; | register pcre_uchar ab, c, d; |
| |
|
| c = *p; |
c = *p; |
| if (c < 128) continue; /* ASCII character */ |
if (c < 128) continue; /* ASCII character */ |
|
Line 133 for (p = string; length-- > 0; p++)
|
Line 134 for (p = string; length-- > 0; p++)
|
| return PCRE_UTF8_ERR21; |
return PCRE_UTF8_ERR21; |
| } |
} |
| |
|
| ab = _pcre_utf8_table4[c & 0x3f]; /* Number of additional bytes */ | ab = PRIV(utf8_table4)[c & 0x3f]; /* Number of additional bytes */ |
| if (length < ab) |
if (length < ab) |
| { |
{ |
| *erroroffset = (int)(p - string); /* Missing bytes */ |
*erroroffset = (int)(p - string); /* Missing bytes */ |
|
Line 288 for (p = string; length-- > 0; p++)
|
Line 289 for (p = string; length-- > 0; p++)
|
| } |
} |
| } |
} |
| |
|
| #else /* SUPPORT_UTF8 */ | #else /* Not SUPPORT_UTF */ |
| (void)(string); /* Keep picky compilers happy */ |
(void)(string); /* Keep picky compilers happy */ |
| (void)(length); |
(void)(length); |
| |
(void)(erroroffset); |
| #endif |
#endif |
| |
|
| return PCRE_UTF8_ERR0; /* This indicates success */ |
return PCRE_UTF8_ERR0; /* This indicates success */ |