summaryrefslogtreecommitdiff
path: root/pack.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-03 13:32:14 (GMT)
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-03 13:32:14 (GMT)
commitb2be623240af7b3318596fa348d2c7920f8703b5 (patch)
tree475d7bd4aeac575fe74120e102be3a2211c4f313 /pack.c
parent48ebea719f4478245a90352cfbfd5146ce65ca9e (diff)
* 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
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/pack.c b/pack.c
index 67b0bc2..aba976a 100644
--- a/pack.c
+++ b/pack.c
@@ -1047,19 +1047,11 @@ qpencode(VALUE str, VALUE from, long len)
static inline int
hex2num(char c)
{
- switch (c) {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- return c - '0';
- case 'a': case 'b': case 'c':
- 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;
- }
+ int n;
+ n = ruby_digit36_to_number_table[(unsigned char)c];
+ if (16 <= n)
+ n = -1;
+ return n;
}
#define PACK_LENGTH_ADJUST_SIZE(sz) do { \