mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Part Bug fix for 729476, this changes the line endings to \r\n to make it more compatible with CSV format.
This commit is contained in:
parent
2b6a6d896c
commit
ba1f8cb1c6
@ -256,7 +256,11 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
|
||||
g_free (part1);
|
||||
|
||||
/* From Number Only */
|
||||
#ifdef G_OS_WIN32
|
||||
part1 = g_strconcat (part2, "", mid_sep, "", mid_sep, "", end_sep, "\n", NULL);
|
||||
#else
|
||||
part1 = g_strconcat (part2, "", mid_sep, "", mid_sep, "", end_sep, "\r\n", NULL);
|
||||
#endif
|
||||
g_free (part2);
|
||||
|
||||
/* Write to file */
|
||||
@ -346,9 +350,17 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
|
||||
split_amount = xaccPrintAmount (xaccSplitGetSharePrice (t_split), gnc_split_amount_print_info (t_split, FALSE));
|
||||
str_temp = csv_txn_test_field_string (info, split_amount);
|
||||
if (xaccSplitGetAccount (t_split) == acc)
|
||||
#ifdef G_OS_WIN32
|
||||
part2 = g_strconcat (part1, str_temp, mid_sep, end_sep, "\n", NULL);
|
||||
else
|
||||
#else
|
||||
part2 = g_strconcat (part1, str_temp, mid_sep, end_sep, "\r\n", NULL);
|
||||
#endif
|
||||
else
|
||||
#ifdef G_OS_WIN32
|
||||
part2 = g_strconcat (part1, mid_sep, str_temp, end_sep, "\n", NULL);
|
||||
#else
|
||||
part2 = g_strconcat (part1, mid_sep, str_temp, end_sep, "\r\n", NULL);
|
||||
#endif
|
||||
g_free (str_temp);
|
||||
g_free (part1);
|
||||
|
||||
@ -415,7 +427,11 @@ void csv_transactions_export (CsvExportInfo *info)
|
||||
_("To With Sym"), mid_sep, _("From With Sym"), mid_sep,
|
||||
_("To Num."), mid_sep, _("From Num."), mid_sep,
|
||||
_("To Rate/Price"), mid_sep, _("From Rate/Price"),
|
||||
#ifdef G_OS_WIN32
|
||||
end_sep, "\n", NULL);
|
||||
#else
|
||||
end_sep, "\r\n", NULL);
|
||||
#endif
|
||||
DEBUG("Header String: %s", header);
|
||||
|
||||
/* Write header line */
|
||||
|
@ -144,12 +144,19 @@ void csv_tree_export (CsvExportInfo *info)
|
||||
}
|
||||
|
||||
/* Header string, 'eol = end of line marker' */
|
||||
header = g_strconcat ( end_sep, _("type"), mid_sep, _("full_name"), mid_sep,
|
||||
_("name"), mid_sep, _("code"), mid_sep,
|
||||
_("description"), mid_sep, _("color"), mid_sep, _("notes"), mid_sep,
|
||||
_("commoditym"), mid_sep, _("commodityn"), mid_sep,
|
||||
_("hidden"), mid_sep, _("tax"), mid_sep, _("place_holder"), mid_sep,
|
||||
_("#eol"), end_sep, "\n", NULL);
|
||||
#ifdef G_OS_WIN32
|
||||
header = g_strconcat (end_sep, _("type"), mid_sep, _("full_name"), mid_sep, _("name"), mid_sep,
|
||||
_("code"), mid_sep, _("description"), mid_sep, _("color"), mid_sep,
|
||||
_("notes"), mid_sep, _("commoditym"), mid_sep, _("commodityn"), mid_sep,
|
||||
_("hidden"), mid_sep, _("tax"), mid_sep, _("place_holder"), mid_sep, _("#eol"),
|
||||
end_sep, "\n", NULL);
|
||||
#else
|
||||
header = g_strconcat (end_sep, _("type"), mid_sep, _("full_name"), mid_sep, _("name"), mid_sep,
|
||||
_("code"), mid_sep, _("description"), mid_sep, _("color"), mid_sep,
|
||||
_("notes"), mid_sep, _("commoditym"), mid_sep, _("commodityn"), mid_sep,
|
||||
_("hidden"), mid_sep, _("tax"), mid_sep, _("place_holder"), mid_sep, _("#eol"),
|
||||
end_sep, "\r\n", NULL);
|
||||
#endif
|
||||
DEBUG("Header String: %s", header);
|
||||
|
||||
/* Write header line */
|
||||
@ -229,7 +236,11 @@ void csv_tree_export (CsvExportInfo *info)
|
||||
g_free (part2);
|
||||
/* Place Holder / end of line marker */
|
||||
currentSel = xaccAccountGetPlaceholder (acc) ? "T" : "F" ;
|
||||
#ifdef G_OS_WIN32
|
||||
part2 = g_strconcat (part1, currentSel, mid_sep, _("#eol"), end_sep, "\n", NULL);
|
||||
#else
|
||||
part2 = g_strconcat (part1, currentSel, mid_sep, _("#eol"), end_sep, "\r\n", NULL);
|
||||
#endif
|
||||
g_free (part1);
|
||||
|
||||
DEBUG("Account String: %s", part2);
|
||||
|
@ -119,8 +119,13 @@ csv_import_read_file (const gchar *filename, const gchar *parser_regexp,
|
||||
}
|
||||
|
||||
/* Setup the two different line endings */
|
||||
#ifdef G_OS_WIN32
|
||||
end1 = g_strconcat (_("#eol"),"\"\n", NULL);
|
||||
end2 = g_strconcat (_("#eol"),"\n", NULL);
|
||||
#else
|
||||
end1 = g_strconcat (_("#eol"),"\"\r\n", NULL);
|
||||
end2 = g_strconcat (_("#eol"),"\r\n", NULL);
|
||||
#endif
|
||||
|
||||
// start the import
|
||||
#define buffer_size 1000
|
||||
@ -154,11 +159,14 @@ csv_import_read_file (const gchar *filename, const gchar *parser_regexp,
|
||||
break; // eof
|
||||
}
|
||||
|
||||
// now strip the '\n' from the end of the line
|
||||
// now strip the '\r\n' from the end of the line
|
||||
l = strlen (currentline);
|
||||
if ((l > 0) && (currentline[l - 1] == '\n'))
|
||||
currentline[l - 1] = 0;
|
||||
|
||||
if ((l > 0) && (currentline[l - 2] == '\r'))
|
||||
currentline[l - 2] = 0;
|
||||
|
||||
// convert line from locale into utf8
|
||||
line_utf8 = g_locale_to_utf8 (currentline, -1, NULL, NULL, NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user