Re: [MacRuby] #663: Kernel#sprintf formatting broken on trunk
#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@…): Crashes When calls log10(0). Sorry. X( {{{ #!diff diff --git a/string.c b/string.c index 969cc4b..517495a 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,11 @@ rb_uchar_strtol(UniChar *chars, long chars_len, long pos, long *end_offse unum_close(nf); if (end_offset != NULL) { - *end_offset = (long)parse_pos; + long offset = 0; + if(val > 0) { + offset = (long)log10((double)val); + } + *end_offset = pos + (offset + 1); // pos + size of number. } return val; } }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/663#comment:2> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby