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

Diff of /code/trunk/pcre_dfa_exec.c

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

revision 97 by ph10, Mon Mar 5 12:36:47 2007 UTC revision 151 by ph10, Tue Apr 17 15:07:29 2007 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-2006 University of Cambridge             Copyright (c) 1997-2007 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 500  for (;;) Line 500  for (;;)
500      const uschar *code;      const uschar *code;
501      int state_offset = current_state->offset;      int state_offset = current_state->offset;
502      int count, codevalue;      int count, codevalue;
503    #ifdef SUPPORT_UCP
504      int chartype, script;      int chartype, script;
505    #endif
506    
507  #ifdef DEBUG  #ifdef DEBUG
508      printf ("%.*sProcessing state %d c=", rlevel*2-2, SP, state_offset);      printf ("%.*sProcessing state %d c=", rlevel*2-2, SP, state_offset);
# Line 783  for (;;) Line 785  for (;;)
785        break;        break;
786    
787    
 #ifdef SUPPORT_UCP  
   
788        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
789        /* Check the next character by Unicode property. We will get here only        /* Check the next character by Unicode property. We will get here only
790        if the support is in the binary; otherwise a compile-time error occurs.        if the support is in the binary; otherwise a compile-time error occurs.
791        */        */
792    
793    #ifdef SUPPORT_UCP
794        case OP_PROP:        case OP_PROP:
795        case OP_NOTPROP:        case OP_NOTPROP:
796        if (clen > 0)        if (clen > 0)
# Line 970  for (;;) Line 971  for (;;)
971        argument. It keeps the code above fast for the other cases. The argument        argument. It keeps the code above fast for the other cases. The argument
972        is in the d variable. */        is in the d variable. */
973    
974    #ifdef SUPPORT_UCP
975        case OP_PROP_EXTRA + OP_TYPEPLUS:        case OP_PROP_EXTRA + OP_TYPEPLUS:
976        case OP_PROP_EXTRA + OP_TYPEMINPLUS:        case OP_PROP_EXTRA + OP_TYPEMINPLUS:
977        case OP_PROP_EXTRA + OP_TYPEPOSPLUS:        case OP_PROP_EXTRA + OP_TYPEPOSPLUS:
# Line 1049  for (;;) Line 1051  for (;;)
1051          ADD_NEW_DATA(-state_offset, count, ncount);          ADD_NEW_DATA(-state_offset, count, ncount);
1052          }          }
1053        break;        break;
1054    #endif
1055    
1056        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
1057        case OP_ANYNL_EXTRA + OP_TYPEPLUS:        case OP_ANYNL_EXTRA + OP_TYPEPLUS:
# Line 1085  for (;;) Line 1088  for (;;)
1088        break;        break;
1089    
1090        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
1091    #ifdef SUPPORT_UCP
1092        case OP_PROP_EXTRA + OP_TYPEQUERY:        case OP_PROP_EXTRA + OP_TYPEQUERY:
1093        case OP_PROP_EXTRA + OP_TYPEMINQUERY:        case OP_PROP_EXTRA + OP_TYPEMINQUERY:
1094        case OP_PROP_EXTRA + OP_TYPEPOSQUERY:        case OP_PROP_EXTRA + OP_TYPEPOSQUERY:
# Line 1182  for (;;) Line 1186  for (;;)
1186          ADD_NEW_DATA(-(state_offset + count), 0, ncount);          ADD_NEW_DATA(-(state_offset + count), 0, ncount);
1187          }          }
1188        break;        break;
1189    #endif
1190    
1191        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
1192        case OP_ANYNL_EXTRA + OP_TYPEQUERY:        case OP_ANYNL_EXTRA + OP_TYPEQUERY:
# Line 1226  for (;;) Line 1231  for (;;)
1231        break;        break;
1232    
1233        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
1234    #ifdef SUPPORT_UCP
1235        case OP_PROP_EXTRA + OP_TYPEEXACT:        case OP_PROP_EXTRA + OP_TYPEEXACT:
1236        case OP_PROP_EXTRA + OP_TYPEUPTO:        case OP_PROP_EXTRA + OP_TYPEUPTO:
1237        case OP_PROP_EXTRA + OP_TYPEMINUPTO:        case OP_PROP_EXTRA + OP_TYPEMINUPTO:
# Line 1313  for (;;) Line 1319  for (;;)
1319            { ADD_NEW_DATA(-state_offset, count, ncount); }            { ADD_NEW_DATA(-state_offset, count, ncount); }
1320          }          }
1321        break;        break;
1322    #endif
1323    
1324        /*-----------------------------------------------------------------*/        /*-----------------------------------------------------------------*/
1325        case OP_ANYNL_EXTRA + OP_TYPEEXACT:        case OP_ANYNL_EXTRA + OP_TYPEEXACT:
# Line 2073  Returns: > 0 => number of match Line 2080  Returns: > 0 => number of match
2080                   < -1 => some kind of unexpected problem                   < -1 => some kind of unexpected problem
2081  */  */
2082    
2083  PCRE_DATA_SCOPE int  PCRE_EXP_DEFN int
2084  pcre_dfa_exec(const pcre *argument_re, const pcre_extra *extra_data,  pcre_dfa_exec(const pcre *argument_re, const pcre_extra *extra_data,
2085    const char *subject, int length, int start_offset, int options, int *offsets,    const char *subject, int length, int start_offset, int options, int *offsets,
2086    int offsetcount, int *workspace, int wscount)    int offsetcount, int *workspace, int wscount)
# Line 2166  md->poptions = re->options; Line 2173  md->poptions = re->options;
2173  /* Handle different types of newline. The three bits give eight cases. If  /* Handle different types of newline. The three bits give eight cases. If
2174  nothing is set at run time, whatever was used at compile time applies. */  nothing is set at run time, whatever was used at compile time applies. */
2175    
2176  switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : options) &  switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options : (pcre_uint32)options) &
2177           PCRE_NEWLINE_BITS)           PCRE_NEWLINE_BITS)
2178    {    {
2179    case 0: newline = NEWLINE; break;   /* Compile-time default */    case 0: newline = NEWLINE; break;   /* Compile-time default */
# Line 2175  switch ((((options & PCRE_NEWLINE_BITS) Line 2182  switch ((((options & PCRE_NEWLINE_BITS)
2182    case PCRE_NEWLINE_CR+    case PCRE_NEWLINE_CR+
2183         PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;         PCRE_NEWLINE_LF: newline = ('\r' << 8) | '\n'; break;
2184    case PCRE_NEWLINE_ANY: newline = -1; break;    case PCRE_NEWLINE_ANY: newline = -1; break;
2185      case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
2186    default: return PCRE_ERROR_BADNEWLINE;    default: return PCRE_ERROR_BADNEWLINE;
2187    }    }
2188    
2189  if (newline < 0)  if (newline == -2)
2190      {
2191      md->nltype = NLTYPE_ANYCRLF;
2192      }
2193    else if (newline < 0)
2194    {    {
2195    md->nltype = NLTYPE_ANY;    md->nltype = NLTYPE_ANY;
2196    }    }
# Line 2308  for (;;) Line 2320  for (;;)
2320          {          {
2321          while (current_subject <= end_subject && !WAS_NEWLINE(current_subject))          while (current_subject <= end_subject && !WAS_NEWLINE(current_subject))
2322            current_subject++;            current_subject++;
2323    
2324            /* If we have just passed a CR and the newline option is ANY or
2325            ANYCRLF, and we are now at a LF, advance the match position by one more
2326            character. */
2327    
2328            if (current_subject[-1] == '\r' &&
2329                 (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&
2330                 current_subject < end_subject &&
2331                 *current_subject == '\n')
2332              current_subject++;
2333          }          }
2334        }        }
2335    
# Line 2416  for (;;) Line 2438  for (;;)
2438      }      }
2439    if (current_subject > end_subject) break;    if (current_subject > end_subject) break;
2440    
2441    /* If we have just passed a CR and the newline option is CRLF or ANY, and we    /* If we have just passed a CR and the newline option is CRLF or ANY or
2442    are now at a LF, advance the match position by one more character. */    ANYCRLF, and we are now at a LF, advance the match position by one more
2443      character. */
2444    
2445    if (current_subject[-1] == '\r' &&    if (current_subject[-1] == '\r' &&
2446         (md->nltype == NLTYPE_ANY || md->nllen == 2) &&         (md->nltype == NLTYPE_ANY ||
2447            md->nltype == NLTYPE_ANYCRLF ||
2448            md->nllen == 2) &&
2449         current_subject < end_subject &&         current_subject < end_subject &&
2450         *current_subject == '\n')         *current_subject == '\n')
2451      current_subject++;      current_subject++;

Legend:
Removed from v.97  
changed lines
  Added in v.151

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12