[grisbi-cvs] grisbi/src gsb_data_account.c, 1.79, 1.80 gsb_data_bank.c, 1.10, 1.11 gsb_data_payee.c, 1.47, 1.48 gsb_data_report.c, 1.29, 1.30 gsb_data_report_text_comparison.c, 1.13, 1.14 gsb_data_scheduled.c, 1.26, 1.27 gsb_data_transaction.c, 1.62, 1.63 gsb_file.c, 1.52, 1.53 gsb_file_save.c, 1.127, 1.128

Mickaƫl Remars mykeul at users.sourceforge.net
Sat Jun 6 17:14:16 CEST 2009


Update of /cvsroot/grisbi/grisbi/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22703

Modified Files:
	gsb_data_account.c gsb_data_bank.c gsb_data_payee.c 
	gsb_data_report.c gsb_data_report_text_comparison.c 
	gsb_data_scheduled.c gsb_data_transaction.c gsb_file.c 
	gsb_file_save.c 
Log Message:
Avoid multiple NULL strings that prevented (crash) saving the gsb file on win32 (the glib printing functions seem to be less tolerent than the linux ones)

Index: gsb_data_transaction.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_transaction.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- gsb_data_transaction.c	21 May 2009 21:58:55 -0000	1.62
+++ gsb_data_transaction.c	6 Jun 2009 15:14:14 -0000	1.63
@@ -414,11 +414,8 @@
 
     if ( transaction -> transaction_id )
         g_free ( transaction -> transaction_id );
+	transaction -> transaction_id = g_strdup ( transaction_id ? transaction_id : "" );
 
-    if (transaction_id)
-	transaction -> transaction_id = my_strdup (transaction_id);
-    else
-    	transaction -> transaction_id = NULL;
     return TRUE;
 }
 
@@ -1271,13 +1268,7 @@
 
     if ( transaction -> notes )
         g_free ( transaction -> notes );
-
-    if ( notes
-	 &&
-	 strlen (notes))
-	transaction -> notes = my_strdup (notes);
-    else
-	transaction -> notes = NULL;
+	transaction -> notes = g_strdup ( notes ? notes : "" );
     
     return TRUE;
 }
@@ -1382,13 +1373,7 @@
 
     if ( transaction -> method_of_payment_content )
         g_free ( transaction -> method_of_payment_content );
-
-    if ( method_of_payment_content
-	 &&
-	 strlen (method_of_payment_content))
-	transaction -> method_of_payment_content = my_strdup (method_of_payment_content);
-    else
-	transaction -> method_of_payment_content = NULL;
+	transaction -> method_of_payment_content = g_strdup ( method_of_payment_content ? method_of_payment_content : "" );
     
     return TRUE;
 }
@@ -1834,13 +1819,7 @@
 
     if ( transaction -> bank_references )
         g_free ( transaction -> bank_references );
-
-    if ( bank_references
-	 &&
-	 strlen (bank_references))
-	transaction -> bank_references = my_strdup (bank_references);
-    else
-	transaction -> bank_references = NULL;
+	transaction -> bank_references = g_strdup ( bank_references ? bank_references : "" );
     
     return TRUE;
 }
@@ -1991,10 +1970,13 @@
 	transaction_number = gsb_data_transaction_get_last_number () + 1;
 
     transaction -> account_number = no_account;
+    transaction -> transaction_id = g_strdup("");
     transaction -> transaction_number = transaction_number;
     transaction -> currency_number = gsb_data_account_get_currency (no_account);
+    transaction -> notes = g_strdup("");
     transaction -> voucher = g_strdup("");
     transaction -> bank_references = g_strdup("");
+    transaction -> method_of_payment_content = g_strdup("");
 
     /* we append the transaction to the complete transactions list and the non archive transaction list */
     transactions_list = g_slist_append ( transactions_list,

Index: gsb_data_payee.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_payee.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- gsb_data_payee.c	27 Apr 2009 19:41:03 -0000	1.47
+++ gsb_data_payee.c	6 Jun 2009 15:14:14 -0000	1.48
@@ -572,12 +572,7 @@
     /* we free the last name */
     if ( payee -> payee_description )
 	g_free (payee -> payee_description);
-    
-    /* and copy the new one */
-    if (description)
-	payee -> payee_description = my_strdup (description);
-    else
-	payee -> payee_description = NULL;
+	payee -> payee_description = g_strdup ( description ? description : "" );
 
     return TRUE;
 }
@@ -846,12 +841,7 @@
     /* we free the last name */
     if ( payee -> payee_search_string )
         g_free (payee -> payee_search_string);
-    
-    /* and copy the new one */
-    if (search_string)
-        payee -> payee_search_string = my_strdup (search_string);
-    else
-        payee -> payee_search_string = NULL;
+    payee -> payee_search_string = g_strdup ( search_string ? search_string : "" );
 
     return TRUE;
 }

Index: gsb_file.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- gsb_file.c	24 May 2009 16:42:39 -0000	1.52
+++ gsb_file.c	6 Jun 2009 15:14:14 -0000	1.53
@@ -1003,7 +1003,7 @@
 
     if ( !g_path_is_absolute ( nom_fichier_comptes ) )
     {
-        real_name = g_strdup( (gchar*)realpath ( nom_fichier_comptes, NULL ));
+//        real_name = g_strdup( (gchar*)realpath ( nom_fichier_comptes, NULL ));
         if ( ! real_name )
         {
             notice_debug ( "could not resolve relative file name" );

Index: gsb_data_scheduled.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_scheduled.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- gsb_data_scheduled.c	27 Apr 2009 19:41:03 -0000	1.26
+++ gsb_data_scheduled.c	6 Jun 2009 15:14:14 -0000	1.27
@@ -803,13 +803,7 @@
 
     if ( scheduled -> notes )
         g_free ( scheduled -> notes );
-
-    if ( notes
-	 &&
-	 strlen (notes))
-	scheduled -> notes = my_strdup (notes);
-    else
-	scheduled -> notes = NULL;
+	scheduled -> notes = g_strdup ( notes ? notes : "" );
 
     return TRUE;
 }
@@ -920,13 +914,7 @@
 
     if ( scheduled -> method_of_payment_content )
         g_free ( scheduled -> method_of_payment_content );
-
-    if ( method_of_payment_content
-	 &&
-	 strlen (method_of_payment_content))
-	scheduled -> method_of_payment_content = my_strdup (method_of_payment_content);
-    else
-	scheduled -> method_of_payment_content = NULL;
+	scheduled -> method_of_payment_content = g_strdup ( method_of_payment_content ? method_of_payment_content : "" );
 
     return TRUE;
 }

Index: gsb_data_bank.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_bank.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- gsb_data_bank.c	7 Apr 2009 21:07:40 -0000	1.10
+++ gsb_data_bank.c	6 Jun 2009 15:14:14 -0000	1.11
@@ -218,9 +218,20 @@
 
     bank = g_malloc0 ( sizeof ( struct_bank ));
     bank -> bank_number = gsb_data_bank_max_number () + 1;
+    bank -> bank_name = g_strdup(name ? name : "");
+    bank -> bank_code = g_strdup("");
+    bank -> bank_BIC = g_strdup("");
 
-    if (name)
-	bank -> bank_name = my_strdup (name);
+    bank -> bank_address = g_strdup("");
+    bank -> bank_tel = g_strdup("");
+    bank -> bank_mail = g_strdup("");
+    bank -> bank_web = g_strdup("");
+    bank -> bank_note = g_strdup("");
+
+    bank -> correspondent_name = g_strdup("");
+    bank -> correspondent_tel = g_strdup("");
+    bank -> correspondent_mail = g_strdup("");
+    bank -> correspondent_fax = g_strdup("");
 
     bank_list = g_slist_append ( bank_list, bank );
 
@@ -365,7 +376,7 @@
 	g_free (bank -> bank_name);
 
     /* and copy the new one */
-    bank -> bank_name = my_strdup (name);
+    bank -> bank_name = g_strdup ( name ? name : "" );
 
     return TRUE;
 }
@@ -415,7 +426,7 @@
 	g_free (bank -> bank_code);
 
     /* and copy the new one */
-    bank -> bank_code = my_strdup (bank_code);
+    bank -> bank_code = g_strdup ( bank_code ? bank_code : "" );
 
     return TRUE;
 }
@@ -466,7 +477,7 @@
 	g_free (bank -> bank_address);
 
     /* and copy the new one */
-    bank -> bank_address = my_strdup (bank_address);
+    bank -> bank_address = g_strdup ( bank_address ? bank_address : "" );
 
     return TRUE;
 }
@@ -515,7 +526,7 @@
 	g_free (bank -> bank_tel);
 
     /* and copy the new one */
-    bank -> bank_tel = my_strdup (bank_tel);
+    bank -> bank_tel = g_strdup ( bank_tel ? bank_tel : "" );
 
     return TRUE;
 }
@@ -565,7 +576,7 @@
 	g_free (bank -> bank_mail);
 
     /* and copy the new one */
-    bank -> bank_mail = my_strdup (bank_mail);
+    bank -> bank_mail = g_strdup ( bank_mail ? bank_mail : "" );
 
     return TRUE;
 }
@@ -615,7 +626,7 @@
 	g_free (bank -> bank_web);
 
     /* and copy the new one */
-    bank -> bank_web = my_strdup (bank_web);
+    bank -> bank_web = g_strdup ( bank_web ? bank_web : "" );
 
     return TRUE;
 }
@@ -665,7 +676,7 @@
 	g_free (bank -> bank_note);
 
     /* and copy the new one */
-    bank -> bank_note = my_strdup (bank_note);
+    bank -> bank_note = g_strdup ( bank_note ? bank_note : "" );
 
     return TRUE;
 }
@@ -715,7 +726,7 @@
 	g_free (bank -> correspondent_name);
 
     /* and copy the new one */
-    bank -> correspondent_name = my_strdup (correspondent_name);
+    bank -> correspondent_name = g_strdup ( correspondent_name ? correspondent_name : "" );
 
     return TRUE;
 }
@@ -765,7 +776,7 @@
 	g_free (bank -> correspondent_tel);
 
     /* and copy the new one */
-    bank -> correspondent_tel = my_strdup (correspondent_tel);
+    bank -> correspondent_tel = g_strdup ( correspondent_tel ? correspondent_tel : "" );
 
     return TRUE;
 }
@@ -815,7 +826,7 @@
 	g_free (bank -> correspondent_mail);
 
     /* and copy the new one */
-    bank -> correspondent_mail = my_strdup (correspondent_mail);
+    bank -> correspondent_mail = g_strdup ( correspondent_mail ? correspondent_mail : "" );
 
     return TRUE;
 }
@@ -865,7 +876,7 @@
 	g_free (bank -> correspondent_fax);
 
     /* and copy the new one */
-    bank -> correspondent_fax = my_strdup (correspondent_fax);
+    bank -> correspondent_fax = g_strdup ( correspondent_fax ? correspondent_fax : "" );
 
     return TRUE;
 }
@@ -914,7 +925,7 @@
 	g_free (bank -> bank_BIC);
 
     /* and copy the new one */
-    bank -> bank_BIC = my_strdup (bank_BIC);
+    bank -> bank_BIC = g_strdup ( bank_BIC ? bank_BIC : "" );
     
     return TRUE;
 }

Index: gsb_file_save.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_save.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -d -r1.127 -r1.128
--- gsb_file_save.c	4 Jun 2009 20:11:31 -0000	1.127
+++ gsb_file_save.c	6 Jun 2009 15:14:14 -0000	1.128
@@ -656,8 +656,8 @@
 	etat.crypt_file,
 	is_archive,
     tmpstr,
-	adresse_commune,
-	adresse_secondaire,
+	adresse_commune ? adresse_commune : "",
+	adresse_secondaire ? adresse_secondaire : "",
 	no_devise_totaux_tiers,
 	no_devise_totaux_categ,
 	no_devise_totaux_ib,
@@ -685,7 +685,7 @@
 	etat.combofix_force_payee,
 	etat.combofix_force_category,
 	etat.automatic_separator,
-	etat.csv_separator,
+	etat.csv_separator ? etat.csv_separator : "",
 	skipped_lines_string );
 
     g_free (transactions_view);
@@ -1016,7 +1016,7 @@
 	    gsb_data_account_get_default_credit (account_number),
 	    gsb_data_account_get_reconcile_sort_type (account_number),
 	    gsb_data_account_get_split_neutral_payment (account_number),
-	    sort_list,
+	    sort_list ? sort_list : "",
 	    gsb_data_account_get_sort_type (account_number),
 	    gsb_data_account_get_sort_column (account_number),
 	    sort_kind_column,
@@ -1159,7 +1159,7 @@
 					       transaction_number,
 					       gsb_data_transaction_get_transaction_id ( transaction_number),
 					       date,
-					       value_date,
+					       value_date ? value_date : "",
 					       gsb_data_transaction_get_currency_number (transaction_number ),
 					       amount,
 					       gsb_data_transaction_get_change_between (transaction_number ),
@@ -1259,7 +1259,7 @@
 					       gsb_data_scheduled_get_frequency ( scheduled_number),
 					       gsb_data_scheduled_get_user_interval ( scheduled_number),
 					       gsb_data_scheduled_get_user_entry ( scheduled_number),
-					       limit_date,
+					       limit_date ? limit_date : "",
 					       gsb_data_scheduled_get_split_of_scheduled ( scheduled_number),
 					       gsb_data_scheduled_get_mother_scheduled_number ( scheduled_number));
 
@@ -2249,25 +2249,25 @@
 	    gsb_data_report_get_report_can_click (report_number),
 	    gsb_data_report_get_use_financial_year (report_number),
 	    gsb_data_report_get_financial_year_type (report_number),
-	    financial_year_select,
+	    financial_year_select ? financial_year_select : "",
 	    gsb_data_report_get_date_type (report_number),
-	    date_start,
-	    date_end,
+	    date_start ? date_start : "",
+	    date_end ? date_end : "",
 	    gsb_data_report_get_period_split (report_number),
 	    gsb_data_report_get_period_split_type (report_number),
 	    gsb_data_report_get_financial_year_split (report_number),
 	    gsb_data_report_get_period_split_day (report_number),
 	    gsb_data_report_get_account_use_chosen (report_number),
-	    account_selected,
+	    account_selected ? account_selected : "",
 	    gsb_data_report_get_account_group_reports (report_number),
 	    gsb_data_report_get_account_show_amount (report_number),
 	    gsb_data_report_get_account_show_name (report_number),
 	    gsb_data_report_get_transfer_choice (report_number),
-	    transfer_selected_accounts,
+	    transfer_selected_accounts ? transfer_selected_accounts : "",
 	    gsb_data_report_get_transfer_reports_only (report_number),
 	    gsb_data_report_get_category_used (report_number),
 	    gsb_data_report_get_category_detail_used (report_number),
-	    categ_selected,
+	    categ_selected ? categ_selected : "",
 	    gsb_data_report_get_category_show_category_amount (report_number),
 	    gsb_data_report_get_category_show_sub_category (report_number),
 	    gsb_data_report_get_category_show_without_category (report_number),
@@ -2276,7 +2276,7 @@
 	    gsb_data_report_get_category_show_name (report_number),
 	    gsb_data_report_get_budget_used (report_number),
 	    gsb_data_report_get_budget_detail_used (report_number),
-	    budget_selected,
+	    budget_selected ? budget_selected : "",
 	    gsb_data_report_get_budget_show_budget_amount (report_number),
 	    gsb_data_report_get_budget_show_sub_budget (report_number),
 	    gsb_data_report_get_budget_show_without_budget (report_number),
@@ -2285,14 +2285,14 @@
 	    gsb_data_report_get_budget_show_name (report_number),
 	    gsb_data_report_get_payee_used (report_number),
 	    gsb_data_report_get_payee_detail_used (report_number),
-	    payee_selected,
+	    payee_selected ? payee_selected : "",
 	    gsb_data_report_get_payee_show_payee_amount (report_number),
 	    gsb_data_report_get_payee_currency (report_number),
 	    gsb_data_report_get_payee_show_name (report_number),
 	    gsb_data_report_get_amount_comparison_currency (report_number),
 	    gsb_data_report_get_amount_comparison_only_report_non_null (report_number),
 	    gsb_data_report_get_method_of_payment_used (report_number),
-	    payment_method_list,
+	    payment_method_list ? payment_method_list : "",
 	    gsb_data_report_get_text_comparison_used (report_number),
 	    gsb_data_report_get_amount_comparison_used (report_number));
 

Index: gsb_data_report_text_comparison.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_report_text_comparison.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- gsb_data_report_text_comparison.c	16 Jun 2008 20:11:21 -0000	1.13
+++ gsb_data_report_text_comparison.c	6 Jun 2009 15:14:14 -0000	1.14
@@ -300,7 +300,7 @@
     text_comparison -> field = last_text_comparison -> field;
     text_comparison -> operator = last_text_comparison -> operator;
     if (last_text_comparison -> text)
-	text_comparison -> text = my_strdup (last_text_comparison -> text);
+	text_comparison -> text = g_strdup (last_text_comparison -> text ? last_text_comparison -> text : "");
     text_comparison -> use_text = last_text_comparison -> use_text;
     text_comparison -> first_comparison = last_text_comparison -> first_comparison;
     text_comparison -> first_amount = last_text_comparison -> first_amount;
@@ -503,10 +503,8 @@
     if ( !text_comparison )
 	return FALSE;
 
-    if ( text && strlen (text))
-	text_comparison -> text = my_strdup (text);
-    else
-	text_comparison -> text = NULL;
+    g_free(text_comparison -> text);
+	text_comparison -> text = g_strdup (text ? text : "");
 
     return TRUE;
 }

Index: gsb_data_account.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_account.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- gsb_data_account.c	25 May 2009 19:42:27 -0000	1.79
+++ gsb_data_account.c	6 Jun 2009 15:14:14 -0000	1.80
@@ -217,9 +217,19 @@
 
     /* set the base */
     account -> account_number = last_number + 1;
+    account -> account_id = g_strdup("");
     account -> account_name = g_strdup_printf ( _("No name %d"),
 						account -> account_number );
     account -> currency = gsb_data_currency_get_default_currency ();
+    account -> name_icon = g_strdup("");
+    account -> comment = g_strdup("");
+    account -> holder_name = g_strdup("");
+    account -> holder_address = g_strdup("");
+
+    account -> bank_branch_code = g_strdup("");
+    account -> bank_account_number = g_strdup("");
+    account -> bank_account_key = g_strdup("");
+    account -> bank_account_iban = g_strdup("");
 
     /* set the kind of account */
     account -> account_kind = account_kind;
@@ -1437,11 +1447,7 @@
 
     if ( account -> bank_branch_code )
         g_free ( account -> bank_branch_code );
-
-    if (!bank_branch_code || !strlen (bank_branch_code))
-	account -> bank_branch_code = NULL;
-    else
-	account -> bank_branch_code = my_strdup (bank_branch_code);
+	account -> bank_branch_code = g_strdup ( bank_branch_code ? bank_branch_code : "" );
 
     return TRUE;
 }
@@ -1485,11 +1491,7 @@
 
     if ( account -> bank_account_number )
         g_free ( account -> bank_account_number );
-
-    if (!bank_account_number || !strlen (bank_account_number))
-	account -> bank_account_number = NULL;
-    else
-	account -> bank_account_number = my_strdup (bank_account_number);
+	account -> bank_account_number = g_strdup ( bank_account_number ? bank_account_number : "" );
 
     return TRUE;
 }
@@ -1534,11 +1536,7 @@
 
     if ( account -> bank_account_key )
         g_free ( account -> bank_account_key );
-
-    if (!bank_account_key || !strlen (bank_account_key))
-	account -> bank_account_key = NULL;
-    else
-	account -> bank_account_key = my_strdup (bank_account_key);
+	account -> bank_account_key = g_strdup ( bank_account_key ? bank_account_key : "" );
 
     return TRUE;
 }
@@ -1620,7 +1618,7 @@
 
     if ( account -> comment )
         g_free ( account -> comment );
-    account -> comment = my_strdup (comment);
+    account -> comment = g_strdup ( comment ? comment : "" );
 
     return TRUE;
 }
@@ -1877,11 +1875,7 @@
 
     if ( account -> holder_name )
         g_free ( account -> holder_name );
-
-    if (!holder_name || !strlen (holder_name))
-	account -> holder_name = NULL;
-    else
-	account -> holder_name = my_strdup (holder_name);
+	account -> holder_name = g_strdup ( holder_name ? holder_name : "" );
 
     return TRUE;
 }
@@ -1925,11 +1919,7 @@
 
     if ( account -> holder_address )
         g_free ( account -> holder_address );
-
-    if (!holder_address || !strlen (holder_address))
-	account -> holder_address = NULL;
-    else
-	account -> holder_address = my_strdup (holder_address);
+	account -> holder_address = g_strdup ( holder_address ? holder_address : "" );
 
     return TRUE;
 }

Index: gsb_data_report.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_report.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- gsb_data_report.c	10 Oct 2008 06:50:39 -0000	1.29
+++ gsb_data_report.c	6 Jun 2009 15:14:14 -0000	1.30
@@ -513,10 +513,8 @@
     if ( !report )
 	return FALSE;
 
-    if (report_name)
-	report -> report_name = my_strdup (report_name);
-    else
-	report -> report_name = NULL;
+    g_free (report -> report_name);
+	report -> report_name = g_strdup ( report_name ? report_name : "" );
 
     return TRUE;
 }
@@ -3936,7 +3934,7 @@
     /* we had to duplicate the strings, dates and lists */
 
     if( report -> report_name )
-	new_report -> report_name = my_strdup ( report -> report_name );
+	new_report -> report_name = g_strdup ( report -> report_name ? report -> report_name : "" );
     new_report -> financial_year_list = g_slist_copy ( report -> financial_year_list );
     new_report -> sorting_type = g_slist_copy ( report -> sorting_type );
     new_report -> account_numbers = g_slist_copy ( report -> account_numbers );



More information about the cvs mailing list