--- parser3/src/main/pa_charset.C 2003/01/21 15:51:13 1.33 +++ parser3/src/main/pa_charset.C 2003/01/27 15:35:24 1.33.2.1 @@ -5,9 +5,10 @@ Author: Alexander Petrosyan(http://paf.design.ru) */ -static const char* IDENT_CHARSET_C="$Date: 2003/01/21 15:51:13 $"; +static const char* IDENT_CHARSET_C="$Date: 2003/01/27 15:35:24 $"; #include "pa_charset.h" +#include "pa_globals.h" #ifdef XML #include "libxml/encoding.h" @@ -74,18 +75,18 @@ static void element2case(unsigned char f // methods extern "C" unsigned char pcre_default_tables[]; // pcre/chartables.c -Charset::Charset(Pool& apool, const String& aname, const String *request_file_spec): Pooled(apool), - fname(aname) { +Charset::Charset(Pool& pool, ConstStringPtr aname, ConstStringPtr afile_spec): + fname(aname), + fname_cstr(aname->cstr()) { - char *name_cstr=fname.cstr(); - for(char *c=name_cstr; *c; c++) + for(char *c=fname_cstr; *c; c++) *c = toupper(*c); - if(request_file_spec) { + if(afile_spec) { fisUTF8=false; - loadDefinition(*request_file_spec); + loadDefinition(pool, fname); #ifdef XML - addEncoding(name_cstr); + addEncoding(fname_cstr); #endif } else { fisUTF8=true; @@ -94,17 +95,18 @@ Charset::Charset(Pool& apool, const Stri } #ifdef XML - initTranscoder(&aname, name_cstr); + initTranscoder(fname, fname_cstr); #endif } Charset::~Charset() { + // @todonow unregister encodings #ifdef XML // not deleting transcoder, that's not our business #endif } -void Charset::loadDefinition(const String& request_file_spec) { +void Charset::loadDefinition(Pool& pool, ConstStringPtr afile_spec) { // pcre_tables // lowcase, flipcase, bits digit+word+whitespace, masks @@ -116,7 +118,7 @@ void Charset::loadDefinition(const Strin // charset memset(tables.fromTable, 0, sizeof(tables.fromTable)); - tables.toTable=(Charset_TransRec *)calloc(sizeof(Charset_TransRec)*MAX_CHARSET_UNI_CODES); + tables.toTable=(Charset_TransRec *)pool.calloc(sizeof(Charset_TransRec)*MAX_CHARSET_UNI_CODES); tables.toTableSize=0; // strangly vital tables.toTable[tables.toTableSize].intCh=0; @@ -124,7 +126,7 @@ void Charset::loadDefinition(const Strin tables.toTableSize++; // loading text - char *data=file_read_text(pool(), request_file_spec); + char *data=file_read_text(pool, utf8_charset, afile_spec); // ignore header getrow(&data); @@ -154,7 +156,7 @@ void Charset::loadDefinition(const Strin // charset if(tables.toTableSize>MAX_CHARSET_UNI_CODES) throw Exception("parser.runtime", - &request_file_spec, + afile_spec, "charset must contain not more then %d unicode values", MAX_CHARSET_UNI_CODES); XMLCh unicode=(XMLCh)to_wchar_code(cell); @@ -415,7 +417,7 @@ static int transcodeFromUTF8( default: throw Exception(0, - 0, + Exception::undefined_source, "transcodeFromUTF8 error: wrong trailingBytes value(%d)", trailingBytes); } tmpVal-=gUTFOffsets[trailingBytes]; @@ -430,7 +432,7 @@ static int transcodeFromUTF8( outPtr+=sprintf((char *)outPtr, "&#%d;", tmpVal); // &#decimal; } else throw Exception(0, - 0, + Exception::undefined_source, "transcodeFromUTF8 error: too big tmpVal(0x%08X)", tmpVal); }