summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--src/cr-tknzr.c6
-rw-r--r--src/cr-utils.c5
-rw-r--r--src/cr-utils.h2
4 files changed, 13 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 4a541f1..a529217 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-03-01 Dom Lachowicz <cinamod@hotmail.com>
+
+ * src/cr-tknzr.c: Parse fractional parts of numbers properly (bug 333057)
+ * src/cr-utils.[ch]: Ditto
+
2005-11-16 Tor Lillqvist <tml@novell.com>
* libcroco-zip.in: New file. libcroco-zip is used to build a
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) ;