--- parser3/src/main/pa_charset.C 2003/09/29 09:42:12 1.38 +++ parser3/src/main/pa_charset.C 2004/02/03 13:09:52 1.46 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan(http://paf.design.ru) */ -static const char* IDENT_CHARSET_C="$Date: 2003/09/29 09:42:12 $"; +static const char * const IDENT_CHARSET_C="$Date: 2004/02/03 13:09:52 $"; #include "pa_charset.h" #include "pa_charsets.h" @@ -14,6 +14,8 @@ static const char* IDENT_CHARSET_C="$Dat #include "libxml/encoding.h" #endif +//#define PA_PATCHED_LIBXML_BACKWARD + // globals Charset::UTF8CaseTable::Rec UTF8CaseToUpperRecords[]={ @@ -117,10 +119,6 @@ void Charset::load_definition(Request_ch // charset memset(&tables, 0, sizeof(tables)); - // strangly vital - tables.toTable[tables.toTableSize].intCh=0; - tables.toTable[tables.toTableSize].extCh=(XMLByte)0; - tables.toTableSize++; // loading text char *data=file_read_text(charsets, afile_spec); @@ -130,7 +128,7 @@ void Charset::load_definition(Request_ch // parse cells char *row; - while(row=getrow(&data)) { + while((row=getrow(&data))) { // remove empty&comment lines if(!*row || *row=='#') continue; @@ -138,7 +136,7 @@ void Charset::load_definition(Request_ch // char white-space digit hex-digit letter word lowercase unicode1 unicode2 unsigned int c=0; char *cell; - for(int column=0; cell=lsplit(&row, '\t'); column++) { + for(int column=0; (cell=lsplit(&row, '\t')); column++) { switch(column) { case 0: c=to_wchar_code(cell); break; // pcre_tables @@ -192,22 +190,20 @@ void Charset::sort_ToTable() { static XMLByte xlatOneTo(const XMLCh toXlat, const Charset::Tables& tables, XMLByte not_found) { - unsigned int lowOfs = 0; - unsigned int hiOfs = tables.toTableSize - 1; - do { + int lo = 0; + int hi = tables.toTableSize - 1; + while(lo<=hi) { // Calc the mid point of the low and high offset. - const unsigned int midOfs =((hiOfs - lowOfs) / 2)+lowOfs; - - // If our test char is greater than the mid point char, then - // we move up to the upper half. Else we move to the lower - // half. If its equal, then its our guy. - if(toXlat>tables.toTable[midOfs].intCh) - lowOfs = midOfs; - else if(toXlatcur) + lo = i+1; else - return tables.toTable[midOfs].extCh; - } while(lowOfs+1table.records[midOfs].from) - lowOfs = midOfs; - else if(srccur) + lo = i+1; else - return table.records[midOfs].to; - } while(lowOfs+1name=name_cstr; handler->input=inputFuncs[handlers_count]; @@ -713,7 +739,11 @@ String::C Charset::transcode_cstr(xmlCha if(xmlCharEncodingOutputFunc output=transcoder(FNAME).output) { error=output( (unsigned char*)out, &outlen, - (const unsigned char*)s, &inlen); + (const unsigned char*)s, &inlen +#ifdef PA_PATCHED_LIBXML_BACKWARD + ,0 +#endif + ); } else { memcpy(out, s, outlen=inlen); error=0; @@ -752,10 +782,14 @@ xmlChar* Charset::transcode_buf2xchar(co #ifndef NDEBUG saved_outlen=outlen; #endif - out=(xmlChar*)xmlMalloc(outlen+1); + out=(xmlChar*)g_malloc(outlen+1); error=input( out, &outlen, - (const unsigned char*)buf, (int*)&buf_size); + (const unsigned char*)buf, (int*)&buf_size +#ifdef PA_PATCHED_LIBXML_BACKWARD + ,0 +#endif + ); } else { outlen=buf_size; #ifndef NDEBUG @@ -825,7 +859,7 @@ struct Transcode_pair_info { const Charset* dest_transcoder; }; #endif -static void transcode_pair(const String::Body akey, +static void transcode_pair(const String::Body /*akey*/, String::Body& avalue, Transcode_pair_info* info) { avalue=Charset::transcode(avalue,