/[pcre]/code/tags/pcre-7.9/pcre_maketables.c
ViewVC logotype

Diff of /code/tags/pcre-7.9/pcre_maketables.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 305 by ph10, Sun Jan 20 20:07:32 2008 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-2008 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 45  compilation of dftables.c, in which case Line 45  compilation of dftables.c, in which case
45    
46    
47  #ifndef DFTABLES  #ifndef DFTABLES
48  #include "pcre_internal.h"  #  ifdef HAVE_CONFIG_H
49    #  include "config.h"
50    #  endif
51    #  include "pcre_internal.h"
52  #endif  #endif
53    
54    
# Line 86  for (i = 0; i < 256; i++) *p++ = tolower Line 89  for (i = 0; i < 256; i++) *p++ = tolower
89    
90  for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i);  for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i);
91    
92  /* Then the character class tables. Don't try to be clever and save effort  /* Then the character class tables. Don't try to be clever and save effort on
93  on exclusive ones - in some locales things may be different. Note that the  exclusive ones - in some locales things may be different. Note that the table
94  table for "space" includes everything "isspace" gives, including VT in the  for "space" includes everything "isspace" gives, including VT in the default
95  default locale. This makes it work for the POSIX class [:space:]. */  locale. This makes it work for the POSIX class [:space:]. Note also that it is
96    possible for a character to be alnum or alpha without being lower or upper,
97    such as "male and female ordinals" (\xAA and \xBA) in the fr_FR locale (at
98    least under Debian Linux's locales as of 12/2005). So we must test for alnum
99    specially. */
100    
101  memset(p, 0, cbit_length);  memset(p, 0, cbit_length);
102  for (i = 0; i < 256; i++)  for (i = 0; i < 256; i++)
103    {    {
104    if (isdigit(i))    if (isdigit(i)) p[cbit_digit  + i/8] |= 1 << (i&7);
105      {    if (isupper(i)) p[cbit_upper  + i/8] |= 1 << (i&7);
106      p[cbit_digit  + i/8] |= 1 << (i&7);    if (islower(i)) p[cbit_lower  + i/8] |= 1 << (i&7);
107      p[cbit_word   + i/8] |= 1 << (i&7);    if (isalnum(i)) p[cbit_word   + i/8] |= 1 << (i&7);
     }  
   if (isupper(i))  
     {  
     p[cbit_upper  + i/8] |= 1 << (i&7);  
     p[cbit_word   + i/8] |= 1 << (i&7);  
     }  
   if (islower(i))  
     {  
     p[cbit_lower  + i/8] |= 1 << (i&7);  
     p[cbit_word   + i/8] |= 1 << (i&7);  
     }  
108    if (i == '_')   p[cbit_word   + i/8] |= 1 << (i&7);    if (i == '_')   p[cbit_word   + i/8] |= 1 << (i&7);
109    if (isspace(i)) p[cbit_space  + i/8] |= 1 << (i&7);    if (isspace(i)) p[cbit_space  + i/8] |= 1 << (i&7);
110    if (isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7);    if (isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7);
# Line 137  for (i = 0; i < 256; i++) Line 133  for (i = 0; i < 256; i++)
133    meta-character, which in this sense is any character that terminates a run    meta-character, which in this sense is any character that terminates a run
134    of data characters. */    of data characters. */
135    
136    if (strchr("*+?{^.$|()[", i) != 0) x += ctype_meta; *p++ = x; }    if (strchr("\\*+?{^.$|()[", i) != 0) x += ctype_meta;
137      *p++ = x;
138      }
139    
140  return yield;  return yield;
141  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.5