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

Diff of /code/trunk/study.c

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

revision 25 by nigel, Sat Feb 24 21:38:45 2007 UTC revision 53 by nigel, Sat Feb 24 21:39:42 2007 UTC
# Line 9  the file Tech.Notes for some information Line 9  the file Tech.Notes for some information
9    
10  Written by: Philip Hazel <ph10@cam.ac.uk>  Written by: Philip Hazel <ph10@cam.ac.uk>
11    
12             Copyright (c) 1998 University of Cambridge             Copyright (c) 1997-2001 University of Cambridge
13    
14  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
15  Permission is granted to anyone to use this software for any purpose on any  Permission is granted to anyone to use this software for any purpose on any
# Line 25  restrictions: Line 25  restrictions:
25    
26  3. Altered versions must be plainly marked as such, and must not be  3. Altered versions must be plainly marked as such, and must not be
27     misrepresented as being the original software.     misrepresented as being the original software.
28    
29    4. If PCRE is embedded in any software that is released under the GNU
30       General Purpose Licence (GPL), then the terms of that licence shall
31       supersede any condition above with which it is incompatible.
32  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
33  */  */
34    
# Line 85  set_start_bits(const uschar *code, uscha Line 89  set_start_bits(const uschar *code, uscha
89  {  {
90  register int c;  register int c;
91    
92    /* This next statement and the later reference to dummy are here in order to
93    trick the optimizer of the IBM C compiler for OS/2 into generating correct
94    code. Apparently IBM isn't going to fix the problem, and we would rather not
95    disable optimization (in this module it actually makes a big difference, and
96    the pcre module can use all the optimization it can get). */
97    
98    volatile int dummy;
99    
100  do  do
101    {    {
102    const uschar *tcode = code + 3;    const uschar *tcode = code + 3;
# Line 92  do Line 104  do
104    
105    while (try_next)    while (try_next)
106      {      {
     try_next = FALSE;  
   
107      /* If a branch starts with a bracket or a positive lookahead assertion,      /* If a branch starts with a bracket or a positive lookahead assertion,
108      recurse to set bits from within them. That's all for this branch. */      recurse to set bits from within them. That's all for this branch. */
109    
# Line 101  do Line 111  do
111        {        {
112        if (!set_start_bits(tcode, start_bits, caseless, cd))        if (!set_start_bits(tcode, start_bits, caseless, cd))
113          return FALSE;          return FALSE;
114          try_next = FALSE;
115        }        }
116    
117      else switch(*tcode)      else switch(*tcode)
# Line 108  do Line 119  do
119        default:        default:
120        return FALSE;        return FALSE;
121    
122          /* Skip over extended extraction bracket number */
123    
124          case OP_BRANUMBER:
125          tcode += 3;
126          break;
127    
128        /* Skip over lookbehind and negative lookahead assertions */        /* Skip over lookbehind and negative lookahead assertions */
129    
130        case OP_ASSERT_NOT:        case OP_ASSERT_NOT:
131        case OP_ASSERTBACK:        case OP_ASSERTBACK:
132        case OP_ASSERTBACK_NOT:        case OP_ASSERTBACK_NOT:
       try_next = TRUE;  
133        do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT);        do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT);
134        tcode += 3;        tcode += 3;
135        break;        break;
# Line 123  do Line 139  do
139        case OP_OPT:        case OP_OPT:
140        caseless = (tcode[1] & PCRE_CASELESS) != 0;        caseless = (tcode[1] & PCRE_CASELESS) != 0;
141        tcode += 2;        tcode += 2;
       try_next = TRUE;  
142        break;        break;
143    
144        /* BRAZERO does the bracket, but carries on. */        /* BRAZERO does the bracket, but carries on. */
# Line 132  do Line 147  do
147        case OP_BRAMINZERO:        case OP_BRAMINZERO:
148        if (!set_start_bits(++tcode, start_bits, caseless, cd))        if (!set_start_bits(++tcode, start_bits, caseless, cd))
149          return FALSE;          return FALSE;
150          dummy = 1;
151        do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT);        do tcode += (tcode[1] << 8) + tcode[2]; while (*tcode == OP_ALT);
152        tcode += 3;        tcode += 3;
       try_next = TRUE;  
153        break;        break;
154    
155        /* Single-char * or ? sets the bit and tries the next item */        /* Single-char * or ? sets the bit and tries the next item */
# Line 145  do Line 160  do
160        case OP_MINQUERY:        case OP_MINQUERY:
161        set_bit(start_bits, tcode[1], caseless, cd);        set_bit(start_bits, tcode[1], caseless, cd);
162        tcode += 2;        tcode += 2;
       try_next = TRUE;  
163        break;        break;
164    
165        /* Single-char upto sets the bit and tries the next */        /* Single-char upto sets the bit and tries the next */
# Line 154  do Line 168  do
168        case OP_MINUPTO:        case OP_MINUPTO:
169        set_bit(start_bits, tcode[3], caseless, cd);        set_bit(start_bits, tcode[3], caseless, cd);
170        tcode += 4;        tcode += 4;
       try_next = TRUE;  
171        break;        break;
172    
173        /* At least one single char sets the bit and stops */        /* At least one single char sets the bit and stops */
# Line 168  do Line 181  do
181        case OP_PLUS:        case OP_PLUS:
182        case OP_MINPLUS:        case OP_MINPLUS:
183        set_bit(start_bits, tcode[1], caseless, cd);        set_bit(start_bits, tcode[1], caseless, cd);
184          try_next = FALSE;
185        break;        break;
186    
187        /* Single character type sets the bits and stops */        /* Single character type sets the bits and stops */
# Line 175  do Line 189  do
189        case OP_NOT_DIGIT:        case OP_NOT_DIGIT:
190        for (c = 0; c < 32; c++)        for (c = 0; c < 32; c++)
191          start_bits[c] |= ~cd->cbits[c+cbit_digit];          start_bits[c] |= ~cd->cbits[c+cbit_digit];
192          try_next = FALSE;
193        break;        break;
194    
195        case OP_DIGIT:        case OP_DIGIT:
196        for (c = 0; c < 32; c++)        for (c = 0; c < 32; c++)
197          start_bits[c] |= cd->cbits[c+cbit_digit];          start_bits[c] |= cd->cbits[c+cbit_digit];
198          try_next = FALSE;
199        break;        break;
200    
201        case OP_NOT_WHITESPACE:        case OP_NOT_WHITESPACE:
202        for (c = 0; c < 32; c++)        for (c = 0; c < 32; c++)
203          start_bits[c] |= ~cd->cbits[c+cbit_space];          start_bits[c] |= ~cd->cbits[c+cbit_space];
204          try_next = FALSE;
205        break;        break;
206    
207        case OP_WHITESPACE:        case OP_WHITESPACE:
208        for (c = 0; c < 32; c++)        for (c = 0; c < 32; c++)
209          start_bits[c] |= cd->cbits[c+cbit_space];          start_bits[c] |= cd->cbits[c+cbit_space];
210          try_next = FALSE;
211        break;        break;
212    
213        case OP_NOT_WORDCHAR:        case OP_NOT_WORDCHAR:
214        for (c = 0; c < 32; c++)        for (c = 0; c < 32; c++)
215          start_bits[c] |= ~(cd->cbits[c] | cd->cbits[c+cbit_word]);          start_bits[c] |= ~cd->cbits[c+cbit_word];
216          try_next = FALSE;
217        break;        break;
218    
219        case OP_WORDCHAR:        case OP_WORDCHAR:
220        for (c = 0; c < 32; c++)        for (c = 0; c < 32; c++)
221          start_bits[c] |= (cd->cbits[c] | cd->cbits[c+cbit_word]);          start_bits[c] |= cd->cbits[c+cbit_word];
222          try_next = FALSE;
223        break;        break;
224    
225        /* One or more character type fudges the pointer and restarts, knowing        /* One or more character type fudges the pointer and restarts, knowing
# Line 208  do Line 228  do
228        case OP_TYPEPLUS:        case OP_TYPEPLUS:
229        case OP_TYPEMINPLUS:        case OP_TYPEMINPLUS:
230        tcode++;        tcode++;
       try_next = TRUE;  
231        break;        break;
232    
233        case OP_TYPEEXACT:        case OP_TYPEEXACT:
234        tcode += 3;        tcode += 3;
       try_next = TRUE;  
235        break;        break;
236    
237        /* Zero or more repeats of character types set the bits and then        /* Zero or more repeats of character types set the bits and then
# Line 251  do Line 269  do
269    
270          case OP_NOT_WORDCHAR:          case OP_NOT_WORDCHAR:
271          for (c = 0; c < 32; c++)          for (c = 0; c < 32; c++)
272            start_bits[c] |= ~(cd->cbits[c] | cd->cbits[c+cbit_word]);            start_bits[c] |= ~cd->cbits[c+cbit_word];
273          break;          break;
274    
275          case OP_WORDCHAR:          case OP_WORDCHAR:
276          for (c = 0; c < 32; c++)          for (c = 0; c < 32; c++)
277            start_bits[c] |= (cd->cbits[c] | cd->cbits[c+cbit_word]);            start_bits[c] |= cd->cbits[c+cbit_word];
278          break;          break;
279          }          }
280    
281        tcode += 2;        tcode += 2;
       try_next = TRUE;  
282        break;        break;
283    
284        /* Character class: set the bits and either carry on or not,        /* Character class: set the bits and either carry on or not,
# Line 279  do Line 296  do
296            case OP_CRQUERY:            case OP_CRQUERY:
297            case OP_CRMINQUERY:            case OP_CRMINQUERY:
298            tcode++;            tcode++;
           try_next = TRUE;  
299            break;            break;
300    
301            case OP_CRRANGE:            case OP_CRRANGE:
302            case OP_CRMINRANGE:            case OP_CRMINRANGE:
303            if (((tcode[1] << 8) + tcode[2]) == 0)            if (((tcode[1] << 8) + tcode[2]) == 0) tcode += 5;
304              {              else try_next = FALSE;
305              tcode += 5;            break;
306              try_next = TRUE;  
307              }            default:
308              try_next = FALSE;
309            break;            break;
310            }            }
311          }          }

Legend:
Removed from v.25  
changed lines
  Added in v.53

  ViewVC Help
Powered by ViewVC 1.1.5