[grisbi-cvs] grisbi/src gsb_real.c,1.32,1.33
Pierre Biava
pbiava at users.sourceforge.net
Sat May 9 23:30:14 CEST 2009
- Previous message: [grisbi-cvs] grisbi/src gsb_real.c,1.31,1.32
- Next message: [grisbi-cvs] grisbi/src affichage.c, 1.157, 1.158 affichage_liste.c, 1.107, 1.108 barre_outils.c, 1.126, 1.127 fenetre_principale.c, 1.111, 1.112 gsb_account.c, 1.45, 1.46 gsb_account_property.c, 1.36, 1.37 gsb_autofunc.c, 1.22, 1.23 gsb_automem.c, 1.25, 1.26 gsb_bank.c, 1.22, 1.23 gsb_currency_config.c, 1.51, 1.52 gsb_currency_link_config.c, 1.11, 1.12 gsb_data_account.c, 1.72, 1.73 gsb_debug.c, 1.12, 1.13 gsb_file.c, 1.47, 1.48 gsb_form.c, 1.121, 1.122 gsb_form_config.c, 1.30, 1.31 gsb_form_widget.c, 1.30, 1.31 gsb_fyear.c, 1.8, 1.9 gsb_payment_method.c, 1.16, 1.17 gsb_payment_method_config.c, 1.35, 1.36 gsb_real.c, 1.33, 1.34 gsb_real.h, 1.13, 1.14 gsb_reconcile.c, 1.37, 1.38 gsb_reconcile_config.c, 1.28, 1.29 gsb_reconcile_sort_config.c, 1.10, 1.11 gsb_scheduler.c, 1.24, 1.25 gsb_scheduler_list.c, 1.64, 1.65 gsb_transactions_list.c, 1.161, 1.162 gsb_transactions_list_sort.c, 1.13, 1.14 import.c, 1.277, 1.278 parametres.c, 1.193, 1.194 traitement_variables.c, 1.172, 1.173 transaction_list.c, 1.35, 1.36
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/grisbi/grisbi/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv24702
Modified Files:
gsb_real.c
Log Message:
various optimization
Index: gsb_real.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_real.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- gsb_real.c 9 May 2009 17:04:37 -0000 1.32
+++ gsb_real.c 9 May 2009 21:30:12 -0000 1.33
@@ -42,11 +42,12 @@
/*START_STATIC*/
static gchar *gsb_real_format_string ( gsb_real number,
- gint currency_number,
- gboolean show_symbol );
-static gsb_real gsb_real_get_from_string_normalized ( const gchar *string, gint default_exponent );
+ gint currency_number,
+ gboolean show_symbol );
+static gsb_real gsb_real_get_from_string_normalized ( const gchar *string,
+ gint default_exponent );
static gboolean gsb_real_normalize ( gsb_real *number_1,
- gsb_real *number_2 );
+ gsb_real *number_2 );
static gdouble gsb_real_real_to_double ( gsb_real number );
/*END_STATIC*/
@@ -55,7 +56,6 @@
/*END_EXTERN*/
-
/**
* Return the real in a formatted string, according to the currency
* regarding decimal separator, thousands separator and positive or
@@ -85,8 +85,8 @@
* \return a newly allocated string of the number
* */
gchar *gsb_real_get_string_with_currency ( gsb_real number,
- gint currency_number,
- gboolean show_symbol )
+ gint currency_number,
+ gboolean show_symbol )
{
gchar *string;
@@ -184,7 +184,6 @@
gchar *ptr_char, *ptr_fin = NULL;
gchar *dest = NULL;
gchar *ch;
- gint i = 0;
reverse = g_utf8_strreverse ( mantissa, -1 );
dest = g_malloc0 ( 30 * sizeof (gunichar));
@@ -192,16 +191,20 @@
nbre_char = g_utf8_strlen ( reverse, -1);
ptr_char = reverse;
ptr_fin = dest;
- for (i = 0; i < nbre_char; i++)
+ while ( (nbre_char = g_utf8_strlen (ptr_char, -1)) > 0)
{
- ch = g_strndup (ptr_char, 1);
- if ( i == 3 )
- ptr_fin = g_stpcpy (ptr_fin, mon_thousands_sep_utf8 );
+ ch = g_strndup (ptr_char, 3);
ptr_fin = g_stpcpy ( ptr_fin, ch );
- ptr_char = g_utf8_next_char ( ptr_char );
+ g_free ( ch );
+ ptr_fin = g_stpcpy (ptr_fin, mon_thousands_sep_utf8 );
- if (ptr_char == NULL) break;
+ nbre_char = g_utf8_strlen ( ptr_char, -1 );
+ if ( nbre_char > 3 )
+ ptr_char = g_utf8_offset_to_pointer ( ptr_char, 3 );
+ else
+ ptr_char = g_utf8_offset_to_pointer ( ptr_char, nbre_char );
}
+
mantissa = g_utf8_strreverse ( dest, -1 );
g_free ( reverse );
g_free ( dest );
@@ -292,7 +295,10 @@
if ( !string
||
- !strlen (string))
+ !strlen (string) )
+ return number;
+
+ if ( g_strcmp0 (string, "0") == 0 )
return number;
new_str = my_strdup (string);
@@ -333,7 +339,6 @@
}
-
/**
* compare 2 gsb_real and return the result (-1, 0, 1)
*
@@ -343,7 +348,7 @@
* \return -1 if number_1 < number_2 ; 0 if number_1 = number_2 ; 1 if number_1 > number_2
* */
gint gsb_real_cmp ( gsb_real number_1,
- gsb_real number_2 )
+ gsb_real number_2 )
{
gsb_real_normalize ( &number_1,
&number_2 );
@@ -366,7 +371,7 @@
* \return TRUE
* */
gboolean gsb_real_normalize ( gsb_real *number_1,
- gsb_real *number_2 )
+ gsb_real *number_2 )
{
glong limit_number;
gboolean invert = FALSE;
@@ -436,7 +441,7 @@
* \return the transformed number
* */
gsb_real gsb_real_adjust_exponent ( gsb_real number,
- gint return_exponent )
+ gint return_exponent )
{
gdouble tmp;
@@ -477,7 +482,7 @@
* \return a gsb_real = number_1 + number_2
* */
gsb_real gsb_real_add ( gsb_real number_1,
- gsb_real number_2 )
+ gsb_real number_2 )
{
gsb_real number = number_1;
@@ -497,7 +502,7 @@
* \return a gsb_real = number_1 - number_2
* */
gsb_real gsb_real_sub ( gsb_real number_1,
- gsb_real number_2 )
+ gsb_real number_2 )
{
gsb_real number = number_1;
@@ -533,7 +538,7 @@
* \return the multiplication between the 2
* */
gsb_real gsb_real_mul ( gsb_real number_1,
- gsb_real number_2 )
+ gsb_real number_2 )
{
number_1.mantissa *= number_2.mantissa;
number_1.exponent += number_2.exponent;
@@ -550,7 +555,7 @@
* \return the multiplication between the 2
* */
gsb_real gsb_real_div ( gsb_real number_1,
- gsb_real number_2 )
+ gsb_real number_2 )
{
gsb_real number;
- Previous message: [grisbi-cvs] grisbi/src gsb_real.c,1.31,1.32
- Next message: [grisbi-cvs] grisbi/src affichage.c, 1.157, 1.158 affichage_liste.c, 1.107, 1.108 barre_outils.c, 1.126, 1.127 fenetre_principale.c, 1.111, 1.112 gsb_account.c, 1.45, 1.46 gsb_account_property.c, 1.36, 1.37 gsb_autofunc.c, 1.22, 1.23 gsb_automem.c, 1.25, 1.26 gsb_bank.c, 1.22, 1.23 gsb_currency_config.c, 1.51, 1.52 gsb_currency_link_config.c, 1.11, 1.12 gsb_data_account.c, 1.72, 1.73 gsb_debug.c, 1.12, 1.13 gsb_file.c, 1.47, 1.48 gsb_form.c, 1.121, 1.122 gsb_form_config.c, 1.30, 1.31 gsb_form_widget.c, 1.30, 1.31 gsb_fyear.c, 1.8, 1.9 gsb_payment_method.c, 1.16, 1.17 gsb_payment_method_config.c, 1.35, 1.36 gsb_real.c, 1.33, 1.34 gsb_real.h, 1.13, 1.14 gsb_reconcile.c, 1.37, 1.38 gsb_reconcile_config.c, 1.28, 1.29 gsb_reconcile_sort_config.c, 1.10, 1.11 gsb_scheduler.c, 1.24, 1.25 gsb_scheduler_list.c, 1.64, 1.65 gsb_transactions_list.c, 1.161, 1.162 gsb_transactions_list_sort.c, 1.13, 1.14 import.c, 1.277, 1.278 parametres.c, 1.193, 1.194 traitement_variables.c, 1.172, 1.173 transaction_list.c, 1.35, 1.36
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cvs
mailing list