r22038 - gnucash/trunk/src/backend/xml - Properly handle Windos end-of-line markers in determining xml file versions.
J. Alex Aycinena
alex.aycinena at code.gnucash.org
Wed Feb 15 18:14:59 EST 2012
Author: alex.aycinena
Date: 2012-02-15 18:14:58 -0500 (Wed, 15 Feb 2012)
New Revision: 22038
Trac: http://svn.gnucash.org/trac/changeset/22038
Modified:
gnucash/trunk/src/backend/xml/sixtp.c
Log:
Properly handle Windos end-of-line markers in determining xml file versions.
Modified: gnucash/trunk/src/backend/xml/sixtp.c
===================================================================
--- gnucash/trunk/src/backend/xml/sixtp.c 2012-02-15 21:00:22 UTC (rev 22037)
+++ gnucash/trunk/src/backend/xml/sixtp.c 2012-02-15 23:14:58 UTC (rev 22038)
@@ -909,7 +909,8 @@
if (strncmp(cursor, "<?xml", 5) == 0)
{
- char *tag_compare;
+ char *tag_compare1;
+ char *tag_compare2;
if (!search_for('>', &cursor))
{
@@ -921,9 +922,12 @@
return GNC_BOOK_NOT_OURS;
}
- tag_compare = g_strdup_printf("<%s\n", gnc_v2_xml_version_string);
+ tag_compare1 = g_strdup_printf("<%s\n", gnc_v2_xml_version_string);
+ /* This second compare is to handle Windows end-of-line markers */
+ tag_compare2 = g_strdup_printf("<%s\r\n", gnc_v2_xml_version_string);
- if (strncmp(cursor, tag_compare, strlen(tag_compare)) == 0)
+ if ((strncmp(cursor, tag_compare1, strlen(tag_compare1)) == 0)
+ || (strncmp(cursor, tag_compare2, strlen(tag_compare2)) == 0))
{
if (with_encoding)
{
@@ -938,13 +942,15 @@
}
}
}
- g_free (tag_compare);
+ g_free (tag_compare1);
+ g_free (tag_compare2);
return GNC_BOOK_XML2_FILE;
}
- g_free (tag_compare);
+ g_free (tag_compare1);
+ g_free (tag_compare2);
- if (strncmp(cursor, "<gnc>\n", strlen("<gnc>\n")) == 0)
+ if (strncmp(cursor, "<gnc>", strlen("<gnc>")) == 0)
return GNC_BOOK_XML1_FILE;
/* If it doesn't match any of the above but has '<gnc-v...', it must */
More information about the gnucash-changes
mailing list