Author: stsp
Date: Sat Jun 11 08:48:24 2011
New Revision: 1134553
URL: http://svn.apache.org/viewvc?rev=1134553&view=rev
Log:
Make it possible to add encoding information to XML headers.
* subversion/include/svn_xml.h
(svn_xml_make_header2): Declare.
(svn_xml_make_header): Deprecate.
* subversion/libsvn_subr/deprecated.c
(svn_xml_make_header): Moved to here from libsvn_subr/xml.c.
* subversion/libsvn_subr/xml.c
(svn_xml_make_header2): New. Like svn_xml_make_header() but also accepts
an ENCODING parameter which, if not NULL, specifies the name of the
encoding of the document and causes an 'encoding' attribute in the header.
Modified:
subversion/trunk/subversion/include/svn_xml.h
subversion/trunk/subversion/libsvn_subr/deprecated.c
subversion/trunk/subversion/libsvn_subr/xml.c
Modified: subversion/trunk/subversion/include/svn_xml.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_xml.h?rev=1134553&r1=1134552&r2=1134553&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_xml.h (original)
+++ subversion/trunk/subversion/include/svn_xml.h Sat Jun 11 08:48:24 2011
@@ -281,14 +281,25 @@ svn_xml_hash_atts_overlaying(const char
*
* Fully-formed XML documents should start out with a header,
* something like <pre>
- * \<?xml version="1.0" encoding="utf-8"?\>
+ * \<?xml version="1.0" encoding="UTF-8"?\>
* </pre>
*
* This function returns such a header. @a *str must either be @c NULL, in
* which case a new string is created, or it must point to an existing
- * string to be appended to.
+ * string to be appended to. @a encoding must either be NULL, in which case
+ * encoding information is omitted from the header, or must be the name of
+ * the encoding of the XML document, such as "UTF-8".
+ *
+ * @since New in 1.7.
*/
void
+svn_xml_make_header2(svn_stringbuf_t **str,
+ const char *encoding,
+ apr_pool_t *pool);
+
+/* Like svn_xml_make_header2, but does not emit encoding information. */
+SVN_DEPRECATED
+void
svn_xml_make_header(svn_stringbuf_t **str,
apr_pool_t *pool);
Modified: subversion/trunk/subversion/libsvn_subr/deprecated.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/deprecated.c?rev=1134553&r1=1134552&r2=1134553&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_subr/deprecated.c Sat Jun 11 08:48:24
2011
@@ -39,6 +39,7 @@
#include "svn_pools.h"
#include "svn_dso.h"
#include "svn_mergeinfo.h"
+#include "svn_xml.h"
#include "opt.h"
#include "private/svn_opt_private.h"
@@ -1119,3 +1120,9 @@ svn_opt__eat_peg_revisions(apr_array_hea
return SVN_NO_ERROR;
}
#endif
+
+void
+svn_xml_make_header(svn_stringbuf_t **str, apr_pool_t *pool)
+{
+ svn_xml_make_header2(str, NULL, pool);
+}
Modified: subversion/trunk/subversion/libsvn_subr/xml.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/xml.c?rev=1134553&r1=1134552&r2=1134553&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/xml.c (original)
+++ subversion/trunk/subversion/libsvn_subr/xml.c Sat Jun 11 08:48:24 2011
@@ -474,12 +474,19 @@ svn_xml_get_attr_value(const char *name,
/*** Printing XML ***/
void
-svn_xml_make_header(svn_stringbuf_t **str, apr_pool_t *pool)
+svn_xml_make_header2(svn_stringbuf_t **str, const char *encoding,
+ apr_pool_t *pool)
{
+
if (*str == NULL)
*str = svn_stringbuf_create("", pool);
- svn_stringbuf_appendcstr(*str,
- "<?xml version=\"1.0\"?>\n");
+ svn_stringbuf_appendcstr(*str, "<?xml version=\"1.0\"");
+ if (encoding)
+ {
+ encoding = apr_psprintf(pool, " encoding=\"%s\"", encoding);
+ svn_stringbuf_appendcstr(*str, encoding);
+ }
+ svn_stringbuf_appendcstr(*str, "?>\n");
}