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

Diff of /code/trunk/pcre_xclass.c

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

revision 1386 by ph10, Sat Oct 12 18:02:11 2013 UTC revision 1387 by ph10, Sat Nov 2 18:29:05 2013 UTC
# Line 128  while ((t = *data++) != XCL_END) Line 128  while ((t = *data++) != XCL_END)
128    else  /* XCL_PROP & XCL_NOTPROP */    else  /* XCL_PROP & XCL_NOTPROP */
129      {      {
130      const ucd_record *prop = GET_UCD(c);      const ucd_record *prop = GET_UCD(c);
131        BOOL isprop = t == XCL_PROP;
132    
133      switch(*data)      switch(*data)
134        {        {
135        case PT_ANY:        case PT_ANY:
136        if (t == XCL_PROP) return !negated;        if (isprop) return !negated;
137        break;        break;
138    
139        case PT_LAMP:        case PT_LAMP:
140        if ((prop->chartype == ucp_Lu || prop->chartype == ucp_Ll ||        if ((prop->chartype == ucp_Lu || prop->chartype == ucp_Ll ||
141             prop->chartype == ucp_Lt) == (t == XCL_PROP)) return !negated;             prop->chartype == ucp_Lt) == isprop) return !negated;
142        break;        break;
143    
144        case PT_GC:        case PT_GC:
145        if ((data[1] == PRIV(ucp_gentype)[prop->chartype]) == (t == XCL_PROP))        if ((data[1] == PRIV(ucp_gentype)[prop->chartype]) == isprop)
146          return !negated;          return !negated;
147        break;        break;
148    
149        case PT_PC:        case PT_PC:
150        if ((data[1] == prop->chartype) == (t == XCL_PROP)) return !negated;        if ((data[1] == prop->chartype) == isprop) return !negated;
151        break;        break;
152    
153        case PT_SC:        case PT_SC:
154        if ((data[1] == prop->script) == (t == XCL_PROP)) return !negated;        if ((data[1] == prop->script) == isprop) return !negated;
155        break;        break;
156    
157        case PT_ALNUM:        case PT_ALNUM:
158        if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||        if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
159             PRIV(ucp_gentype)[prop->chartype] == ucp_N) == (t == XCL_PROP))             PRIV(ucp_gentype)[prop->chartype] == ucp_N) == isprop)
160          return !negated;          return !negated;
161        break;        break;
162    
# Line 169  while ((t = *data++) != XCL_END) Line 170  while ((t = *data++) != XCL_END)
170          {          {
171          HSPACE_CASES:          HSPACE_CASES:
172          VSPACE_CASES:          VSPACE_CASES:
173          if (t == XCL_PROP) return !negated;          if (isprop) return !negated;
174          break;          break;
175    
176          default:          default:
177          if ((PRIV(ucp_gentype)[prop->chartype] == ucp_Z) == (t == XCL_PROP))          if ((PRIV(ucp_gentype)[prop->chartype] == ucp_Z) == isprop)
178            return !negated;            return !negated;
179          break;          break;
180          }          }
# Line 182  while ((t = *data++) != XCL_END) Line 183  while ((t = *data++) != XCL_END)
183        case PT_WORD:        case PT_WORD:
184        if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||        if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
185             PRIV(ucp_gentype)[prop->chartype] == ucp_N || c == CHAR_UNDERSCORE)             PRIV(ucp_gentype)[prop->chartype] == ucp_N || c == CHAR_UNDERSCORE)
186               == (t == XCL_PROP))               == isprop)
187          return !negated;          return !negated;
188        break;        break;
189    
# Line 190  while ((t = *data++) != XCL_END) Line 191  while ((t = *data++) != XCL_END)
191        if (c < 0xa0)        if (c < 0xa0)
192          {          {
193          if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||          if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
194               c == CHAR_GRAVE_ACCENT) == (t == XCL_PROP))               c == CHAR_GRAVE_ACCENT) == isprop)
195            return !negated;            return !negated;
196          }          }
197        else        else
198          {          {
199          if ((c < 0xd800 || c > 0xdfff) == (t == XCL_PROP))          if ((c < 0xd800 || c > 0xdfff) == isprop)
200            return !negated;            return !negated;
201          }          }
202        break;        break;
203    
204          /* The following three properties can occur only in an XCLASS, as there
205          is no \p or \P coding for them. */
206    
207          /* Graphic character. Implement this as not Z (space or separator) and
208          not C (other), except for Cf (format) with a few exceptions. This seems
209          to be what Perl does. The exceptional characters are:
210    
211          U+061C           Arabic Letter Mark
212          U+180E           Mongolian Vowel Separator
213          U+2066 - U+2069  Various "isolate"s
214          */
215    
216          case PT_PXGRAPH:
217          if ((PRIV(ucp_gentype)[prop->chartype] != ucp_Z &&
218                (PRIV(ucp_gentype)[prop->chartype] != ucp_C ||
219                  (prop->chartype == ucp_Cf &&
220                    c != 0x061c && c != 0x180e && (c < 0x2066 || c > 0x2069))
221             )) == isprop)
222            return !negated;
223          break;
224    
225          /* Printable character: same as graphic, with the addition of Zs, i.e.
226          not Zl and not Zp, and U+180E. */
227    
228          case PT_PXPRINT:
229          if ((prop->chartype != ucp_Zl &&
230               prop->chartype != ucp_Zp &&
231                (PRIV(ucp_gentype)[prop->chartype] != ucp_C ||
232                  (prop->chartype == ucp_Cf &&
233                    c != 0x061c && (c < 0x2066 || c > 0x2069))
234             )) == isprop)
235            return !negated;
236          break;
237    
238          /* Punctuation: all Unicode punctuation, plus ASCII characters that
239          Unicode treats as symbols rather than punctuation, for Perl
240          compatibility (these are $+<=>^`|~). */
241    
242          case PT_PXPUNCT:
243          if ((PRIV(ucp_gentype)[prop->chartype] == ucp_P ||
244                (c < 256 && PRIV(ucp_gentype)[prop->chartype] == ucp_S)) == isprop)
245            return !negated;
246          break;
247    
248        /* This should never occur, but compilers may mutter if there is no        /* This should never occur, but compilers may mutter if there is no
249        default. */        default. */

Legend:
Removed from v.1386  
changed lines
  Added in v.1387

  ViewVC Help
Powered by ViewVC 1.1.5