[grisbi-cvs] grisbi/src gsb_real.c,1.70,1.71

Pierre Biava pbiava at users.sourceforge.net
Mon Mar 8 23:31:55 CET 2010


Update of /cvsroot/grisbi/grisbi/src
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv3535

Modified Files:
	gsb_real.c 
Log Message:
minor correction

Index: gsb_real.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_real.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- gsb_real.c	28 Feb 2010 08:40:57 -0000	1.70
+++ gsb_real.c	8 Mar 2010 22:31:53 -0000	1.71
@@ -369,9 +369,13 @@
     static gchar *decimal_chars;
     static const gchar *positive_chars = "+";
     static const gchar *negative_chars = "-";
-
-	unsigned mts_len;
-	unsigned mdp_len;
+    static const gchar *decimal_char_dot = ".";
+    static const gchar *decimal_char_comma = ",";
+    static const gchar *empty_char = "" ;
+    const gchar *default_decimal_char_dot = decimal_char_dot;
+    const gchar *default_decimal_char_comma = decimal_char_comma;
+    unsigned mts_len;
+    unsigned mdp_len;
     unsigned nb_digits = 0;
     gint64 mantissa = 0;
     gint8 sign = 0;
@@ -385,11 +389,19 @@
                        ? strlen ( mon_thousands_sep )
                        : 0;
     mdp_len = mon_decimal_point ? strlen ( mon_decimal_point ) : 0;
-    if ( !strchr ( mon_thousands_sep, '.' ))
-        decimal_chars = g_strconcat(".", mon_decimal_point, NULL);
-    else
-        decimal_chars = g_strdup(mon_decimal_point);
-	space_chars = g_strconcat(" ", mon_thousands_sep, NULL);
+
+    if ( mon_thousands_sep )
+    {
+        if ( g_strstr_len ( mon_thousands_sep, -1, decimal_char_dot ) )
+            default_decimal_char_dot = empty_char;
+        if ( g_strstr_len ( mon_thousands_sep, -1, decimal_char_comma ) )
+            default_decimal_char_comma = empty_char ;
+    }
+
+    decimal_chars = g_strconcat(default_decimal_char_dot,
+             default_decimal_char_comma,
+             mon_decimal_point,
+             NULL);
 
     for ( ; ; )
     {
@@ -412,7 +424,7 @@
                               : 0;
             return result;
         }
-        else if ( strchr ( decimal_chars, *p ) )
+        else if ( decimal_chars && strchr ( decimal_chars, *p ) )
         {
             if ( dot_position >= 0 ) // already found a decimal separator
                 return error_real;
@@ -443,6 +455,9 @@
             return error_real;
         }
     }
+     /* Free memory */
+     g_free ( decimal_chars );
+     g_free ( space_chars );
 }
 
 



More information about the cvs mailing list