version 1.1.1.1, 2012/02/21 23:05:51
|
version 1.1.1.2, 2012/02/21 23:50:25
|
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-2012 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 67 Arguments:
|
Line 67 Arguments:
|
type the newline type |
type the newline type |
endptr pointer to the end of the string |
endptr pointer to the end of the string |
lenptr where to return the length |
lenptr where to return the length |
utf8 TRUE if in utf8 mode | utf TRUE if in utf mode |
|
|
Returns: TRUE or FALSE |
Returns: TRUE or FALSE |
*/ |
*/ |
|
|
BOOL |
BOOL |
_pcre_is_newline(USPTR ptr, int type, USPTR endptr, int *lenptr, BOOL utf8) | PRIV(is_newline)(PCRE_PUCHAR ptr, int type, PCRE_PUCHAR endptr, int *lenptr, |
| BOOL utf) |
{ |
{ |
int c; |
int c; |
if (utf8) { GETCHAR(c, ptr); } else c = *ptr; | (void)utf; |
| #ifdef SUPPORT_UTF |
| if (utf) |
| { |
| GETCHAR(c, ptr); |
| } |
| else |
| #endif /* SUPPORT_UTF */ |
| c = *ptr; |
|
|
if (type == NLTYPE_ANYCRLF) switch(c) |
if (type == NLTYPE_ANYCRLF) switch(c) |
{ |
{ |
Line 95 else switch(c)
|
Line 104 else switch(c)
|
case 0x000c: *lenptr = 1; return TRUE; /* FF */ |
case 0x000c: *lenptr = 1; return TRUE; /* FF */ |
case 0x000d: *lenptr = (ptr < endptr - 1 && ptr[1] == 0x0a)? 2 : 1; |
case 0x000d: *lenptr = (ptr < endptr - 1 && ptr[1] == 0x0a)? 2 : 1; |
return TRUE; /* CR */ |
return TRUE; /* CR */ |
case 0x0085: *lenptr = utf8? 2 : 1; return TRUE; /* NEL */ | #ifdef COMPILE_PCRE8 |
| case 0x0085: *lenptr = utf? 2 : 1; return TRUE; /* NEL */ |
case 0x2028: /* LS */ |
case 0x2028: /* LS */ |
case 0x2029: *lenptr = 3; return TRUE; /* PS */ |
case 0x2029: *lenptr = 3; return TRUE; /* PS */ |
|
#else |
|
case 0x0085: /* NEL */ |
|
case 0x2028: /* LS */ |
|
case 0x2029: *lenptr = 1; return TRUE; /* PS */ |
|
#endif /* COMPILE_PCRE8 */ |
default: return FALSE; |
default: return FALSE; |
} |
} |
} |
} |
Line 116 Arguments:
|
Line 131 Arguments:
|
type the newline type |
type the newline type |
startptr pointer to the start of the string |
startptr pointer to the start of the string |
lenptr where to return the length |
lenptr where to return the length |
utf8 TRUE if in utf8 mode | utf TRUE if in utf mode |
|
|
Returns: TRUE or FALSE |
Returns: TRUE or FALSE |
*/ |
*/ |
|
|
BOOL |
BOOL |
_pcre_was_newline(USPTR ptr, int type, USPTR startptr, int *lenptr, BOOL utf8) | PRIV(was_newline)(PCRE_PUCHAR ptr, int type, PCRE_PUCHAR startptr, int *lenptr, |
| BOOL utf) |
{ |
{ |
int c; |
int c; |
|
(void)utf; |
ptr--; |
ptr--; |
#ifdef SUPPORT_UTF8 | #ifdef SUPPORT_UTF |
if (utf8) | if (utf) |
{ |
{ |
BACKCHAR(ptr); |
BACKCHAR(ptr); |
GETCHAR(c, ptr); |
GETCHAR(c, ptr); |
} |
} |
else c = *ptr; | else |
#else /* no UTF-8 support */ | #endif /* SUPPORT_UTF */ |
c = *ptr; | c = *ptr; |
#endif /* SUPPORT_UTF8 */ | |
|
|
if (type == NLTYPE_ANYCRLF) switch(c) |
if (type == NLTYPE_ANYCRLF) switch(c) |
{ |
{ |
Line 152 else switch(c)
|
Line 168 else switch(c)
|
case 0x000b: /* VT */ |
case 0x000b: /* VT */ |
case 0x000c: /* FF */ |
case 0x000c: /* FF */ |
case 0x000d: *lenptr = 1; return TRUE; /* CR */ |
case 0x000d: *lenptr = 1; return TRUE; /* CR */ |
case 0x0085: *lenptr = utf8? 2 : 1; return TRUE; /* NEL */ | #ifdef COMPILE_PCRE8 |
| case 0x0085: *lenptr = utf? 2 : 1; return TRUE; /* NEL */ |
case 0x2028: /* LS */ |
case 0x2028: /* LS */ |
case 0x2029: *lenptr = 3; return TRUE; /* PS */ |
case 0x2029: *lenptr = 3; return TRUE; /* PS */ |
|
#else |
|
case 0x0085: /* NEL */ |
|
case 0x2028: /* LS */ |
|
case 0x2029: *lenptr = 1; return TRUE; /* PS */ |
|
#endif /* COMPILE_PCRE8 */ |
default: return FALSE; |
default: return FALSE; |
} |
} |
} |
} |