--- parser3/src/main/pa_string.C 2001/07/18 10:06:04 1.94 +++ parser3/src/main/pa_string.C 2001/08/01 12:08:40 1.97 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) */ -static const char *RCSId="$Id: pa_string.C,v 1.94 2001/07/18 10:06:04 parser Exp $"; +static const char *RCSId="$Id: pa_string.C,v 1.97 2001/08/01 12:08:40 parser Exp $"; #include "pa_config_includes.h" @@ -149,6 +149,15 @@ String& String::real_append(STRING_APPEN return *this; } +char String::first_char() const { + if(!fused_rows) + THROW(0, 0, + this, + "getting first char of empty string"); + + return *head.rows[0].item.ptr; +} + uint String::hash_code() const { uint result=0; @@ -329,10 +338,10 @@ int String::cmp(int& partial, const char #ifndef NO_STRING_ORIGIN const Origin& String::origin() const { - if(!fused_rows) - THROW(0, 0, - 0, - "String::origin() of empty string called"); + if(!fused_rows) { + static const Origin empty_origin={"empty string"}; + return empty_origin; + } // determining origin by last appended piece // because first one frequently constant. @@ -493,7 +502,8 @@ bool String::match(const unsigned char * const String& regexp, const String *options, Table **table, - Row_action row_action, void *info) const { + Row_action row_action, void *info, + bool *was_global) const { if(!regexp.size()) THROW(0, 0, @@ -503,6 +513,8 @@ bool String::match(const unsigned char * const char *errptr; int erroffset; int option_bits[2]; regex_options(options?options->cstr():0, option_bits); + if(was_global) + *was_global=option_bits[1]!=0; pcre *code=pcre_compile(pattern, option_bits[0], &errptr, &erroffset, pcre_tables);