--- parser3/src/main/pa_string.C 2003/04/08 12:47:31 1.172.2.21.2.37 +++ parser3/src/main/pa_string.C 2003/04/08 13:58:30 1.172.2.21.2.38 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_STRING_C="$Date: 2003/04/08 12:47:31 $"; +static const char* IDENT_STRING_C="$Date: 2003/04/08 13:58:30 $"; #include "pcre.h" @@ -42,14 +42,14 @@ void String::ArrayFragment::append_posit if(substr_begin==substr_end) return; - FILE *err=fopen("append.log", "wt"); +// FILE *err=fopen("append.log", "wt"); size_t fragment_begin=0; size_t fragment_end; for(Array_iterator i(src); ; fragment_begin=fragment_end) { const Fragment fragment=i.next(); 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'? if(!(substr_begin>=fragment_begin && substr_begin<=fragment_end)) @@ -63,13 +63,13 @@ void String::ArrayFragment::append_posit while(true) { const Fragment fragment=i.next(); 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? append(Fragment(fragment.lang, fragment.length)); // appending whole fragment else { // no, it was last append(Fragment(fragment.lang, substr_end-fragment_begin)); - fclose(err); + //fclose(err); return; } } @@ -77,7 +77,7 @@ void String::ArrayFragment::append_posit break; } - fclose(err); + //fclose(err); } // StringBody methods @@ -111,24 +111,20 @@ uint StringBody::hash_code() const { 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); } -String::String(String::C cstr, bool tainted): body(CORD_EMPTY) { - append_know_length(cstr, cstr.length, tainted?L_TAINTED:L_CLEAN); +String::String(const String::C cstr, bool tainted): body(CORD_EMPTY) { + append_know_length(cstr.str, cstr.length, tainted?L_TAINTED:L_CLEAN); } String::String(const String& src): body(src.body) { fragments.append(src.fragments); -#ifndef NDEBUG - invariant(); -#endif + ASSERT_STRING_INVARIANT(*this); } String& String::append_know_length(const char* str, size_t known_length, Language lang) { body.append_know_length(str, known_length); fragments+=Fragment(lang, known_length); -#ifndef NDEBUG - invariant(); -#endif + ASSERT_STRING_INVARIANT(*this); return *this; } String& String::append_help_length(const char* str, size_t helper_length, Language lang) { @@ -148,9 +144,7 @@ String& String::append_strdup(const char body.append_strdup_know_length(str, known_length); fragments+=Fragment(lang, known_length); -#ifndef NDEBUG - invariant(); -#endif + ASSERT_STRING_INVARIANT(*this); return *this; } @@ -172,10 +166,7 @@ String& String::mid(size_t substr_begin, // SAPI::log("piece of '%s' from %d to %d is '%s'", //cstr(), substr_begin, substr_end, result.cstr()); -#ifndef NDEBUG - result.invariant(); -#endif - + ASSERT_STRING_INVARIANT(result); return result; } @@ -488,9 +479,7 @@ const String& String::replace(const Dict result.fragments.append_positions(fragments, prematch_begin-old_cstr, current-old_cstr); } -#ifndef NDEBUG - result.invariant(); -#endif + ASSERT_STRING_INVARIANT(result); return result; } @@ -633,8 +622,6 @@ bool String::deserialize(size_t prolog_l body=StringBody(cur, buf_length); } -#ifndef NDEBUG - invariant(); -#endif + ASSERT_STRING_INVARIANT(*this); return true; }