[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_0_9.0-80-ge8bdac0
Pierre Biava
nobody at users.sourceforge.net
Thu Mar 17 22:46:39 CET 2011
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grisbi".
The branch, master has been updated
via e8bdac07962574111152a2a6b4bb416e901ff77e (commit)
from c9b799225aa760e310a152e09490ee3bc2157ef5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e8bdac07962574111152a2a6b4bb416e901ff77e
Author: pbiava <pierre.biava at nerim.net>
Date: Wed Mar 16 23:27:01 2011 +0100
fixes bug 1313 : Grisbi crashes when Importing a QIF file with a list of categories
(cherry picked from commit 4beb1924d110f522b03fc5bc160fc1f9fa61064d)
-----------------------------------------------------------------------
Changes:
diff --git a/src/qif.c b/src/qif.c
index 68e8727..7271138 100644
--- a/src/qif.c
+++ b/src/qif.c
@@ -55,6 +55,7 @@ static gchar **gsb_qif_get_date_content ( gchar *date_string );
static gint gsb_qif_get_date_order ( GSList *transactions_list );
static gchar *gsb_qif_get_account_name ( FILE *qif_file, const gchar *coding_system );
static gint gsb_qif_get_account_type ( gchar *header );
+static gint gsb_qif_recupere_categories ( FILE *qif_file, const gchar *coding_system );
static gint gsb_qif_recupere_operations_from_account ( FILE *qif_file,
const gchar *coding_system,
struct struct_compte_importation *imported_account );
@@ -166,6 +167,24 @@ gboolean recuperation_donnees_qif ( GtkWidget *assistant, struct imported_file *
&&
tmp_str
&&
+ g_ascii_strncasecmp ( tmp_str, "!Type:Cat", 9 ) == 0 )
+ {
+
+ do
+ {
+ returned_value = gsb_qif_recupere_categories ( qif_file,
+ imported -> coding_system );
+
+ if ( returned_value == 0 )
+ tmp_str = last_header;
+ }
+ /* continue untill the end of the file or a change of account */
+ while ( returned_value != EOF && returned_value != 0 );
+ }
+ else if ( returned_value != EOF
+ &&
+ tmp_str
+ &&
g_ascii_strncasecmp ( tmp_str, "!Type", 5 ) == 0 )
{
gint account_type;
@@ -1251,6 +1270,96 @@ gint gsb_qif_recupere_operations_from_account ( FILE *qif_file,
}
+/**
+ *
+ *
+ *
+ *
+ * */
+gint gsb_qif_recupere_categories ( FILE *qif_file, const gchar *coding_system )
+{
+ gchar *string;
+ gint returned_value;
+
+ do
+ {
+ returned_value = get_utf8_line_from_file ( qif_file, &string, coding_system );
+
+ /* a category never begin with ^ and ! */
+ if ( strlen ( string )
+ &&
+ returned_value != EOF
+ &&
+ string[0] != '^'
+ &&
+ string[0] != '!' )
+ {
+ gint category_number;
+ gint type_category = 1;
+ gchar **tab_str = NULL;
+
+ tab_str = g_strsplit ( string + 1, ":", 2 );
+ g_free ( string );
+
+ do
+ {
+ returned_value = get_utf8_line_from_file ( qif_file,
+ &string, coding_system );
+ if ( strlen ( string )
+ &&
+ returned_value != EOF
+ &&
+ string[0] != '^'
+ &&
+ string[0] != '!' )
+ {
+ if ( strcmp ( string, "I" ) == 0 )
+ type_category = 0;
+ g_free ( string );
+ }
+ }
+ while ( string[0] != '^' && returned_value != EOF && string[0] != '!' );
+
+ /* get the category and create it if doesn't exist */
+ if (tab_str[0])
+ {
+ tab_str[0] = g_strstrip ( tab_str[0] );
+ category_number = gsb_data_category_get_number_by_name ( tab_str[0],
+ TRUE,
+ type_category );
+
+ if (tab_str[1])
+ {
+ tab_str[1] = g_strstrip ( tab_str[1] );
+
+ gsb_data_category_get_sub_category_number_by_name (
+ category_number,
+ tab_str[1],
+ TRUE );
+ }
+ }
+
+ g_strfreev(tab_str);
+ }
+ }
+ while ( string[0] != '^' && returned_value != EOF && string[0] != '!' );
+
+ if ( string[0] == '!' )
+ {
+ if ( last_header && strlen ( last_header ) )
+ g_free ( last_header );
+ last_header = g_strdup ( string );
+ }
+
+ if ( returned_value != EOF && string[0] != '!' )
+ return 1;
+ else if ( returned_value == EOF )
+ return EOF;
+ else
+ return 0;
+}
+
+
/* Local Variables: */
/* c-basic-offset: 4 */
/* End: */
hooks/post-receive
--
grisbi
More information about the cvs
mailing list