Diff for /parser3/src/main/pa_string.C between versions 1.172.2.21.2.20 and 1.172.2.21.2.28

version 1.172.2.21.2.20, 2003/03/24 11:22:48 version 1.172.2.21.2.28, 2003/03/25 09:34:53
Line 49  void String::ArrayFragment::append_posit Line 49  void String::ArrayFragment::append_posit
                 const element_type& fragment=i.next();                  const element_type& fragment=i.next();
                 fragment_end=fragment_begin+fragment.length;                              fragment_end=fragment_begin+fragment.length;            
   
                 if(fragment_begin<substr_begin) // not reached fragments which may include 'substr'?                  if(substr_begin<fragment_begin) // not reached fragments which may include 'substr'?
                           continue;
   
                   if(substr_begin>fragment_end) // not reached fragments which may include 'substr'?
                         continue;                          continue;
   
                 // found first fragment including piece of 'substr'                  // found first fragment including piece of 'substr'
Line 73  void String::ArrayFragment::append_posit Line 76  void String::ArrayFragment::append_posit
                 break;                  break;
         }                 }       
 }  }
 /*  
 void String::ArrayFragment::mid(ArrayFragment& result, size_t substr_begin, size_t substr_end) {  
 }  
 */  
   
 // StringSimple methods  // StringBody methods
   
   StringBody::StringBody(int value) {
           char local[MAX_NUMBER];
           body=pa_strdup(local, snprintf(local, MAX_NUMBER, "%d", value));
   }
   
   static int CORD_batched_iter_fn_generic_hash_code(char c, void * client_data) {
           uint& result=*static_cast<uint*>(client_data);
           generic_hash_code(result, c);
           return 0;
   }
 static int CORD_batched_iter_fn_generic_hash_code(const char*  s, void * client_data) {  static int CORD_batched_iter_fn_generic_hash_code(const char*  s, void * client_data) {
         uint& result=*static_cast<uint*>(client_data);          uint& result=*static_cast<uint*>(client_data);
         generic_hash_code(result, s);          generic_hash_code(result, s);
Line 88  static int CORD_batched_iter_fn_generic_ Line 96  static int CORD_batched_iter_fn_generic_
 };  };
 uint StringBody::hash_code() const {  uint StringBody::hash_code() const {
         uint result=0;          uint result=0;
         CORD_iter5(body, 0, 0, CORD_batched_iter_fn_generic_hash_code, &result);          CORD_iter5(body, 0,
                   CORD_batched_iter_fn_generic_hash_code, 
                   CORD_batched_iter_fn_generic_hash_code, &result);
         return result;          return result;
 }  }
   
Line 137  String& String::mid(size_t substr_begin, Line 147  String& String::mid(size_t substr_begin,
 size_t String::pos(const StringBody substr,   size_t String::pos(const StringBody substr, 
                    size_t this_offset, Language lang) const {                     size_t this_offset, Language lang) const {
         // first: letters themselves          // first: letters themselves
         size_t substr_begin=body.pos(this_offset, substr);          size_t substr_begin=body.pos(substr, this_offset);
         if(substr_begin==CORD_NOT_FOUND)          if(substr_begin==CORD_NOT_FOUND)
                 return STRING_NOT_FOUND;                  return STRING_NOT_FOUND;
   
Line 165  size_t String::pos(const StringBody subs Line 175  size_t String::pos(const StringBody subs
                                 "searching for '%s' starting from %ud problem: found begin in one fragment, but end in another",                                  "searching for '%s' starting from %ud problem: found begin in one fragment, but end in another",
                                         substr.cstr(), this_offset);                                          substr.cstr(), this_offset);
   
                 if(fragment.lang==lang)                  if(fragment.lang<=lang)
                         return substr_begin;                          return substr_begin;
                 else { // bad lang...                  else { // bad lang...
                         /// WARNING: this possibly skips assert (*), but it's fast                          /// WARNING: this possibly skips assert (*), but it's fast
                         substr_begin=body.pos(fragment_end/*...search AFTER for more*/, substr);                          substr_begin=body.pos(substr, fragment_end/*...search AFTER for more*/);
                         if(substr_begin==CORD_NOT_FOUND)                          if(substr_begin==CORD_NOT_FOUND)
                                 return STRING_NOT_FOUND;                                  return STRING_NOT_FOUND;
   
Line 189  size_t String::pos(const String& substr, Line 199  size_t String::pos(const String& substr,
 void String::split(ArrayString& result,   void String::split(ArrayString& result, 
                                    size_t& pos_after,                                      size_t& pos_after, 
                                    const char* delim,                                      const char* delim, 
                                    Language lang, int limit) {                                     Language lang, int limit) const {
         size_t self_length=length();          size_t self_length=length();
         if(size_t delim_length=strlen(delim)) {          if(size_t delim_length=strlen(delim)) {
                 int pos_before;                  int pos_before;
Line 231  void String::split(ArrayString& result, Line 241  void String::split(ArrayString& result,
         }          }
 }  }
   
 static void regex_options(const String& options, int *result, bool& need_pre_post_match){  static void regex_options(const String* options, int *result, bool& need_pre_post_match){
     struct Regex_option {      struct Regex_option {
                 const char* keyL;                  const char* keyL;
                 const char* keyU;                  const char* keyU;
Line 250  static void regex_options(const String& Line 260  static void regex_options(const String&
         result[0]=PCRE_EXTRA | PCRE_DOTALL | PCRE_DOLLAR_ENDONLY;          result[0]=PCRE_EXTRA | PCRE_DOTALL | PCRE_DOLLAR_ENDONLY;
         result[1]=0;          result[1]=0;
   
     if(!options.is_empty())       if(options && !options->is_empty()) 
                 for(Regex_option *o=regex_option; o->keyL; o++)                   for(Regex_option *o=regex_option; o->keyL; o++) 
                         if(options.pos(o->keyL)>=0                          if(options->pos(o->keyL)>=0
                                 || (o->keyU && options.pos(o->keyU)>=0)) {                                  || (o->keyU && options->pos(o->keyU)>=0)) {
                                 if(o->flag)                                  if(o->flag)
                                         *o->flag=true;                                          *o->flag=true;
                                 else { // result                                  else { // result
Line 265  static void regex_options(const String& Line 275  static void regex_options(const String&
   
 Table* String::match(Charset& source_charset,  Table* String::match(Charset& source_charset,
                                            const String& regexp,                                              const String& regexp, 
                                            const String& options,                                             const String* options,
                                            Row_action row_action, void *info,                                             Row_action row_action, void *info,
                                            bool& just_matched) const {                                              bool& just_matched) const { 
         if(regexp.is_empty())          if(regexp.is_empty())
Line 277  Table* String::match(Charset& source_cha Line 287  Table* String::match(Charset& source_cha
         const char* errptr;          const char* errptr;
         int erroffset;          int erroffset;
         bool need_pre_post_match=false;          bool need_pre_post_match=false;
         int option_bits[2];  regex_options(options, option_bits, need_pre_post_match);          int option_bits[2]={0};  regex_options(options, option_bits, need_pre_post_match);
         bool global=option_bits[1]!=0;          bool global=option_bits[1]!=0;
         pcre *code=pcre_compile(pattern, option_bits[0],           pcre *code=pcre_compile(pattern, option_bits[0], 
                 &errptr, &erroffset,                  &errptr, &erroffset,
Line 303  Table* String::match(Charset& source_cha Line 313  Table* String::match(Charset& source_cha
         int ovector[oveclength];          int ovector[oveclength];
   
         // create table          // create table
         Table* table=new Table(string_match_table_template);          Table& table=*new Table(string_match_table_template);
   
         int exec_option_bits=0;          int exec_option_bits=0;
         int prestart=0;          int prestart=0;
Line 318  Table* String::match(Charset& source_cha Line 328  Table* String::match(Charset& source_cha
                         pcre_free(code);                          pcre_free(code);
                         row_action(table, 0/*last time, no raw*/, 0, 0, poststart, postfinish, info);                          row_action(table, 0/*last time, no raw*/, 0, 0, poststart, postfinish, info);
                         if(global || subpatterns)                          if(global || subpatterns)
                                 return table; // global or with subpatterns=true+result                                  return &table; // global or with subpatterns=true+result
                         else {                          else {
                                 just_matched=false; return 0; // not global=no result                                  just_matched=false; return 0; // not global=no result
                         }                          }
Line 355  Table* String::match(Charset& source_cha Line 365  Table* String::match(Charset& source_cha
                 if(!global || prestart==poststart) { // not global | going to hang                  if(!global || prestart==poststart) { // not global | going to hang
                         pcre_free(code);                          pcre_free(code);
                         row_action(table, 0/*last time, no row*/, 0, 0, poststart, postfinish, info);                          row_action(table, 0/*last time, no row*/, 0, 0, poststart, postfinish, info);
                         return table;                          return &table;
                 }                  }
                 prestart=poststart;                  prestart=poststart;
   

Removed from v.1.172.2.21.2.20  
changed lines
  Added in v.1.172.2.21.2.28


E-mail: