Diff for /parser3/src/main/pa_string.C between versions 1.172.2.21.2.37 and 1.172.2.21.2.41

version 1.172.2.21.2.37, 2003/04/08 12:47:31 version 1.172.2.21.2.41, 2003/04/21 07:07:45
Line 42  void String::ArrayFragment::append_posit Line 42  void String::ArrayFragment::append_posit
         if(substr_begin==substr_end)          if(substr_begin==substr_end)
                 return;                  return;
   
         FILE *err=fopen("append.log", "wt");  //      FILE *err=fopen("append.log", "wt");
   
         size_t fragment_begin=0;          size_t fragment_begin=0;
         size_t fragment_end;          size_t fragment_end;
         for(Array_iterator<element_type> i(src); ; fragment_begin=fragment_end) {          for(Array_iterator<element_type> i(src); ; fragment_begin=fragment_end) {
                 const Fragment fragment=i.next();                  const Fragment fragment=i.next();
                 fragment_end=fragment_begin+fragment.length;                              fragment_end=fragment_begin+fragment.length;            
                 fprintf(err, "1end=%u\n", fragment_end);fflush(err);                  //fprintf(err, "1end=%u\n", fragment_end);fflush(err);
   
                 // not reached fragments which may include 'substr'?                  // not reached fragments which may include 'substr'?
                 if(!(substr_begin>=fragment_begin && substr_begin<=fragment_end))                  if(!(substr_begin>=fragment_begin && substr_begin<fragment_end))
                         continue;                          continue;
   
                 // found first fragment including piece of 'substr'                  // found first fragment including piece of 'substr'
Line 63  void String::ArrayFragment::append_posit Line 63  void String::ArrayFragment::append_posit
                         while(true) {                          while(true) {
                                 const Fragment fragment=i.next();                                  const Fragment fragment=i.next();
                                 fragment_end=(fragment_begin=fragment_end)+fragment.length;                                  fragment_end=(fragment_begin=fragment_end)+fragment.length;
                                 fprintf(err, "2end=%u\n", fragment_end);fflush(err);                                  //fprintf(err, "2end=%u\n", fragment_end);fflush(err);
   
                                 if(substr_end>fragment_end) // are there still more?                                  if(substr_end>fragment_end) // are there still more?
                                         append(Fragment(fragment.lang, fragment.length)); // appending whole fragment                                          append(Fragment(fragment.lang, fragment.length)); // appending whole fragment
                                 else { // no, it was last                                  else { // no, it was last
                                         append(Fragment(fragment.lang, substr_end-fragment_begin));                                          append(Fragment(fragment.lang, substr_end-fragment_begin));
                                         fclose(err);                                          //fclose(err);
                                         return;                                          return;
                                 }                                  }
                         }                          }
Line 77  void String::ArrayFragment::append_posit Line 77  void String::ArrayFragment::append_posit
   
                 break;                  break;
         }          }
         fclose(err);          //fclose(err);
 }  }
   
 // StringBody methods  // StringBody methods
Line 111  uint StringBody::hash_code() const { Line 111  uint StringBody::hash_code() const {
 String::String(const char* cstr, size_t helper_length, bool tainted): body(CORD_EMPTY) {  String::String(const char* cstr, size_t helper_length, bool tainted): body(CORD_EMPTY) {
         append_help_length(cstr, helper_length, tainted?L_TAINTED:L_CLEAN);          append_help_length(cstr, helper_length, tainted?L_TAINTED:L_CLEAN);
 }  }
 String::String(String::C cstr, bool tainted): body(CORD_EMPTY) {  String::String(const String::C cstr, bool tainted): body(CORD_EMPTY) {
         append_know_length(cstr, cstr.length, tainted?L_TAINTED:L_CLEAN);          append_know_length(cstr.str, cstr.length, tainted?L_TAINTED:L_CLEAN);
 }  }
   
 String::String(const String& src): body(src.body) {  String::String(const String& src): body(src.body) {
         fragments.append(src.fragments);          fragments.append(src.fragments);
 #ifndef NDEBUG          ASSERT_STRING_INVARIANT(*this);
         invariant();  
 #endif  
 }  }
   
 String& String::append_know_length(const char* str, size_t known_length, Language lang) {  String& String::append_know_length(const char* str, size_t known_length, Language lang) {
           if(!known_length || !*str)
                   return *this;
   
         body.append_know_length(str, known_length);          body.append_know_length(str, known_length);
         fragments+=Fragment(lang, known_length);          fragments+=Fragment(lang, known_length);
   
 #ifndef NDEBUG          ASSERT_STRING_INVARIANT(*this);
         invariant();  
 #endif  
         return *this;          return *this;
 }  }
 String& String::append_help_length(const char* str, size_t helper_length, Language lang) {  String& String::append_help_length(const char* str, size_t helper_length, Language lang) {
Line 148  String& String::append_strdup(const char Line 147  String& String::append_strdup(const char
         body.append_strdup_know_length(str, known_length);          body.append_strdup_know_length(str, known_length);
         fragments+=Fragment(lang, known_length);          fragments+=Fragment(lang, known_length);
   
 #ifndef NDEBUG          ASSERT_STRING_INVARIANT(*this);
         invariant();  
 #endif  
         return *this;          return *this;
 }  }
   
Line 172  String& String::mid(size_t substr_begin, Line 169  String& String::mid(size_t substr_begin,
   
 //      SAPI::log("piece of '%s' from %d to %d is '%s'",  //      SAPI::log("piece of '%s' from %d to %d is '%s'",
                 //cstr(), substr_begin, substr_end, result.cstr());                  //cstr(), substr_begin, substr_end, result.cstr());
 #ifndef NDEBUG          ASSERT_STRING_INVARIANT(result);
         result.invariant();  
 #endif  
   
         return result;          return result;
 }  }
   
Line 232  size_t String::pos(const String& substr, Line 226  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) const {                     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 255  void String::split(ArrayString& result, Line 249  void String::split(ArrayString& result,
 }  }
   
 void String::split(ArrayString& result,   void String::split(ArrayString& result, 
                                    size_t& pos_after,                      size_t& pos_after, 
                                    const String& delim, Language lang,                      const String& delim, Language lang, 
                                    int limit) const {                     int limit) const {
         if(!delim.is_empty()) {          if(!delim.is_empty()) {
                 int pos_before;                  int pos_before;
                 // while we have 'delim'...                  // while we have 'delim'...
Line 309  static void regex_options(const String* Line 303  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())
                 throw Exception(0,                  throw Exception(0,
                         0,                          0,
Line 348  Table* String::match(Charset& source_cha Line 342  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::Action_options table_options;
           Table& table=*new Table(string_match_table_template, table_options);
   
         int exec_option_bits=0;          int exec_option_bits=0;
         int prestart=0;          int prestart=0;
Line 488  const String& String::replace(const Dict Line 483  const String& String::replace(const Dict
                 result.fragments.append_positions(fragments, prematch_begin-old_cstr, current-old_cstr);                  result.fragments.append_positions(fragments, prematch_begin-old_cstr, current-old_cstr);
         }          }
   
 #ifndef NDEBUG          ASSERT_STRING_INVARIANT(result);
         result.invariant();  
 #endif  
         return result;          return result;
 }  }
   
Line 633  bool String::deserialize(size_t prolog_l Line 626  bool String::deserialize(size_t prolog_l
                 body=StringBody(cur, buf_length);                  body=StringBody(cur, buf_length);
         }          }
   
 #ifndef NDEBUG          ASSERT_STRING_INVARIANT(*this);
         invariant();  
 #endif  
         return true;          return true;
 }  }

Removed from v.1.172.2.21.2.37  
changed lines
  Added in v.1.172.2.21.2.41


E-mail: