Diff for /parser3/src/main/pa_string.C between versions 1.172.2.21.2.21 and 1.172.2.21.2.30

version 1.172.2.21.2.21, 2003/03/24 11:45:28 version 1.172.2.21.2.30, 2003/03/26 07:45:24
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::Format(int value) {
           char local[MAX_NUMBER];
           size_t length=snprintf(local, MAX_NUMBER, "%d", value);
           return StringBody(pa_strdup(local, length), length);
   }
   
   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 97  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 98  String::String(const char* cstr, size_t Line 109  String::String(const char* cstr, size_t
         append(cstr, helper_length, tainted?L_TAINTED:L_CLEAN);          append(cstr, helper_length, tainted?L_TAINTED:L_CLEAN);
 }  }
   
 String::String(const String& src): body(src.body), fragments(src.fragments) {}  String::String(const String& src): body(src.body) {
           fragments.append(src.fragments);
   }
   
 String& String::append(const char* str, size_t length, Language lang) {  String& String::append(const char* str, size_t length, Language lang) {
         if(!str)          if(!str)
Line 137  String& String::mid(size_t substr_begin, Line 150  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 178  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 202  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 244  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 263  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 278  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 290  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 318  Table* String::match(Charset& source_cha Line 331  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 368  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;
   
Line 368  Table* String::match(Charset& source_cha Line 381  Table* String::match(Charset& source_cha
   
 String& String::change_case(Charset& source_charset, Change_case_kind kind) const {  String& String::change_case(Charset& source_charset, Change_case_kind kind) const {
         String& result=*new String();          String& result=*new String();
           if(is_empty())
                   return result;
   
         const unsigned char *tables=source_charset.pcre_tables;          const unsigned char *tables=source_charset.pcre_tables;
   

Removed from v.1.172.2.21.2.21  
changed lines
  Added in v.1.172.2.21.2.30


E-mail: