diff options
author | SVN Migration <svn@php.net> | 1999-07-23 14:14:44 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 1999-07-23 14:14:44 +0000 |
commit | 5cb21cbfef2dcdf31ac914920427d3d190c6ed26 (patch) | |
tree | a6ea5826ba1eda810e9580a335798c020dfaeb9a /ext/standard/base64.c | |
parent | b1617d8ac3bad1ace92085194e24cff8cbdbaf31 (diff) | |
download | php-git-php-4.0b1.tar.gz |
This commit was manufactured by cvs2svn to create tag 'php_4_0b1'.php-4.0b1
Diffstat (limited to 'ext/standard/base64.c')
-rw-r--r-- | ext/standard/base64.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/ext/standard/base64.c b/ext/standard/base64.c index d0a565fde4..70675d14e3 100644 --- a/ext/standard/base64.c +++ b/ext/standard/base64.c @@ -71,24 +71,8 @@ unsigned char *_php3_base64_encode(const unsigned char *string, int length, int unsigned char *_php3_base64_decode(const unsigned char *string, int length, int *ret_length) { const unsigned char *current = string; int ch, i = 0, j = 0, k; - /* this sucks for threaded environments */ - static short reverse_table[256]; - static int table_built; - unsigned char *result; - - if (++table_built == 1) { - char *chp; - for(ch = 0; ch < 256; ch++) { - chp = strchr(base64_table, ch); - if(chp) { - reverse_table[ch] = chp - base64_table; - } else { - reverse_table[ch] = -1; - } - } - } - result = (unsigned char *)emalloc((length / 4 * 3 + 1) * sizeof(char)); + unsigned char *result = (unsigned char *)emalloc((length / 4 * 3 + 1) * sizeof(char)); if (result == NULL) { return NULL; } @@ -96,8 +80,9 @@ unsigned char *_php3_base64_decode(const unsigned char *string, int length, int /* run through the whole string, converting as we go */ while ((ch = *current++) != '\0') { if (ch == base64_pad) break; - ch = reverse_table[ch]; - if (ch < 0) continue; + ch = (int)strchr(base64_table, ch); + if (ch == 0) continue; + ch -= (int)base64_table; switch(i % 4) { case 0: |