/[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 77 by nigel, Sat Feb 24 21:40:45 2007 UTC revision 535 by ph10, Thu Jun 3 19:18:24 2010 UTC
# Line 6  Line 6 
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-2005 University of Cambridge             Copyright (c) 1997-2010 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
# Line 39  POSSIBILITY OF SUCH DAMAGE. Line 39  POSSIBILITY OF SUCH DAMAGE.
39    
40    
41  /* This module contains an internal function that is used to match an extended  /* This module contains an internal function that is used to match an extended
42  class (one that contains characters whose values are > 255). It is used by both  class. It is used by both pcre_exec() and pcre_def_exec(). */
 pcre_exec() and pcre_def_exec(). */  
43    
44    
45    #ifdef HAVE_CONFIG_H
46    #include "config.h"
47    #endif
48    
49  #include "pcre_internal.h"  #include "pcre_internal.h"
50    
51    
# Line 51  pcre_exec() and pcre_def_exec(). */ Line 54  pcre_exec() and pcre_def_exec(). */
54  *************************************************/  *************************************************/
55    
56  /* This function is called to match a character against an extended class that  /* This function is called to match a character against an extended class that
57  might contain values > 255.  might contain values > 255 and/or Unicode properties.
58    
59  Arguments:  Arguments:
60    c           the character    c           the character
# Line 60  Arguments: Line 63  Arguments:
63  Returns:      TRUE if character matches, else FALSE  Returns:      TRUE if character matches, else FALSE
64  */  */
65    
66  EXPORT BOOL  BOOL
67  _pcre_xclass(int c, const uschar *data)  _pcre_xclass(int c, const uschar *data)
68  {  {
69  int t;  int t;
# Line 100  while ((t = *data++) != XCL_END) Line 103  while ((t = *data++) != XCL_END)
103  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
104    else  /* XCL_PROP & XCL_NOTPROP */    else  /* XCL_PROP & XCL_NOTPROP */
105      {      {
106      int chartype, othercase;      const ucd_record *prop = GET_UCD(c);
107      int rqdtype = *data++;  
108      int category = ucp_findchar(c, &chartype, &othercase);      switch(*data)
     if (rqdtype >= 128)  
       {  
       if ((rqdtype - 128 == category) == (t == XCL_PROP)) return !negated;  
       }  
     else  
109        {        {
110        if ((rqdtype == chartype) == (t == XCL_PROP)) return !negated;        case PT_ANY:
111          if (t == XCL_PROP) return !negated;
112          break;
113    
114          case PT_LAMP:
115          if ((prop->chartype == ucp_Lu || prop->chartype == ucp_Ll ||
116               prop->chartype == ucp_Lt) == (t == XCL_PROP)) return !negated;
117          break;
118    
119          case PT_GC:
120          if ((data[1] == _pcre_ucp_gentype[prop->chartype]) == (t == XCL_PROP))
121            return !negated;
122          break;
123    
124          case PT_PC:
125          if ((data[1] == prop->chartype) == (t == XCL_PROP)) return !negated;
126          break;
127    
128          case PT_SC:
129          if ((data[1] == prop->script) == (t == XCL_PROP)) return !negated;
130          break;
131    
132          case PT_ALNUM:
133          if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
134               _pcre_ucp_gentype[prop->chartype] == ucp_N) == (t == XCL_PROP))
135            return !negated;
136          break;
137    
138          case PT_SPACE:    /* Perl space */
139          if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
140               c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)
141                 == (t == XCL_PROP))
142            return !negated;
143          break;
144    
145          case PT_PXSPACE:  /* POSIX space */
146          if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
147               c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
148               c == CHAR_FF || c == CHAR_CR) == (t == XCL_PROP))
149            return !negated;
150          break;
151    
152          case PT_WORD:
153          if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
154               _pcre_ucp_gentype[prop->chartype] == ucp_N || c == CHAR_UNDERSCORE)
155                 == (t == XCL_PROP))
156            return !negated;
157          break;
158    
159          /* This should never occur, but compilers may mutter if there is no
160          default. */
161    
162          default:
163          return FALSE;
164        }        }
165    
166        data += 2;
167      }      }
168  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
169    }    }

Legend:
Removed from v.77  
changed lines
  Added in v.535

  ViewVC Help
Powered by ViewVC 1.1.5