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. |
7 |
|
|
8 |
Written by Philip Hazel |
Written by Philip Hazel |
9 |
Copyright (c) 1997-2009 University of Cambridge |
Copyright (c) 1997-2012 University of Cambridge |
10 |
|
|
11 |
----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
12 |
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
67 |
type the newline type |
type the newline type |
68 |
endptr pointer to the end of the string |
endptr pointer to the end of the string |
69 |
lenptr where to return the length |
lenptr where to return the length |
70 |
utf8 TRUE if in utf8 mode |
utf TRUE if in utf mode |
71 |
|
|
72 |
Returns: TRUE or FALSE |
Returns: TRUE or FALSE |
73 |
*/ |
*/ |
74 |
|
|
75 |
BOOL |
BOOL |
76 |
_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, |
77 |
|
BOOL utf) |
78 |
{ |
{ |
79 |
int c; |
int c; |
80 |
if (utf8) { GETCHAR(c, ptr); } else c = *ptr; |
(void)utf; |
81 |
|
#ifdef SUPPORT_UTF |
82 |
|
if (utf) |
83 |
|
{ |
84 |
|
GETCHAR(c, ptr); |
85 |
|
} |
86 |
|
else |
87 |
|
#endif /* SUPPORT_UTF */ |
88 |
|
c = *ptr; |
89 |
|
|
90 |
if (type == NLTYPE_ANYCRLF) switch(c) |
if (type == NLTYPE_ANYCRLF) switch(c) |
91 |
{ |
{ |
104 |
case 0x000c: *lenptr = 1; return TRUE; /* FF */ |
case 0x000c: *lenptr = 1; return TRUE; /* FF */ |
105 |
case 0x000d: *lenptr = (ptr < endptr - 1 && ptr[1] == 0x0a)? 2 : 1; |
case 0x000d: *lenptr = (ptr < endptr - 1 && ptr[1] == 0x0a)? 2 : 1; |
106 |
return TRUE; /* CR */ |
return TRUE; /* CR */ |
107 |
case 0x0085: *lenptr = utf8? 2 : 1; return TRUE; /* NEL */ |
#ifdef COMPILE_PCRE8 |
108 |
|
case 0x0085: *lenptr = utf? 2 : 1; return TRUE; /* NEL */ |
109 |
case 0x2028: /* LS */ |
case 0x2028: /* LS */ |
110 |
case 0x2029: *lenptr = 3; return TRUE; /* PS */ |
case 0x2029: *lenptr = 3; return TRUE; /* PS */ |
111 |
|
#else |
112 |
|
case 0x0085: /* NEL */ |
113 |
|
case 0x2028: /* LS */ |
114 |
|
case 0x2029: *lenptr = 1; return TRUE; /* PS */ |
115 |
|
#endif /* COMPILE_PCRE8 */ |
116 |
default: return FALSE; |
default: return FALSE; |
117 |
} |
} |
118 |
} |
} |
131 |
type the newline type |
type the newline type |
132 |
startptr pointer to the start of the string |
startptr pointer to the start of the string |
133 |
lenptr where to return the length |
lenptr where to return the length |
134 |
utf8 TRUE if in utf8 mode |
utf TRUE if in utf mode |
135 |
|
|
136 |
Returns: TRUE or FALSE |
Returns: TRUE or FALSE |
137 |
*/ |
*/ |
138 |
|
|
139 |
BOOL |
BOOL |
140 |
_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, |
141 |
|
BOOL utf) |
142 |
{ |
{ |
143 |
int c; |
int c; |
144 |
|
(void)utf; |
145 |
ptr--; |
ptr--; |
146 |
#ifdef SUPPORT_UTF8 |
#ifdef SUPPORT_UTF |
147 |
if (utf8) |
if (utf) |
148 |
{ |
{ |
149 |
BACKCHAR(ptr); |
BACKCHAR(ptr); |
150 |
GETCHAR(c, ptr); |
GETCHAR(c, ptr); |
151 |
} |
} |
152 |
else c = *ptr; |
else |
153 |
#else /* no UTF-8 support */ |
#endif /* SUPPORT_UTF */ |
154 |
c = *ptr; |
c = *ptr; |
|
#endif /* SUPPORT_UTF8 */ |
|
155 |
|
|
156 |
if (type == NLTYPE_ANYCRLF) switch(c) |
if (type == NLTYPE_ANYCRLF) switch(c) |
157 |
{ |
{ |
168 |
case 0x000b: /* VT */ |
case 0x000b: /* VT */ |
169 |
case 0x000c: /* FF */ |
case 0x000c: /* FF */ |
170 |
case 0x000d: *lenptr = 1; return TRUE; /* CR */ |
case 0x000d: *lenptr = 1; return TRUE; /* CR */ |
171 |
case 0x0085: *lenptr = utf8? 2 : 1; return TRUE; /* NEL */ |
#ifdef COMPILE_PCRE8 |
172 |
|
case 0x0085: *lenptr = utf? 2 : 1; return TRUE; /* NEL */ |
173 |
case 0x2028: /* LS */ |
case 0x2028: /* LS */ |
174 |
case 0x2029: *lenptr = 3; return TRUE; /* PS */ |
case 0x2029: *lenptr = 3; return TRUE; /* PS */ |
175 |
|
#else |
176 |
|
case 0x0085: /* NEL */ |
177 |
|
case 0x2028: /* LS */ |
178 |
|
case 0x2029: *lenptr = 1; return TRUE; /* PS */ |
179 |
|
#endif /* COMPILE_PCRE8 */ |
180 |
default: return FALSE; |
default: return FALSE; |
181 |
} |
} |
182 |
} |
} |