diff --git a/ChangeLog b/ChangeLog index 0077f4ef..a6c61a77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu May 13 23:19:00 CEST 2004 Daniel Veillard + + * xmlIO.c xmlsave.c include/libxml/xmlIO.h: second pass on escaping + handling, start to looks better, need to be completed and added + directly at the saving context level. + Thu May 13 10:31:28 CEST 2004 Daniel Veillard * xmlIO.c xmlsave.c include/libxml/xmlIO.h: first pass at refactoring diff --git a/include/libxml/xmlIO.h b/include/libxml/xmlIO.h index bb0de038..9c7dc33a 100644 --- a/include/libxml/xmlIO.h +++ b/include/libxml/xmlIO.h @@ -245,7 +245,8 @@ XMLPUBFUN int XMLCALL const char *str); XMLPUBFUN int XMLCALL xmlOutputBufferWriteEscape (xmlOutputBufferPtr out, - const xmlChar *str); + const xmlChar *str, + xmlCharEncodingOutputFunc escaping); XMLPUBFUN int XMLCALL xmlOutputBufferFlush (xmlOutputBufferPtr out); diff --git a/xmlIO.c b/xmlIO.c index eec1dd69..efc991d3 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -2929,6 +2929,7 @@ xmlEscapeContent(unsigned char* out, int *outlen, * xmlOutputBufferWriteEscape: * @out: a buffered parser output * @str: a zero terminated UTF-8 string + * @escaping: an optional escaping function (or NULL) * * Write the content of the string in the output I/O buffer * This routine escapes the caracters and then handle the I18N @@ -2940,7 +2941,8 @@ xmlEscapeContent(unsigned char* out, int *outlen, * in case of error. */ int -xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str) { +xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str, + xmlCharEncodingOutputFunc escaping) { int nbchars = 0; /* number of chars to output to I/O */ int ret; /* return from function call */ int written = 0; /* number of char written to I/O so far */ @@ -2949,9 +2951,10 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str) { int cons; /* byte from str consumed */ if ((out == NULL) || (out->error) || (str == NULL)) return(-1); - len = strlen(str); + len = strlen((const char *)str); if (len < 0) return(0); if (out->error) return(-1); + if (escaping == NULL) escaping = xmlEscapeContent; do { /* @@ -2970,8 +2973,8 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str) { if (out->conv == NULL) { out->conv = xmlBufferCreate(); } - ret = xmlEscapeContent(out->buffer->content + out->buffer->use , - &chunk, str, &cons); + ret = escaping(out->buffer->content + out->buffer->use , + &chunk, str, &cons); if (ret < 0) return(-1); out->buffer->use += chunk; @@ -2991,8 +2994,8 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str) { } nbchars = out->conv->use; } else { - ret = xmlEscapeContent(out->buffer->content + out->buffer->use , - &chunk, str, &cons); + ret = escaping(out->buffer->content + out->buffer->use , + &chunk, str, &cons); if (ret < 0) return(-1); out->buffer->use += chunk; diff --git a/xmlsave.c b/xmlsave.c index e57e5680..bfaf07b7 100644 --- a/xmlsave.c +++ b/xmlsave.c @@ -481,7 +481,7 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { xmlFree(buffer); } } else { - xmlOutputBufferWriteEscape(buf, cur->content); + xmlOutputBufferWriteEscape(buf, cur->content, NULL); } } else { /* @@ -594,7 +594,7 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { xmlFree(buffer); } } else { - xmlOutputBufferWriteEscape(buf, cur->content); + xmlOutputBufferWriteEscape(buf, cur->content, NULL); } } if (cur->children != NULL) { @@ -941,7 +941,7 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { xmlFree(buffer); } } else { - xmlOutputBufferWriteEscape(buf, cur->content); + xmlOutputBufferWriteEscape(buf, cur->content, NULL); } } else { /* @@ -1068,7 +1068,7 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { xmlFree(buffer); } } else { - xmlOutputBufferWriteEscape(buf, cur->content); + xmlOutputBufferWriteEscape(buf, cur->content, NULL); } }