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

Diff of /code/trunk/pcre_newline.c

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

revision 1033 by ph10, Mon Sep 10 11:02:48 2012 UTC revision 1221 by ph10, Sun Nov 11 20:27:03 2012 UTC
# Line 60  http://unicode.org/unicode/reports/tr18/ Line 60  http://unicode.org/unicode/reports/tr18/
60  *************************************************/  *************************************************/
61    
62  /* It is guaranteed that the initial value of ptr is less than the end of the  /* It is guaranteed that the initial value of ptr is less than the end of the
63  string that is being processed.  string that is being processed.
64    
65  Arguments:  Arguments:
66    ptr          pointer to possible newline    ptr          pointer to possible newline
# Line 76  BOOL Line 76  BOOL
76  PRIV(is_newline)(PCRE_PUCHAR ptr, int type, PCRE_PUCHAR endptr, int *lenptr,  PRIV(is_newline)(PCRE_PUCHAR ptr, int type, PCRE_PUCHAR endptr, int *lenptr,
77    BOOL utf)    BOOL utf)
78  {  {
79  int c;  pcre_uint32 c;
80  (void)utf;  (void)utf;
81  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
82  if (utf)  if (utf)
# Line 86  if (utf) Line 86  if (utf)
86  else  else
87  #endif  /* SUPPORT_UTF */  #endif  /* SUPPORT_UTF */
88    c = *ptr;    c = *ptr;
89    
90  /* Note that this function is called only for ANY or ANYCRLF. */  /* Note that this function is called only for ANY or ANYCRLF. */
91    
92  if (type == NLTYPE_ANYCRLF) switch(c)  if (type == NLTYPE_ANYCRLF) switch(c)
93    {    {
# Line 103  else switch(c) Line 103  else switch(c)
103    {    {
104  #ifdef EBCDIC  #ifdef EBCDIC
105    case CHAR_NEL:    case CHAR_NEL:
106  #endif  #endif
107    case CHAR_LF:    case CHAR_LF:
108    case CHAR_VT:    case CHAR_VT:
109    case CHAR_FF: *lenptr = 1; return TRUE;    case CHAR_FF: *lenptr = 1; return TRUE;
110    
111    case CHAR_CR:    case CHAR_CR:
112    *lenptr = (ptr < endptr - 1 && ptr[1] == CHAR_LF)? 2 : 1;    *lenptr = (ptr < endptr - 1 && ptr[1] == CHAR_LF)? 2 : 1;
113    return TRUE;    return TRUE;
114    
# Line 117  else switch(c) Line 117  else switch(c)
117    case CHAR_NEL: *lenptr = utf? 2 : 1; return TRUE;    case CHAR_NEL: *lenptr = utf? 2 : 1; return TRUE;
118    case 0x2028:                                       /* LS */    case 0x2028:                                       /* LS */
119    case 0x2029: *lenptr = 3; return TRUE;             /* PS */    case 0x2029: *lenptr = 3; return TRUE;             /* PS */
120  #else   /* 16-bit (can't be EBCDIC) */  #else /* COMPILE_PCRE16 || COMPILE_PCRE32 */
121    case CHAR_NEL:    case CHAR_NEL:
122    case 0x2028:                                       /* LS */    case 0x2028:                                       /* LS */
123    case 0x2029: *lenptr = 1; return TRUE;             /* PS */    case 0x2029: *lenptr = 1; return TRUE;             /* PS */
# Line 151  BOOL Line 151  BOOL
151  PRIV(was_newline)(PCRE_PUCHAR ptr, int type, PCRE_PUCHAR startptr, int *lenptr,  PRIV(was_newline)(PCRE_PUCHAR ptr, int type, PCRE_PUCHAR startptr, int *lenptr,
152    BOOL utf)    BOOL utf)
153  {  {
154  int c;  pcre_uint32 c;
155  (void)utf;  (void)utf;
156  ptr--;  ptr--;
157  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
# Line 164  else Line 164  else
164  #endif  /* SUPPORT_UTF */  #endif  /* SUPPORT_UTF */
165    c = *ptr;    c = *ptr;
166    
167  /* Note that this function is called only for ANY or ANYCRLF. */  /* Note that this function is called only for ANY or ANYCRLF. */
168    
169  if (type == NLTYPE_ANYCRLF) switch(c)  if (type == NLTYPE_ANYCRLF) switch(c)
170    {    {
171    case CHAR_LF:    case CHAR_LF:
172    *lenptr = (ptr > startptr && ptr[-1] == CHAR_CR)? 2 : 1;    *lenptr = (ptr > startptr && ptr[-1] == CHAR_CR)? 2 : 1;
173    return TRUE;    return TRUE;
174    
175    case CHAR_CR: *lenptr = 1; return TRUE;    case CHAR_CR: *lenptr = 1; return TRUE;
176    default: return FALSE;    default: return FALSE;
177    }    }
# Line 180  if (type == NLTYPE_ANYCRLF) switch(c) Line 180  if (type == NLTYPE_ANYCRLF) switch(c)
180    
181  else switch(c)  else switch(c)
182    {    {
183    case CHAR_LF:    case CHAR_LF:
184    *lenptr = (ptr > startptr && ptr[-1] == CHAR_CR)? 2 : 1;    *lenptr = (ptr > startptr && ptr[-1] == CHAR_CR)? 2 : 1;
185    return TRUE;    return TRUE;
186    
187  #ifdef EBCDIC  #ifdef EBCDIC
188    case CHAR_NEL:    case CHAR_NEL:
189  #endif  #endif
190    case CHAR_VT:    case CHAR_VT:
191    case CHAR_FF:    case CHAR_FF:
192    case CHAR_CR: *lenptr = 1; return TRUE;    case CHAR_CR: *lenptr = 1; return TRUE;
193    
194  #ifndef EBCDIC  #ifndef EBCDIC
195  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
196    case CHAR_NEL: *lenptr = utf? 2 : 1; return TRUE;    case CHAR_NEL: *lenptr = utf? 2 : 1; return TRUE;
197    case 0x2028:                                       /* LS */    case 0x2028:                                       /* LS */
198    case 0x2029: *lenptr = 3; return TRUE;             /* PS */    case 0x2029: *lenptr = 3; return TRUE;             /* PS */
199  #else  #else /* COMPILE_PCRE16 || COMPILE_PCRE32 */
200    case CHAR_NEL:    case CHAR_NEL:
201    case 0x2028:                                       /* LS */    case 0x2028:                                       /* LS */
202    case 0x2029: *lenptr = 1; return TRUE;             /* PS */    case 0x2029: *lenptr = 1; return TRUE;             /* PS */

Legend:
Removed from v.1033  
changed lines
  Added in v.1221

  ViewVC Help
Powered by ViewVC 1.1.5