[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_0_7_4-79-g7cddda1

Pierre Biava nobody at users.sourceforge.net
Sun Nov 7 12:39:34 CET 2010


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  7cddda1cc218619ac823470c841e6bb0e5f37ee3 (commit)
       via  38c8d707d6b57870fd2fa8825e2432dd7e2fd4c8 (commit)
       via  ab69c80ff07bda9b7ed8297976f544d6f14ce2c5 (commit)
      from  def7b2cc9b31b6188af68d84ca76fcd4f6338722 (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 7cddda1cc218619ac823470c841e6bb0e5f37ee3
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Nov 7 12:36:02 2010 +0100

    Fixed bug 1199: management of the dates for English users is not correct

commit 38c8d707d6b57870fd2fa8825e2432dd7e2fd4c8
Author: pbiava <pierre.biava at nerim.net>
Date:   Sat Nov 6 21:26:33 2010 +0100

    fixes a crash when the payee field is not present in the form

commit ab69c80ff07bda9b7ed8297976f544d6f14ce2c5
Author: pbiava <pierre.biava at nerim.net>
Date:   Sat Nov 6 18:49:40 2010 +0100

    Search crash when saving a file encrypted.

-----------------------------------------------------------------------

Changes:
diff --git a/src/gsb_calendar_entry.h b/src/gsb_calendar_entry.h
index cd31eb6..e1854ca 100644
--- a/src/gsb_calendar_entry.h
+++ b/src/gsb_calendar_entry.h
@@ -7,7 +7,7 @@
 #define ONE_WEEK 7
 #define ONE_MONTH 30
 #define ONE_YEAR 365
-#define SIZEOF_FORMATTED_STRING_DATE 128
+#define SIZEOF_FORMATTED_STRING_DATE 200
 
 /* START_INCLUDE_H */
 /* END_INCLUDE_H */
diff --git a/src/gsb_file_save.c b/src/gsb_file_save.c
index f3231a3..a12fe99 100644
--- a/src/gsb_file_save.c
+++ b/src/gsb_file_save.c
@@ -194,24 +194,24 @@ gboolean gsb_file_save_save_file ( const gchar *filename,
     gulong length_calculated;
     gchar *file_content;
 
-    gint general_part;
-    gint account_part;
-    gint transaction_part;
-    gint party_part;
-    gint category_part;
-    gint budgetary_part;
-    gint currency_part;
-    gint currency_link_part;
-    gint bank_part;
-    gint financial_year_part;
-    gint archive_part;
-    gint reconcile_part;
-    gint report_part;
-    gint import_rule_part;
-    gint partial_balance_part;
-    gint logo_part;
-    gint account_icon_part;
-    gint bet_part;
+    gint general_part = 4048;
+    gint account_part = 1300;
+    gint transaction_part = 350;
+    gint party_part = 256;
+    gint category_part = 500;
+    gint budgetary_part = 500;
+    gint currency_part = 100;
+    gint currency_link_part = 100;
+    gint bank_part = 500;
+    gint financial_year_part = 100;
+    gint archive_part = 120;
+    gint reconcile_part = 50;
+    gint report_part = 2500;
+    gint import_rule_part = 50;
+    gint partial_balance_part = 50;
+    gint logo_part = 65536;
+    gint account_icon_part = 4500;
+    gint bet_part = 500;
 
     struct stat buf;
 
@@ -219,21 +219,19 @@ gboolean gsb_file_save_save_file ( const gchar *filename,
 
     devel_debug (filename);
 
-    if (g_file_test ( filename,
-		      G_FILE_TEST_EXISTS ))
+    if ( g_file_test ( filename, G_FILE_TEST_EXISTS ) )
     {
-	/* the file exists, we need to get the chmod values
-	 * because gtk will overwrite it */
-	if (stat (filename, &buf) == -1)
-	    /* stat couldn't get the information, so do as a new file
-	     * and we will set the good chmod */
-	    do_chmod = TRUE;
-	else
-	    do_chmod = FALSE;
+        /* the file exists, we need to get the chmod values because gtk will overwrite it */
+        if (stat (filename, &buf) == -1)
+            /* stat couldn't get the information, so do as a new file
+             * and we will set the good chmod */
+            do_chmod = TRUE;
+        else
+            do_chmod = FALSE;
     }
     else
-	/* the file doesn't exist, so we will set the only user chmod */
-	do_chmod = TRUE;
+        /* the file doesn't exist, so we will set the only user chmod */
+        do_chmod = TRUE;
 
     etat.en_train_de_sauvegarder = 1;
 
@@ -241,25 +239,6 @@ gboolean gsb_file_save_save_file ( const gchar *filename,
      * if not enough, we will make it growth later
      * the data below are about the memory to take for each part and for 1 of this part
      * with that i think we will allocate enough memory in one time but not too much */
-
-    general_part = 900;
-    account_part = 1200;
-    transaction_part = 350;
-    party_part = 100;
-    category_part = 500;
-    budgetary_part = 500;
-    currency_part = 100;
-    currency_link_part = 100;
-    bank_part = 300;
-    financial_year_part = 100;
-    archive_part = 120;
-    reconcile_part = 50;
-    report_part = 2500;
-    import_rule_part = 50;
-    partial_balance_part = 50;
-    logo_part = 65536;
-    account_icon_part = 4048;
-    bet_part = 250;
     
     length_calculated = general_part
 	+ account_part * gsb_data_account_get_accounts_amount ()
@@ -281,7 +260,7 @@ gboolean gsb_file_save_save_file ( const gchar *filename,
     + bet_part;
 
     iterator = 0;
-    file_content = g_malloc0 ( length_calculated );
+    file_content = g_malloc0 ( length_calculated * sizeof ( gchar ) );
 
     /* begin the file whith xml markup */
     iterator = gsb_file_save_append_part ( iterator,
@@ -397,25 +376,30 @@ gboolean gsb_file_save_save_file ( const gchar *filename,
     /* crypt the file if asked */
     if ( etat.crypt_file )
     {
-	if ( ( plugin = gsb_plugin_find ( "openssl" ) ) )
-	{
-	    gint (*crypt_function) ( const gchar *, gchar **, gboolean, gulong );
-	    
-	    crypt_function = (gpointer) plugin -> plugin_run;
-	    iterator = crypt_function ( filename, &file_content, TRUE, iterator );	
-	    if ( ! iterator )
-		return FALSE;
-	}
-	else
-	{
-	    dialogue_error_hint ( _("Grisbi was unable to load required plugin to "
-				    "handle that file.\n\n"
-				    "Please make sure if is installed (i.e. check "
-				    "that 'grisbi-ssl' package is installed) and "
-				    "try again."),
-				  _("Encryption plugin not found." ) );
-	    return FALSE;
-	}
+        if ( ( plugin = gsb_plugin_find ( "openssl" ) ) )
+        {
+            gint (*crypt_function) ( const gchar *, gchar **, gboolean, gulong );
+            
+            crypt_function = (gpointer) plugin -> plugin_run;
+            iterator = crypt_function ( filename, &file_content, TRUE, iterator );
+            if ( ! iterator )
+            {
+                g_free ( file_content);
+                return FALSE;
+            }
+        }
+        else
+        {
+            dialogue_error_hint ( _("Grisbi was unable to load required plugin to "
+                        "handle that file.\n\n"
+                        "Please make sure if is installed (i.e. check "
+                        "that 'grisbi-ssl' package is installed) and "
+                        "try again."),
+                      _("Encryption plugin not found." ) );
+
+            g_free ( file_content);
+            return FALSE;
+        }
     }
     
     /* the file is in memory, we can save it */
@@ -424,42 +408,42 @@ gboolean gsb_file_save_save_file ( const gchar *filename,
      * zlib if compression */
     if (compress)
     {
-	gzFile grisbi_file;
-	grisbi_file = gzopen (filename, "wb9");
-
-	if ( !grisbi_file
-	     ||
-	     !gzwrite ( grisbi_file,
-			file_content,
-			iterator ))
-	{
-	    gchar* tmpstr = g_strdup_printf ( _("Cannot save file '%s': %s"),
-					      filename,
-					      g_strerror(errno) );
-	    dialogue_error ( tmpstr );
-	    g_free ( tmpstr );
-	    g_free ( file_content);
-	    return ( FALSE );
-	}
-	gzclose (grisbi_file);
+        gzFile grisbi_file;
+
+        grisbi_file = gzopen (filename, "wb9");
+
+        if ( !grisbi_file
+         ||
+         !gzwrite ( grisbi_file, file_content, iterator ) )
+        {
+            gchar* tmpstr = g_strdup_printf ( _("Cannot save file '%s': %s"),
+                              filename,
+                              g_strerror(errno) );
+            dialogue_error ( tmpstr );
+            g_free ( tmpstr );
+            g_free ( file_content);
+
+            return ( FALSE );
+        }
+
+        g_free ( file_content);
+        gzclose (grisbi_file);
     }
     else
     {
-	GError *error = NULL;
+        GError *error = NULL;
 
-	if (!g_file_set_contents ( filename,
-				   file_content,
-				   iterator, &error ))
-	{
-	    gchar* tmpstr = g_strdup_printf ( _("Cannot save file '%s': %s"),
-					      filename,
-					      error -> message);
-	    dialogue_error ( tmpstr );
-	    g_free ( tmpstr );
-	    g_free ( file_content);
-	    g_error_free (error);
-	    return ( FALSE );
-	}
+        if ( !g_file_set_contents ( filename, file_content, iterator, &error ) )
+        {
+            gchar* tmpstr = g_strdup_printf ( _("Cannot save file '%s': %s"),
+                              filename,
+                              error -> message);
+            dialogue_error ( tmpstr );
+            g_free ( tmpstr );
+            g_error_free (error);
+            return ( FALSE );
+        }
+        g_free ( file_content);
     }
 
     /* if it's a new file, we set the permission */
diff --git a/src/gsb_form.c b/src/gsb_form.c
index 04a24a3..a824051 100644
--- a/src/gsb_form.c
+++ b/src/gsb_form.c
@@ -2160,29 +2160,31 @@ gboolean gsb_form_key_press_event ( GtkWidget *widget,
 	     * we need to finish with the dialog wich contains the form */
 	    if (gsb_gui_navigation_get_current_page () == GSB_HOME_PAGE)
 	    {
-		GtkWidget *tmp_widget;
+            GtkWidget *tmp_widget;
 
-		/* ok, we are on the home page. the best way is to send the response ok
-		 * to the dialog */
-		tmp_widget = widget;
+            /* ok, we are on the home page. the best way is to send the response ok
+             * to the dialog */
+            tmp_widget = widget;
 
-		do
-		{
-		    tmp_widget = gtk_widget_get_parent (GTK_WIDGET (tmp_widget));
-		}
-		while ( GTK_IS_WIDGET (tmp_widget)
-			&&
-			!GTK_IS_DIALOG (tmp_widget));
-		gtk_dialog_response (GTK_DIALOG (tmp_widget), GTK_RESPONSE_OK);
-		return TRUE;
+            do
+            {
+                tmp_widget = gtk_widget_get_parent (GTK_WIDGET (tmp_widget));
+            }
+            while ( GTK_IS_WIDGET (tmp_widget)
+                &&
+                !GTK_IS_DIALOG (tmp_widget));
+            gtk_dialog_response (GTK_DIALOG (tmp_widget), GTK_RESPONSE_OK);
+            return TRUE;
 	    }
 	    else
 	    {
             widget_prov = gsb_form_widget_get_widget ( TRANSACTION_FORM_PARTY );
-            
-            gsb_form_transaction_complete_form_by_payee ( gtk_combofix_get_text (
-                        GTK_COMBOFIX ( widget_prov ) ) ); 
-            gsb_form_finish_edition();
+
+            if ( GTK_IS_COMBOFIX ( widget_prov ) )
+                gsb_form_transaction_complete_form_by_payee ( gtk_combofix_get_text (
+                        GTK_COMBOFIX ( widget_prov ) ) );
+
+            gsb_form_finish_edition ();
             return TRUE;
 	    }
 	    break;
diff --git a/src/gsb_form_widget.c b/src/gsb_form_widget.c
index e9726d7..c0a9f08 100644
--- a/src/gsb_form_widget.c
+++ b/src/gsb_form_widget.c
@@ -730,6 +730,10 @@ void gsb_form_widget_set_empty ( GtkWidget *entry,
 				 &gray );
     }
 
+	gtk_widget_modify_base ( entry, 
+				 GTK_STATE_NORMAL,
+				 NULL );
+
     g_object_set_data ( G_OBJECT(entry), "empty", GINT_TO_POINTER( empty ) );
 }
 
diff --git a/src/main.c b/src/main.c
index bd574a2..b73b35a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -396,13 +396,15 @@ gboolean gsb_grisbi_print_environment_var ( void )
     conv = localeconv();
     
     printf ("Variables d'environnement :\n\n" );
-    printf ("Currency\n"
+    printf ("LANG = %s\n\n"
+            "Currency\n"
             "\tcurrency_symbol = %s\n"
             "\tmon_thousands_sep = \"%s\"\n"
             "\tmon_decimal_point = %s\n"
             "\tpositive_sign = \"%s\"\n"
             "\tnegative_sign = \"%s\"\n"
             "\tfrac_digits = \"%d\"\n\n",
+            g_getenv ( "LANG"),
             conv->currency_symbol,
             g_locale_to_utf8 ( conv->mon_thousands_sep, -1, NULL, NULL, NULL ),
             g_locale_to_utf8 ( conv->mon_decimal_point, -1, NULL, NULL, NULL ),
diff --git a/src/plugins/openssl/openssl.c b/src/plugins/openssl/openssl.c
index 822b5c4..07bd5cb 100644
--- a/src/plugins/openssl/openssl.c
+++ b/src/plugins/openssl/openssl.c
@@ -77,103 +77,101 @@ gulong gsb_file_util_crypt_file ( gchar * file_name, gchar **file_content,
 
     if ( crypt )
     {
-	/* we want to encrypt the file */
+        /* we want to encrypt the file */
 
-	gchar *encrypted_file;
+        gchar *encrypted_file;
 
-	/* now, if we know here a key to crypt, we use it, else, we ask for it */
+        /* now, if we know here a key to crypt, we use it, else, we ask for it */
 
-	if ( crypt_key )
-	    key = crypt_key;
-	else
-	    key = gsb_file_util_ask_for_crypt_key ( file_name, message, TRUE);
+        if ( crypt_key )
+            key = crypt_key;
+        else
+            key = gsb_file_util_ask_for_crypt_key ( file_name, message, TRUE);
 
-	/* if we have no key, we will no crypt that file */
+        /* if we have no key, we will no crypt that file */
 
-	if ( !key )
-	    return 0;
+        if ( !key )
+            return 0;
 
-	des_string_to_key ( key, &openssl_key );
-	des_set_key_unchecked( &openssl_key, sched );
-	DES_set_odd_parity ( &openssl_key );
+        des_string_to_key ( key, &openssl_key );
+        des_set_key_unchecked ( &openssl_key, sched );
+        DES_set_odd_parity ( &openssl_key );
 
-	/* we create a copy of the file in memory which will begin by
-	 * "Grisbi encrypted file " */
+        /* we create a copy of the file in memory which will begin by
+         * "Grisbi encrypted file " */
 
-	encrypted_file = g_malloc ( (length + 22) * sizeof ( gchar ));
-	strncpy ( encrypted_file,
-		  "Grisbi encrypted file ",
-		  22 );
+        encrypted_file = g_malloc0 ( ( length + 23 ) * sizeof ( gchar ) );
+        encrypted_file = strncpy ( encrypted_file, "Grisbi encrypted file ", 22 );
 
-	des_cbc_encrypt ( (guchar *) (* file_content),
-			  (guchar *) (encrypted_file + 22),
-			  (long) length,
-			  sched,
-			  (DES_cblock *) key,
-			  TRUE );
+        des_cbc_encrypt ( (guchar *) (* file_content),
+                        (guchar *) (encrypted_file + 22),
+                        (long) length,
+                        sched,
+                        (DES_cblock *) key,
+                        TRUE );
 
-	if ( length % 8 != 0 )
-	{
-	    length += ( 8 - length % 8 );
-	}
+        if ( length % 8 != 0 )
+        {
+            length += ( 8 - length % 8 );
+        }
 
-	*file_content = encrypted_file;
+        *file_content = encrypted_file;
 
-	/* the actual length is the initial + 22 (size of Grisbi encrypted file */
-	return length + 22;
+        /* the actual length is the initial + 22 (size of Grisbi encrypted file */
+        return length + 22;
     }
     else
     {
-	/* we want to decrypt the file */
+        /* we want to decrypt the file */
 
-	gchar *decrypted_file;
+        gchar *decrypted_file;
 
-	/* we set the length on the rigt size */
+        /* we set the length on the rigt size */
 
-	length = length - 22;
+        length = length - 22;
 
 return_bad_password:
 
-	/* now, if we know here a key to crypt, we use it, else, we ask for it */
+        /* now, if we know here a key to crypt, we use it, else, we ask for it */
 
-	if ( crypt_key )
-	    key = crypt_key;
-	else
-	    key = gsb_file_util_ask_for_crypt_key ( file_name, message, FALSE );
+        if ( crypt_key )
+            key = crypt_key;
+        else
+            key = gsb_file_util_ask_for_crypt_key ( file_name, message, FALSE );
 
-	/* if we have no key, we stop the loading */
+        /* if we have no key, we stop the loading */
 
-	if ( !key )
-	    return 0;
+        if ( !key )
+            return 0;
 
-	des_string_to_key ( key, &openssl_key );
-	des_set_key_unchecked( &openssl_key, sched );
-	DES_set_odd_parity ( &openssl_key );
+        des_string_to_key ( key, &openssl_key );
+        des_set_key_unchecked( &openssl_key, sched );
+        DES_set_odd_parity ( &openssl_key );
 
-	/* we create a copy of the file in memory which will begin
-	 * with "Grisbi encrypted file " */
+        /* we create a copy of the file in memory which will begin
+         * with "Grisbi encrypted file " */
 
-	decrypted_file = g_malloc ( length * sizeof ( gchar ));
+        decrypted_file = g_malloc0 ( length * sizeof ( gchar ));
 
-	des_cbc_encrypt ( (guchar *) (* file_content + 22),
-			  (guchar *) decrypted_file,
-			  (long) length,
-			  sched,
-			  (DES_cblock *) key,
-			  FALSE );
+        des_cbc_encrypt ( (guchar *) (* file_content + 22),
+                  (guchar *) decrypted_file,
+                  (long) length,
+                  sched,
+                  (DES_cblock *) key,
+                  FALSE );
 
-	/* before freeing file_content and go back, we check that the password was correct
-	 * if not, we free the decrypted_file and ask again for the password */
+        /* before freeing file_content and go back, we check that the password was correct
+         * if not, we free the decrypted_file and ask again for the password */
 
-	if ( strncmp ( decrypted_file,
-		       "<?xml version=\"1.0\"?>",
-		       18 )
-	     &&
-	     strncmp ( decrypted_file,
-		       "Grisbi compressed file ",
-		       23 ))
-	{
-	    /* it seems that it was not the correct password */
+        if ( strncmp ( decrypted_file,
+                   "<?xml version=\"1.0\"?>",
+                   18 )
+             &&
+             strncmp ( decrypted_file,
+                   "Grisbi compressed file ",
+                   23 ))
+        {
+            /* it seems that it was not the correct password */
 
 	    g_free ( decrypted_file );
 
@@ -189,8 +187,8 @@ return_bad_password:
 #else
     /* FIXME: import symbols to be sure we can call this kind of stuff. */
     dialogue_error_hint ( _("This build of Grisbi does not support encryption.\n"
-			    "Please recompile Grisbi with OpenSSL encryption enabled."),
-			  g_strdup_printf ( _("Cannot open encrypted file '%s'"),
+                        "Please recompile Grisbi with OpenSSL encryption enabled."),
+                        g_strdup_printf ( _("Cannot open encrypted file '%s'"),
 					    file_name ) );
 #endif
 
diff --git a/src/utils_dates.c b/src/utils_dates.c
index dda3030..1941392 100644
--- a/src/utils_dates.c
+++ b/src/utils_dates.c
@@ -67,12 +67,12 @@ gchar *gsb_date_today ( void )
     if (!last_date)
     {
         GDate *date;
-        gchar date_str[SIZEOF_FORMATTED_STRING_DATE];
+        gchar *date_string;
 
-        date = gdate_today();
-        g_date_strftime ( date_str, SIZEOF_FORMATTED_STRING_DATE, "%x", date );
-        gsb_date_set_last_date (date_str);
-        g_date_free( date );
+        date = gdate_today ( );
+        date_string = gsb_format_gdate ( date );
+        gsb_date_set_last_date ( date_string );
+        g_date_free ( date );
     }
     return (last_date);
 }
@@ -387,7 +387,10 @@ GDate *gsb_parse_date_string ( const gchar *date_string )
 	}
 	g_strfreev(tab_format);
 #else
-    format = nl_langinfo ( D_FMT );
+    if ( g_str_has_prefix ( g_getenv ( "LANG"), "en_" ) )
+        format = g_strndup ( "%m/%d/%Y", 8 );
+    else
+        format = nl_langinfo ( D_FMT );
 #endif
 
     while ( * format )
@@ -579,9 +582,13 @@ GDate *gsb_parse_date_string_safe ( const gchar *date_string )
  */
 gchar *gsb_format_date ( gint day, gint month, gint year )
 {
-    GDate* date = g_date_new_dmy ( day, month, year );
-    gchar* result = gsb_format_gdate ( date );
+    GDate* date;
+    gchar* result;
+
+    date = g_date_new_dmy ( day, month, year );
+    result = gsb_format_gdate ( date );
     g_date_free ( date );
+
     return result;
 }
 
@@ -598,15 +605,23 @@ gchar *gsb_format_date ( gint day, gint month, gint year )
 gchar *gsb_format_gdate ( const GDate *date )
 {
     gchar retour_str[SIZEOF_FORMATTED_STRING_DATE];
+    guint longueur;
 
-    if ( !date || !g_date_valid ( date ))
+    if ( !date || !g_date_valid ( date ) )
     {
-    return my_strdup ( "" );
+        return my_strdup ( "" );
     }
 
-    g_date_strftime ( retour_str, SIZEOF_FORMATTED_STRING_DATE, "%x", date );
+    if ( g_str_has_prefix ( g_getenv ( "LANG"), "en_" ) )
+        longueur = g_date_strftime ( retour_str, SIZEOF_FORMATTED_STRING_DATE, "%m/%d/%Y", date );
+    else
+        longueur = g_date_strftime ( retour_str, SIZEOF_FORMATTED_STRING_DATE, "%x", date );
 
-    return my_strdup ( retour_str );
+    if ( longueur == 0 )
+        return NULL;
+    else
+        return g_strndup ( retour_str, longueur );
+        
 }
 
 
@@ -622,15 +637,19 @@ gchar *gsb_format_gdate ( const GDate *date )
 gchar *gsb_format_gdate_safe ( const GDate *date )
 {
     gchar retour_str[SIZEOF_FORMATTED_STRING_DATE];
+    guint longueur;
 
-    if ( !date || !g_date_valid ( date ))
+    if ( !date || !g_date_valid ( date ) )
     {
-    return g_strdup ( "" );
+        return g_strdup ( "" );
     }
 
-    g_date_strftime ( retour_str, SIZEOF_FORMATTED_STRING_DATE, "%m/%d/%Y", date );
+    longueur = g_date_strftime ( retour_str, SIZEOF_FORMATTED_STRING_DATE, "%m/%d/%Y", date );
 
-    return g_strdup ( retour_str );
+    if ( longueur == 0 )
+        return NULL;
+    else
+        return g_strndup ( retour_str, longueur );
 }
 
 


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list