mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Properly handle Windos end-of-line markers in determining xml file versions.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22038 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -909,7 +909,8 @@ gnc_is_our_first_xml_chunk(char *chunk, gboolean *with_encoding)
|
||||
|
||||
if (strncmp(cursor, "<?xml", 5) == 0)
|
||||
{
|
||||
char *tag_compare;
|
||||
char *tag_compare1;
|
||||
char *tag_compare2;
|
||||
|
||||
if (!search_for('>', &cursor))
|
||||
{
|
||||
@@ -921,9 +922,12 @@ gnc_is_our_first_xml_chunk(char *chunk, gboolean *with_encoding)
|
||||
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 @@ gnc_is_our_first_xml_chunk(char *chunk, gboolean *with_encoding)
|
||||
}
|
||||
}
|
||||
}
|
||||
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 */
|
||||
|
||||
Reference in New Issue
Block a user