--- parser3/src/main/pa_charset.C 2002/02/27 16:37:38 1.21 +++ parser3/src/main/pa_charset.C 2002/06/28 09:59:01 1.24 @@ -4,7 +4,7 @@ Copyright(c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan(http://paf.design.ru) - $Id: pa_charset.C,v 1.21 2002/02/27 16:37:38 paf Exp $ + $Id: pa_charset.C,v 1.24 2002/06/28 09:59:01 paf Exp $ */ #include "pa_charset.h" @@ -153,7 +153,7 @@ void Charset::loadDefinition(const Strin case 8: // charset if(tables.toTableSize>MAX_CHARSET_UNI_CODES) - throw Exception(0, 0, + throw Exception("parser.runtime", &request_file_spec, "charset must contain not more then %d unicode values", MAX_CHARSET_UNI_CODES); @@ -404,7 +404,7 @@ static size_t transcodeFromUTF8( break; default: - throw Exception(0, 0, + throw Exception(0, 0, "transcodeFromUTF8 error: wrong trailingBytes value(%d)", trailingBytes); } @@ -416,7 +416,7 @@ static size_t transcodeFromUTF8( if(!(tmpVal & 0xFFFF0000)) *outPtr++= xlatOneTo(tmpVal, tables); else - throw Exception(0, 0, + throw Exception(0, 0, "transcodeFromUTF8 error: too big tmpVal(0x%08X)", tmpVal); } @@ -448,7 +448,6 @@ void Charset::transcodeToUTF8(Pool& pool // return adest_body=dest_body; } -/// @test buf overflow void Charset::transcodeFromUTF8(Pool& pool, const void *source_body, size_t source_content_length, const void *& adest_body, size_t& dest_content_length) const { @@ -540,7 +539,7 @@ void Charset::initTranscoder(const Strin xmlCharEncodingHandler *Charset::transcoder(const String *source) { if(!ftranscoder) - throw Exception(0, 0, + throw Exception("parser.runtime", source, "unsupported encoding"); return ftranscoder; @@ -563,7 +562,7 @@ const char *Charset::transcode_cstr(xmlC } else memcpy(out, s, size=inlen); if(size<0) - throw Exception(0, 0, + throw Exception(0, 0, "transcode_cstr failed (%d)", size); @@ -581,7 +580,7 @@ String& Charset::transcode(GdomeDOMStrin } /// @test less memory using -maybe- xmlParserInputBufferCreateMem -GdomeDOMString_auto_ptr Charset::transcode_buf(const char *buf, size_t buf_size) { +xmlChar *Charset::transcode_buf2xchar(const char *buf, size_t buf_size) { int outlen=buf_size*6/*max*/+1; unsigned char *out=(unsigned char*)malloc(outlen*sizeof(unsigned char)); @@ -595,16 +594,19 @@ GdomeDOMString_auto_ptr Charset::transco memcpy(out, buf, size=buf_size); if(size<0) - throw Exception(0, 0, + throw Exception(0, 0, "transcode_buf failed (%d)", size); out[size]=0; - return GdomeDOMString_auto_ptr((gchar*)out); + return (xmlChar *)out; +} +GdomeDOMString_auto_ptr Charset::transcode_buf2dom(const char *buf, size_t buf_size) { + return GdomeDOMString_auto_ptr((gchar*)transcode_buf2xchar(buf, buf_size)); } GdomeDOMString_auto_ptr Charset::transcode(const String& s) { const char *cstr=s.cstr(String::UL_UNSPECIFIED); - return transcode_buf(cstr, strlen(cstr)); + return transcode_buf2dom(cstr, strlen(cstr)); } #endif