[MacRuby] #663: Kernel#sprintf formatting broken on trunk
MacRuby
ruby-noreply at macosforge.org
Mon Aug 16 02:45:58 PDT 2010
#663: Kernel#sprintf formatting broken on trunk
-------------------------------------+--------------------------------------
Reporter: jordan.breeding@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone: MacRuby 0.6
Component: MacRuby | Keywords:
-------------------------------------+--------------------------------------
Comment(by watson1978@…):
I think this problem to be a bug of the rb_uchar_strtol().[[BR]]
When parsed the "6.2", rb_uchar_strtol() returns
* returns = 6
* end_offset = 3
But, expected
* returns = 6
* end_offset = 1
Too big end_offset so that does not parse ".2".[[BR]]
Actually the "%6.2f" is treated with "%6f".
{{{
#!diff
diff --git a/string.c b/string.c
index 969cc4b..cc1a735 100644
--- a/string.c
+++ b/string.c
@@ -13,6 +13,7 @@
#include <stdarg.h>
#include <wctype.h>
#include <unistd.h>
+#include <math.h>
#include "ruby/macruby.h"
#include "ruby/encoding.h"
@@ -6495,7 +6496,7 @@ rb_uchar_strtol(UniChar *chars, long chars_len, long
pos, long *end_offset)
unum_close(nf);
if (end_offset != NULL) {
- *end_offset = (long)parse_pos;
+ *end_offset = pos + ((long)log10((double)val) + 1); // pos + size
of number.
}
return val;
}
}}}
--
Ticket URL: <http://www.macruby.org/trac/ticket/663#comment:1>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list