* internal.h (ruby_digit36_to_number_table): Declared.
* util.c (ruby_digit36_to_number_table): Moved from scan_digits. * bignum.c (conv_digit): Use ruby_digit36_to_number_table. * pack.c (hex2num): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
48ebea719f
commit
b2be623240
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Wed Jul 3 22:29:20 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* internal.h (ruby_digit36_to_number_table): Declared.
|
||||||
|
|
||||||
|
* util.c (ruby_digit36_to_number_table): Moved from scan_digits.
|
||||||
|
|
||||||
|
* bignum.c (conv_digit): Use ruby_digit36_to_number_table.
|
||||||
|
|
||||||
|
* pack.c (hex2num): Ditto.
|
||||||
|
|
||||||
Wed Jul 3 18:12:56 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Jul 3 18:12:56 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/mkmf.rb (install_dirs): revert DESTDIR prefix by r39841, since
|
* lib/mkmf.rb (install_dirs): revert DESTDIR prefix by r39841, since
|
||||||
|
7
bignum.c
7
bignum.c
@ -1916,12 +1916,7 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
|
|||||||
|
|
||||||
#undef ISDIGIT
|
#undef ISDIGIT
|
||||||
#define ISDIGIT(c) ('0' <= (c) && (c) <= '9')
|
#define ISDIGIT(c) ('0' <= (c) && (c) <= '9')
|
||||||
#define conv_digit(c) \
|
#define conv_digit(c) (ruby_digit36_to_number_table[(unsigned char)(c)])
|
||||||
(!ISASCII(c) ? -1 : \
|
|
||||||
ISDIGIT(c) ? ((c) - '0') : \
|
|
||||||
ISLOWER(c) ? ((c) - 'a' + 10) : \
|
|
||||||
ISUPPER(c) ? ((c) - 'A' + 10) : \
|
|
||||||
-1)
|
|
||||||
|
|
||||||
if (!str) {
|
if (!str) {
|
||||||
if (badcheck) goto bad;
|
if (badcheck) goto bad;
|
||||||
|
@ -530,6 +530,9 @@ int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, cha
|
|||||||
VALUE rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash);
|
VALUE rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash);
|
||||||
void rb_execarg_setenv(VALUE execarg_obj, VALUE env);
|
void rb_execarg_setenv(VALUE execarg_obj, VALUE env);
|
||||||
|
|
||||||
|
/* util.c */
|
||||||
|
extern const signed char ruby_digit36_to_number_table[];
|
||||||
|
|
||||||
/* variable.c */
|
/* variable.c */
|
||||||
void rb_gc_mark_global_tbl(void);
|
void rb_gc_mark_global_tbl(void);
|
||||||
void rb_mark_generic_ivar(VALUE);
|
void rb_mark_generic_ivar(VALUE);
|
||||||
|
18
pack.c
18
pack.c
@ -1047,19 +1047,11 @@ qpencode(VALUE str, VALUE from, long len)
|
|||||||
static inline int
|
static inline int
|
||||||
hex2num(char c)
|
hex2num(char c)
|
||||||
{
|
{
|
||||||
switch (c) {
|
int n;
|
||||||
case '0': case '1': case '2': case '3': case '4':
|
n = ruby_digit36_to_number_table[(unsigned char)c];
|
||||||
case '5': case '6': case '7': case '8': case '9':
|
if (16 <= n)
|
||||||
return c - '0';
|
n = -1;
|
||||||
case 'a': case 'b': case 'c':
|
return n;
|
||||||
case 'd': case 'e': case 'f':
|
|
||||||
return c - 'a' + 10;
|
|
||||||
case 'A': case 'B': case 'C':
|
|
||||||
case 'D': case 'E': case 'F':
|
|
||||||
return c - 'A' + 10;
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PACK_LENGTH_ADJUST_SIZE(sz) do { \
|
#define PACK_LENGTH_ADJUST_SIZE(sz) do { \
|
||||||
|
11
util.c
11
util.c
@ -55,10 +55,7 @@ ruby_scan_hex(const char *start, size_t len, size_t *retlen)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long
|
const signed char ruby_digit36_to_number_table[] = {
|
||||||
scan_digits(const char *str, int base, size_t *retlen, int *overflow)
|
|
||||||
{
|
|
||||||
static const signed char table[] = {
|
|
||||||
/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
|
/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
|
||||||
/*0*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
/*0*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
/*1*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
/*1*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
@ -78,6 +75,10 @@ scan_digits(const char *str, int base, size_t *retlen, int *overflow)
|
|||||||
/*f*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
/*f*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static unsigned long
|
||||||
|
scan_digits(const char *str, int base, size_t *retlen, int *overflow)
|
||||||
|
{
|
||||||
|
|
||||||
const char *start = str;
|
const char *start = str;
|
||||||
unsigned long ret = 0, x;
|
unsigned long ret = 0, x;
|
||||||
unsigned long mul_overflow = (~(unsigned long)0) / base;
|
unsigned long mul_overflow = (~(unsigned long)0) / base;
|
||||||
@ -85,7 +86,7 @@ scan_digits(const char *str, int base, size_t *retlen, int *overflow)
|
|||||||
*overflow = 0;
|
*overflow = 0;
|
||||||
|
|
||||||
while ((c = (unsigned char)*str++) != '\0') {
|
while ((c = (unsigned char)*str++) != '\0') {
|
||||||
int d = table[c];
|
int d = ruby_digit36_to_number_table[c];
|
||||||
if (d == -1 || base <= d) {
|
if (d == -1 || base <= d) {
|
||||||
*retlen = (str-1) - start;
|
*retlen = (str-1) - start;
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user