--- parser3/src/main/pa_string.C 2002/04/10 08:53:55 1.151 +++ parser3/src/main/pa_string.C 2002/04/19 07:59:51 1.153 @@ -4,7 +4,7 @@ Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - $Id: pa_string.C,v 1.151 2002/04/10 08:53:55 paf Exp $ + $Id: pa_string.C,v 1.153 2002/04/19 07:59:51 paf Exp $ */ #include "pcre.h" @@ -70,8 +70,7 @@ void String::expand() { if(new_chunk_count>max_integral(Chunk::count_type)) new_chunk_count=max_integral(Chunk::count_type); - Chunk *new_chunk=static_cast( - malloc( + Chunk *new_chunk=static_cast(malloc( sizeof(Chunk)// count+interpadding(?)+rows[CR_PREALLOCATED_COUNT]+tailpadding(??) -sizeof(Chunk::rows_type) // PREALLOCATED rows +sizeof(Chunk::Row)*new_chunk_count // neaded rows @@ -442,27 +441,28 @@ void String::split(Array& result, } } -static void regex_options(char *options, int *result){ +static void regex_options(const String *options, int *result){ struct Regex_option { - char key; + const char *keyL; + const char *keyU; int clear, set; int *result; } regex_option[]={ - {'i', 0, PCRE_CASELESS, result}, // a=A - {'s', 0, PCRE_DOTALL, result}, // \n\n$ [default] - {'x', 0, PCRE_EXTENDED, result}, // whitespace in regex ignored - {'m', PCRE_DOTALL, PCRE_MULTILINE, result}, // ^aaa\n$^bbb\n$ - {'g', 0, true, result+1}, // many rows + {"i", "I", 0, PCRE_CASELESS, result}, // a=A + {"s", "S", 0, PCRE_DOTALL, result}, // \n\n$ [default] + {"x", "U", 0, PCRE_EXTENDED, result}, // whitespace in regex ignored + {"m", "M", PCRE_DOTALL, PCRE_MULTILINE, result}, // ^aaa\n$^bbb\n$ + {"g", "G", 0, true, result+1}, // many rows {0}, }; result[0]=PCRE_EXTRA | PCRE_DOTALL; result[1]=0; if(options) - for(Regex_option *o=regex_option; o->key; o++) + for(Regex_option *o=regex_option; o->keyL; o++) if( - strchr(options, o->key) || - strchr(options, toupper(o->key))) { + options->pos(o->keyL)>=0 || + options->pos(o->keyU)>=0) { *(o->result)&=~o->clear; *(o->result)|=o->set; } @@ -484,7 +484,7 @@ bool String::match( const char *pattern=regexp.cstr(); const char *errptr; int erroffset; - int option_bits[2]; regex_options(options?options->cstr():0, option_bits); + int option_bits[2]; regex_options(options, option_bits); if(was_global) *was_global=option_bits[1]!=0; pcre *code=pcre_compile(pattern, option_bits[0],