From 661ea3fb4f1463f9c6602c0f562c40e3c8f9023e Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Sat, 17 Sep 2011 16:50:30 +0000 Subject: [PATCH] Improved regexps for CSV files with quotes - quotes are allowed but not required on all fields. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21262 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/plugins/bi_import/bi_import.c | 2 +- src/plugins/bi_import/gui.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/bi_import/bi_import.c b/src/plugins/bi_import/bi_import.c index b85b8207c4..26f4b58e37 100644 --- a/src/plugins/bi_import/bi_import.c +++ b/src/plugins/bi_import/bi_import.c @@ -114,7 +114,7 @@ gnc_bi_import_read_file (const gchar * filename, const gchar * parser_regexp, // compile the regular expression and check for errors err = NULL; regexpat = - g_regex_new (parser_regexp, G_REGEX_EXTENDED | G_REGEX_OPTIMIZE, 0, &err); + g_regex_new (parser_regexp, G_REGEX_EXTENDED | G_REGEX_OPTIMIZE | G_REGEX_DUPNAMES, 0, &err); if (err != NULL) { GtkWidget *dialog; diff --git a/src/plugins/bi_import/gui.c b/src/plugins/bi_import/gui.c index 3cf78185e5..c70e4d8a30 100644 --- a/src/plugins/bi_import/gui.c +++ b/src/plugins/bi_import/gui.c @@ -309,7 +309,7 @@ void gnc_bi_import_gui_option3_cb (GtkWidget *widget, gpointer data) BillImportGui *gui = data; if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) )) return; - g_string_assign (gui->regexp, "^\"(?[^!#+^\"]*)\";\"(?[^\"]*)\";\"(?[^\"]*)\";\"(?[^\"]*)\";\"?(?[^\"]*)\";\"?(?[^\"]*)\";\"?(?[^\"]*)\";\"?(?[^\"]*)\";\"?(?[^\"]*)\";\"?(?[^\"]*)\";\"?(?[^\"]*)\";\"?(?[^\"]*)\";\"?(?[^\"]*)\";\"?(?[^\"]*)\";\"?(?[^\"]*)\";\"?(?[^\"]*)\";\"?(?[^\"]*)\";\"(?[^\"]*)\";\"(?[^\"]*)\";\"(?[^\"]*)\";\"(?[^\"]*)\";\"(?[^\"]*)\""); + g_string_assign (gui->regexp, "^((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\");((?[^\";]*)|\"(?[^\"]*)\")$"); gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui); } void gnc_bi_import_gui_option4_cb (GtkWidget *widget, gpointer data) @@ -317,7 +317,7 @@ void gnc_bi_import_gui_option4_cb (GtkWidget *widget, gpointer data) BillImportGui *gui = data; if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) )) return; - g_string_assign (gui->regexp, "^\"(?[^!#+^\"]*)\",\"(?[^\"]*)\",\"(?[^\"]*)\",\"(?[^\"]*)\",\"?(?[^\"]*)\",\"?(?[^\"]*)\",\"?(?[^\"]*)\",\"?(?[^\"]*)\",\"?(?[^\"]*)\",\"?(?[^\"]*)\",\"?(?[^\"]*)\",\"?(?[^\"]*)\",\"?(?[^\"]*)\",\"?(?[^\"]*)\",\"?(?[^\"]*)\",\"?(?[^\"]*)\",\"?(?[^\"]*)\",\"(?[^\"]*)\",\"(?[^\"]*)\",\"(?[^\"]*)\",\"(?[^\"]*)\",\"(?[^\"]*)\""); + g_string_assign (gui->regexp, "^((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\"),((?[^\",]*)|\"(?[^\"]*)\")$"); gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui); } void gnc_bi_import_gui_option5_cb (GtkWidget *widget, gpointer data)