[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Fix compilation warning with Expat 2

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: Sun, 27 Jan 2008 00:09:58 +0000

Hi Arfrever.

Thanks for the report and the patch and your persistence. I agree your patch is
correct. However, I committed the following alternative fix in r29057, which
avoids an explicit dependency on particular versions of Expat, and has only one
copy of the error message for translators to maintain.

I tested it by compiling with the function redefined manually to return various
types, and looking for the warning to go away with all reasonable integer
types. (I have Expat v1 installed.)

Let me know if there is any problem with this solution, of course.

[[[
Index: subversion/libsvn_subr/xml.c
===================================================================
--- subversion/libsvn_subr/xml.c (revision 29055)
+++ subversion/libsvn_subr/xml.c (working copy)
@@ -395,11 +395,13 @@
    /* If expat choked internally, return its error. */
    if (! success)
      {
+ /* Line num is "int" in Expat v1, "long" in v2; hide the difference. */
+ long line = XML_GetCurrentLineNumber(svn_parser->parser);
+
        err = svn_error_createf
          (SVN_ERR_XML_MALFORMED, NULL,
- _("Malformed XML: %s at line %d"),
- XML_ErrorString(XML_GetErrorCode(svn_parser->parser)),
- XML_GetCurrentLineNumber(svn_parser->parser));
+ _("Malformed XML: %s at line %ld"),
+ XML_ErrorString(XML_GetErrorCode(svn_parser->parser)), line);

        /* Kill all parsers and return the expat error */
        svn_xml_free_parser(svn_parser);
]]]

Regards,
- Julian

Arfrever Frehtes Taifersar Arahesis wrote:
> [[[
> Fix compilation warning with Expat 2.
>
> * subversion/libsvn_subr/xml.c
> (svn_xml_parse): When creating error messages, use format specifier
> conditionalized on the version of Expat.
>
> Patch by: markphip
> arfrever
> ]]]
>
> The patch is here:
> http://svn.haxx.se/dev/archive-2007-12/0766.shtml

For quick reference:
> Index: subversion/libsvn_subr/xml.c
> ===================================================================
> --- subversion/libsvn_subr/xml.c (revision 29055)
> +++ subversion/libsvn_subr/xml.c (working copy)
> @@ -397,7 +397,11 @@
> {
> err = svn_error_createf
> (SVN_ERR_XML_MALFORMED, NULL,
> +#if XML_MAJOR_VERSION >= 2
> + _("Malformed XML: %s at line %ld"),
> +#else
> _("Malformed XML: %s at line %d"),
> +#endif
> XML_ErrorString(XML_GetErrorCode(svn_parser->parser)),
> XML_GetCurrentLineNumber(svn_parser->parser));
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-01-27 01:10:22 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.