summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDom Lachowicz <doml@src.gnome.org>2006-03-02 01:13:01 +0000
committerDom Lachowicz <doml@src.gnome.org>2006-03-02 01:13:01 +0000
commitc7d1ea6efefbf3293bff617bddc4699219b543a0 (patch)
treecf619c2bbf0c47bc85be8d8830bf04e194280568 /src
parent9dc32d6f472e367208527366fb7830d69aa3fb15 (diff)
downloadlibcroco-c7d1ea6efefbf3293bff617bddc4699219b543a0.tar.gz
Parse fractional parts of numbers properly (bug 333057)
Diffstat (limited to 'src')
-rw-r--r--src/cr-tknzr.c6
-rw-r--r--src/cr-utils.c5
-rw-r--r--src/cr-utils.h2
3 files changed, 8 insertions, 5 deletions
diff --git a/src/cr-tknzr.c b/src/cr-tknzr.c
index 7f2d2c6..34f0b4c 100644
--- a/src/cr-tknzr.c
+++ b/src/cr-tknzr.c
@@ -1489,7 +1489,8 @@ cr_tknzr_parse_num (CRTknzr * a_this,
guint32 cur_char = 0,
int_part = 0,
dec_part = 0,
- next_char = 0;
+ next_char = 0,
+ decimal_places = 0;
CRInputPos init_pos;
CRParsingLocation location = {0} ;
@@ -1534,6 +1535,7 @@ cr_tknzr_parse_num (CRTknzr * a_this,
if (parsing_dec == FALSE) {
int_part = int_part * 10 + (cur_char - '0');
} else {
+ decimal_places++;
dec_part = dec_part * 10 + (cur_char - '0');
}
} else {
@@ -1552,7 +1554,7 @@ cr_tknzr_parse_num (CRTknzr * a_this,
gdouble val = 0.0;
val = int_part;
- val += cr_utils_n_to_0_dot_n (dec_part);
+ val += cr_utils_n_to_0_dot_n (dec_part, decimal_places);
if (*a_num == NULL) {
*a_num = cr_num_new_with_val (val, val_type);
diff --git a/src/cr-utils.c b/src/cr-utils.c
index f5505c7..8690b85 100644
--- a/src/cr-utils.c
+++ b/src/cr-utils.c
@@ -1293,12 +1293,13 @@ cr_utils_dump_n_chars2 (guchar a_char, GString * a_string, glong a_nb)
}
gdouble
-cr_utils_n_to_0_dot_n (glong a_n)
+cr_utils_n_to_0_dot_n (glong a_n, glong decimal_places)
{
gdouble result = a_n;
- while (ABS (result) > 1) {
+ while (decimal_places > 0) {
result = result / 10;
+ decimal_places--;
}
return result;
diff --git a/src/cr-utils.h b/src/cr-utils.h
index 535e817..6f03946 100644
--- a/src/cr-utils.h
+++ b/src/cr-utils.h
@@ -236,7 +236,7 @@ cr_utils_dump_n_chars2 (guchar a_char,
GString *a_string,
glong a_nb) ;
gdouble
-cr_utils_n_to_0_dot_n (glong a_n) ;
+cr_utils_n_to_0_dot_n (glong a_n, glong decimal_places) ;
GList *
cr_utils_dup_glist_of_string (GList *a_list) ;