~ubuntu-branches/ubuntu/trusty/pcre3/trusty

« back to all changes in this revision

Viewing changes to pcre_newline.c

  • Committer: Package Import Robot
  • Author(s): Mark Baker
  • Date: 2012-03-23 22:34:54 UTC
  • mfrom: (23.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20120323223454-grhqqolk8a7x1h24
Tags: 1:8.30-4
* Reluctantly using an epoch, as it seems the funny version number with
  extra dots causes problems
* Bumped standard version to 3.9.3. No changes needed
* Converted to use new source format / quilt
* Put back obsolete pcre_info() API that upstream have dropped (Closes:
  #665300, #665356)
* Don't include pcregrep binary in debug package

Thanks to Elimar Riesebieter for the conversion to the new source format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
and semantics are as close as possible to those of the Perl 5 language.
7
7
 
8
8
                       Written by Philip Hazel
9
 
           Copyright (c) 1997-2009 University of Cambridge
 
9
           Copyright (c) 1997-2012 University of Cambridge
10
10
 
11
11
-----------------------------------------------------------------------------
12
12
Redistribution and use in source and binary forms, with or without
67
67
  type         the newline type
68
68
  endptr       pointer to the end of the string
69
69
  lenptr       where to return the length
70
 
  utf8         TRUE if in utf8 mode
 
70
  utf          TRUE if in utf mode
71
71
 
72
72
Returns:       TRUE or FALSE
73
73
*/
74
74
 
75
75
BOOL
76
 
_pcre_is_newline(USPTR ptr, int type, USPTR endptr, int *lenptr, BOOL utf8)
 
76
PRIV(is_newline)(PCRE_PUCHAR ptr, int type, PCRE_PUCHAR endptr, int *lenptr,
 
77
  BOOL utf)
77
78
{
78
79
int c;
79
 
if (utf8) { GETCHAR(c, ptr); } else c = *ptr;
 
80
(void)utf;
 
81
#ifdef SUPPORT_UTF
 
82
if (utf)
 
83
  {
 
84
  GETCHAR(c, ptr);
 
85
  }
 
86
else
 
87
#endif  /* SUPPORT_UTF */
 
88
  c = *ptr;
80
89
 
81
90
if (type == NLTYPE_ANYCRLF) switch(c)
82
91
  {
95
104
  case 0x000c: *lenptr = 1; return TRUE;             /* FF */
96
105
  case 0x000d: *lenptr = (ptr < endptr - 1 && ptr[1] == 0x0a)? 2 : 1;
97
106
               return TRUE;                          /* CR */
98
 
  case 0x0085: *lenptr = utf8? 2 : 1; return TRUE;   /* NEL */
 
107
#ifdef COMPILE_PCRE8
 
108
  case 0x0085: *lenptr = utf? 2 : 1; return TRUE;    /* NEL */
99
109
  case 0x2028:                                       /* LS */
100
110
  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 */
101
116
  default: return FALSE;
102
117
  }
103
118
}
116
131
  type         the newline type
117
132
  startptr     pointer to the start of the string
118
133
  lenptr       where to return the length
119
 
  utf8         TRUE if in utf8 mode
 
134
  utf          TRUE if in utf mode
120
135
 
121
136
Returns:       TRUE or FALSE
122
137
*/
123
138
 
124
139
BOOL
125
 
_pcre_was_newline(USPTR ptr, int type, USPTR startptr, int *lenptr, BOOL utf8)
 
140
PRIV(was_newline)(PCRE_PUCHAR ptr, int type, PCRE_PUCHAR startptr, int *lenptr,
 
141
  BOOL utf)
126
142
{
127
143
int c;
 
144
(void)utf;
128
145
ptr--;
129
 
#ifdef SUPPORT_UTF8
130
 
if (utf8)
 
146
#ifdef SUPPORT_UTF
 
147
if (utf)
131
148
  {
132
149
  BACKCHAR(ptr);
133
150
  GETCHAR(c, ptr);
134
151
  }
135
 
else c = *ptr;
136
 
#else   /* no UTF-8 support */
137
 
c = *ptr;
138
 
#endif  /* SUPPORT_UTF8 */
 
152
else
 
153
#endif  /* SUPPORT_UTF */
 
154
  c = *ptr;
139
155
 
140
156
if (type == NLTYPE_ANYCRLF) switch(c)
141
157
  {
152
168
  case 0x000b:                                      /* VT */
153
169
  case 0x000c:                                      /* FF */
154
170
  case 0x000d: *lenptr = 1; return TRUE;            /* CR */
155
 
  case 0x0085: *lenptr = utf8? 2 : 1; return TRUE;  /* NEL */
 
171
#ifdef COMPILE_PCRE8
 
172
  case 0x0085: *lenptr = utf? 2 : 1; return TRUE;   /* NEL */
156
173
  case 0x2028:                                      /* LS */
157
174
  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 */
158
180
  default: return FALSE;
159
181
  }
160
182
}