--- parser3/src/main/pa_request.C 2001/09/30 12:06:04 1.159 +++ parser3/src/main/pa_request.C 2001/09/30 14:36:26 1.162 @@ -4,7 +4,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_request.C,v 1.159 2001/09/30 12:06:04 parser Exp $ + $Id: pa_request.C,v 1.162 2001/09/30 14:36:26 parser Exp $ */ #include "pa_config_includes.h" @@ -31,6 +31,7 @@ extern "C" unsigned char pcre_default_ta # include # include # include +# include #endif /// content type of exception response, when no @MAIN:exception handler defined @@ -91,7 +92,7 @@ static void element2case(unsigned char f } #ifndef DOXYGEN -struct CTYPE_Tables { +struct Charset_tables { // pcre_tables unsigned char *pcre_tables; #ifdef XML @@ -103,9 +104,9 @@ struct CTYPE_Tables { }; #endif -static void ctype_table_row_to_CTYPE_tables(Array::Item *value, void *info) { +static void ctype_table_row_to_charset_tables(Array::Item *value, void *info) { Array& row=*static_cast(value); - CTYPE_Tables& tables=*static_cast(info); + Charset_tables& tables=*static_cast(info); // char white-space digit hex-digit letter word lowercase unicode1 unicode2 unsigned int c=to_wchar_code(row.get_string(0)); @@ -121,6 +122,8 @@ static void ctype_table_row_to_CTYPE_tab #ifdef XML XMLCh unicode1=row.size()>7?(XMLCh)to_wchar_code(row.get_string(7)):0; XMLCh unicode2=row.size()>8?(XMLCh)to_wchar_code(row.get_string(8)):0; + if(!tables.fromTable[c]) + tables.fromTable[c]=unicode1?unicode1:(XMLCh)c; tables.toTable[tables.toTableSz].intCh=unicode1?unicode1:(XMLCh)c; tables.toTable[tables.toTableSz].extCh=(XMLByte)c; tables.toTableSz++; @@ -204,12 +207,31 @@ private : }; #endif -static void load_ctype_for_charset(const Hash::Key& akey, Hash::Val *avalue, +#ifdef XALAN_HACK_DIGITAL_ENTITIES +static void hack_s_maximumCharacterValues(const XalanDOMString& encoding) { +/* + open: + xml-xalan/c/src/PlatformSupport/XalanTranscodingServices.hpp + find: + static const MaximumCharacterValueMapType& s_maximumCharacterValues; + paste to next line: + friend static void hack_s_maximumCharacterValues(const XalanDOMString& encoding); // hack by paf +*/ + + /* + const_cast( + XalanTranscodingServices::s_maximumCharacterValues).insert( + XalanTranscodingServices::MaximumCharacterValueMapType::value_type(encoding, 0xFFFF)); + */ +} +#endif + +static void load_charset(const Hash::Key& akey, Hash::Val *avalue, void *info) { Hash& CTYPE=*static_cast(info); Pool& pool=CTYPE.pool(); - CTYPE_Tables tables={ + Charset_tables tables={ // pcre_tables // lowcase, flipcase, bits digit+word+whitespace, masks (unsigned char *)pool.calloc(tables_length) // pcre_tables @@ -230,7 +252,7 @@ static void load_ctype_for_charset(const tables.toTable=(XMLTransService::TransRec *)pool.calloc( sizeof(XMLTransService::TransRec)*table->size()*2); #endif - table->for_each(ctype_table_row_to_CTYPE_tables, &tables); + table->for_each(ctype_table_row_to_charset_tables, &tables); #ifdef XML // sort by the Unicode code point _qsort(tables.toTable, tables.toTableSz, sizeof(*tables.toTable), @@ -246,9 +268,12 @@ static void load_ctype_for_charset(const #ifdef XML // charset->transcoder - XalanDOMString skey(akey.cstr()); - const XMLCh* const auto_encoding_cstr=skey.c_str(); - int size=sizeof(XMLCh)*(skey.size()+1); + XalanDOMString sencoding(akey.cstr()); +#ifdef XALAN_HACK_DIGITAL_ENTITIES + hack_s_maximumCharacterValues(sencoding); +#endif + const XMLCh* const auto_encoding_cstr=sencoding.c_str(); + int size=sizeof(XMLCh)*(sencoding.size()+1); XMLCh* pool_encoding_cstr=(XMLCh*)malloc(size); memcpy(pool_encoding_cstr, auto_encoding_cstr, size); XMLString::upperCase(pool_encoding_cstr); @@ -261,7 +286,6 @@ static void load_ctype_for_charset(const , tables.toTable , tables.toTableSz )); - // delete sencoding; somehow #endif } @@ -420,12 +444,12 @@ void Request::core( if(Table *table=element->get_table()) mime_types=table; - if(Value *vctype=main_class->get_element(*ctype_name)) { - if(Hash *ctype=vctype->get_hash()) - ctype->for_each(load_ctype_for_charset, &CTYPE); + if(Value *vcharsets=main_class->get_element(*charsets_name)) { + if(Hash *charsets=vcharsets->get_hash()) + charsets->for_each(load_charset, &CTYPE); else THROW(0, 0, - &vctype->name(), + &vcharsets->name(), "must be hash"); }