summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-30 15:58:36 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-30 15:58:36 +0000
commit8510cbd286f507f41eee5a6a7b2423f59ba588e0 (patch)
tree052631553bd8e6c3908e3d110a648b20b28a16cf
parent53ad216214a61a50cb74a9081ea7007b3d490d39 (diff)
downloadruby-8510cbd286f507f41eee5a6a7b2423f59ba588e0.tar.gz
ruby-8510cbd286f507f41eee5a6a7b2423f59ba588e0.tar.xz
ruby-8510cbd286f507f41eee5a6a7b2423f59ba588e0.zip
* pack.c (pack_unpack): reduced static variables.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--pack.c24
2 files changed, 15 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index c1db73b63..2d4b223a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Jul 31 00:58:33 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * pack.c (pack_unpack): reduced static variables.
+
Thu Jul 31 00:10:20 2008 Yusuke Endoh <mame@tsg.ne.jp>
* proc.c (rb_proc_call_with_block): prevent null reference.
diff --git a/pack.c b/pack.c
index 4e11c5d9b..f7f51ac9f 100644
--- a/pack.c
+++ b/pack.c
@@ -1787,33 +1787,31 @@ pack_unpack(VALUE str, VALUE fmt)
VALUE buf = infected_str_new(0, (send - s)*3/4, str);
char *ptr = RSTRING_PTR(buf);
int a = -1,b = -1,c = 0,d;
- static int first = 1;
- static int b64_xtable[256];
+ static signed char b64_xtable[256];
- if (first) {
+ if (b64_xtable['/'] <= 0) {
int i;
- first = 0;
for (i = 0; i < 256; i++) {
b64_xtable[i] = -1;
}
for (i = 0; i < 64; i++) {
- b64_xtable[(int)b64_table[i]] = i;
+ b64_xtable[(unsigned char)b64_table[i]] = i;
}
}
while (s < send) {
a = b = c = d = -1;
- while((a = b64_xtable[(int)(*(unsigned char*)s)]) == -1 && s < send) { s++; }
- if( s >= send ) break;
+ while ((a = b64_xtable[(unsigned char)*s]) == -1 && s < send) {s++;}
+ if (s >= send) break;
s++;
- while((b = b64_xtable[(int)(*(unsigned char*)s)]) == -1 && s < send) { s++; }
- if( s >= send ) break;
+ while ((b = b64_xtable[(unsigned char)*s]) == -1 && s < send) {s++;}
+ if (s >= send) break;
s++;
- while((c = b64_xtable[(int)(*(unsigned char*)s)]) == -1 && s < send) { if( *s == '=' ) break; s++; }
- if( *s == '=' || s >= send ) break;
+ while ((c = b64_xtable[(unsigned char)*s]) == -1 && s < send) {if (*s == '=') break; s++;}
+ if (*s == '=' || s >= send) break;
s++;
- while((d = b64_xtable[(int)(*(unsigned char*)s)]) == -1 && s < send) { if( *s == '=' ) break; s++; }
- if( *s == '=' || s >= send ) break;
+ while ((d = b64_xtable[(unsigned char)*s]) == -1 && s < send) {if (*s == '=') break; s++;}
+ if (*s == '=' || s >= send) break;
s++;
*ptr++ = a << 2 | b >> 4;
*ptr++ = b << 4 | c >> 2;