ruby-changes:25723
From: tadf <ko1@a...>
Date: Wed, 21 Nov 2012 18:49:02 +0900 (JST)
Subject: [ruby-changes:25723] tadf:r37780 (trunk): * rational.c (read_digits): due to a bit tighter rb_cstr_to_inum().
tadf 2012-11-21 18:48:51 +0900 (Wed, 21 Nov 2012) New Revision: 37780 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37780 Log: * rational.c (read_digits): due to a bit tighter rb_cstr_to_inum(). Modified files: trunk/ChangeLog trunk/rational.c Index: ChangeLog =================================================================== --- ChangeLog (revision 37779) +++ ChangeLog (revision 37780) @@ -1,3 +1,7 @@ +Wed Nov 21 18:46:37 2012 Tadayoshi Funaba <tadf@d...> + + * rational.c (read_digits): due to a bit tighter rb_cstr_to_inum(). + Wed Nov 21 16:13:37 2012 Koichi Sasada <ko1@a...> * benchmark/bm_so_nsieve_bits.rb: add an encoding pragma because Index: rational.c =================================================================== --- rational.c (revision 37779) +++ rational.c (revision 37780) @@ -1986,14 +1986,16 @@ read_digits(const char **s, int strict, VALUE *num, int *count) { + char *b, *bb; int us = 1, ret = 1; - const char *b = *s; if (!isdecimal(**s)) { *num = ZERO; return 0; } + bb = b = ALLOCA_N(char, strlen(*s) + 1); + while (isdecimal(**s) || **s == '_') { if (**s == '_') { if (strict) { @@ -2007,6 +2009,7 @@ else { if (count) (*count)++; + *b++ = **s; us = 0; } (*s)++; @@ -2016,7 +2019,8 @@ (*s)--; } while (**s == '_'); conv: - *num = rb_cstr_to_inum(b, 10, 0); + *b = '\0'; + *num = rb_cstr_to_inum(bb, 10, 0); return ret; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/