[grisbi-cvs] grisbi/src gsb_real.c,1.58,1.59
Gunee
guneemwelloeux at users.sourceforge.net
Thu Nov 26 18:20:31 CET 2009
Update of /cvsroot/grisbi/grisbi/src
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv8577/src
Modified Files:
gsb_real.c
Log Message:
Fix for the changing amounts (factor 1e+3). Reason: comma was considered to be a decimal separator in all locales (not true for en_US for example)
Index: gsb_real.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_real.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- gsb_real.c 23 Nov 2009 17:07:22 -0000 1.58
+++ gsb_real.c 26 Nov 2009 17:20:29 -0000 1.59
@@ -353,8 +353,8 @@
const gchar *mon_thousands_sep,
const gchar *mon_decimal_point )
{
- static const gchar *space_chars = " ";
- static const gchar *decimal_chars = ".,";
+ static gchar *space_chars;
+ static gchar *decimal_chars;
static const gchar *positive_chars = "+";
static const gchar *negative_chars = "-";
@@ -376,6 +376,8 @@
? strlen ( mon_thousands_sep )
: 0;
mdp_len = mon_decimal_point ? strlen ( mon_decimal_point ) : 0;
+ decimal_chars = g_strconcat(".", mon_decimal_point, NULL);
+ space_chars = g_strconcat(" ", mon_thousands_sep, NULL);
for ( ; ; )
{
@@ -398,14 +400,12 @@
: 0;
return result;
}
- else if ( strchr ( space_chars, *p )
- || ( mts_len && ( strncmp ( p, mon_thousands_sep, mts_len ) == 0 ) ) )
+ else if ( strchr ( space_chars, *p ) )
{
// just skip spaces and thousands separators
p = g_utf8_find_next_char ( p, NULL );
}
- else if ( strchr ( decimal_chars, *p )
- || ( mdp_len && ( strncmp ( p, mon_decimal_point, mdp_len ) == 0 ) ) )
+ else if ( strchr ( decimal_chars, *p ) )
{
if ( dot_position >= 0 ) // already found a decimal separator
return error_real;
@@ -884,11 +884,18 @@
{
gchar *str2, **numb, **ff, **ss, *err;
gchar *sss, *ttt, *f, *s, *a, *b;
+ static gchar *space_chars;
+ static gchar *decimal_chars;
int decimals;
glong nombre;
gsb_real resu;
gsb_real null_real = { 0 , 0 };
gsb_real error_real = { 0x80000000, 0 };
+ struct lconv *loc;
+
+ loc = localeconv();
+ decimal_chars = g_locale_to_utf8 ( g_strconcat ( ".", loc->mon_decimal_point, NULL ), -1, NULL, NULL, NULL );
+ space_chars = g_locale_to_utf8 ( g_strconcat ( " ", loc->mon_thousands_sep, NULL ), -1, NULL, NULL, NULL );
if ( !g_utf8_validate ( str, -1, NULL ) )
str2 = g_locale_to_utf8 ( str, -1, NULL, NULL, NULL );
@@ -897,8 +904,9 @@
if(!str2 || !g_utf8_strlen( str2 , -1 ))
return null_real;
- numb = g_strsplit_set(str2, ",.",2);
+ numb = g_strsplit_set(str2, decimal_chars, 2);
g_free(str2);
+ g_free(decimal_chars);
if( !numb[0] || !g_utf8_strlen( numb[0] , -1 ))
a = g_strdup ( "0" );
else
@@ -908,10 +916,11 @@
else
b = g_strdup(numb[1]);
g_strfreev(numb);
- ff = g_strsplit ( a , " ", -1);
- ss = g_strsplit ( b , " ", -1);
+ ff = g_strsplit_set ( a , space_chars, -1);
+ ss = g_strsplit_set ( b , space_chars, -1);
g_free(a);
g_free(b);
+ g_free(space_chars);
f = g_strjoinv ("", ff);
s = g_strjoinv ("", ss);
g_strfreev ( ff );
More information about the cvs
mailing list