diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-12 07:24:11 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-12 07:24:11 +0000 |
commit | aa198dd39cad6cb41fbf6c8b64301b581a9ba206 (patch) | |
tree | 52e694aa0738e3c4b0bc110fce1a76e6a2285bf6 | |
parent | 745119605e2ecdffad1def6aaabfc8f6d270209e (diff) | |
download | busybox-w32-aa198dd39cad6cb41fbf6c8b64301b581a9ba206.tar.gz busybox-w32-aa198dd39cad6cb41fbf6c8b64301b581a9ba206.tar.bz2 busybox-w32-aa198dd39cad6cb41fbf6c8b64301b581a9ba206.zip |
uudecode: nuke duplicate base64_table[]. saves 65 bytes
-rw-r--r-- | coreutils/uudecode.c | 13 | ||||
-rw-r--r-- | libbb/uuencode.c | 5 |
2 files changed, 10 insertions, 8 deletions
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 287386d9d..2dd8f9457 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c | |||
@@ -68,8 +68,6 @@ static void read_stduu(FILE *src_stream, FILE *dst_stream) | |||
68 | 68 | ||
69 | static void read_base64(FILE *src_stream, FILE *dst_stream) | 69 | static void read_base64(FILE *src_stream, FILE *dst_stream) |
70 | { | 70 | { |
71 | static const char base64_table[] = | ||
72 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n"; | ||
73 | int term_count = 1; | 71 | int term_count = 1; |
74 | 72 | ||
75 | while (1) { | 73 | while (1) { |
@@ -80,17 +78,20 @@ static void read_base64(FILE *src_stream, FILE *dst_stream) | |||
80 | char *table_ptr; | 78 | char *table_ptr; |
81 | int ch; | 79 | int ch; |
82 | 80 | ||
83 | /* Get next _valid_ character */ | 81 | /* Get next _valid_ character. |
82 | * global vector bb_uuenc_tbl_base64[] contains this string: | ||
83 | * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n" | ||
84 | */ | ||
84 | do { | 85 | do { |
85 | ch = fgetc(src_stream); | 86 | ch = fgetc(src_stream); |
86 | if (ch == EOF) { | 87 | if (ch == EOF) { |
87 | bb_error_msg_and_die("short file"); | 88 | bb_error_msg_and_die("short file"); |
88 | } | 89 | } |
89 | table_ptr = strchr(base64_table, ch); | 90 | table_ptr = strchr(bb_uuenc_tbl_base64, ch); |
90 | } while (table_ptr == NULL); | 91 | } while (table_ptr == NULL); |
91 | 92 | ||
92 | /* Convert encoded charcter to decimal */ | 93 | /* Convert encoded character to decimal */ |
93 | ch = table_ptr - base64_table; | 94 | ch = table_ptr - bb_uuenc_tbl_base64; |
94 | 95 | ||
95 | if (*table_ptr == '=') { | 96 | if (*table_ptr == '=') { |
96 | if (term_count == 0) { | 97 | if (term_count == 0) { |
diff --git a/libbb/uuencode.c b/libbb/uuencode.c index 38401205b..bbb92d600 100644 --- a/libbb/uuencode.c +++ b/libbb/uuencode.c | |||
@@ -8,7 +8,7 @@ | |||
8 | #include "libbb.h" | 8 | #include "libbb.h" |
9 | 9 | ||
10 | /* Conversion table. for base 64 */ | 10 | /* Conversion table. for base 64 */ |
11 | const char bb_uuenc_tbl_base64[65] = { | 11 | const char bb_uuenc_tbl_base64[65 + 2] = { |
12 | 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', | 12 | 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', |
13 | 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', | 13 | 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', |
14 | 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', | 14 | 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', |
@@ -17,7 +17,8 @@ const char bb_uuenc_tbl_base64[65] = { | |||
17 | 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', | 17 | 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', |
18 | 'w', 'x', 'y', 'z', '0', '1', '2', '3', | 18 | 'w', 'x', 'y', 'z', '0', '1', '2', '3', |
19 | '4', '5', '6', '7', '8', '9', '+', '/', | 19 | '4', '5', '6', '7', '8', '9', '+', '/', |
20 | '=' /* termination character */ | 20 | '=' /* termination character */, |
21 | '\n', '\0' /* needed for uudecode.c */ | ||
21 | }; | 22 | }; |
22 | 23 | ||
23 | const char bb_uuenc_tbl_std[65] = { | 24 | const char bb_uuenc_tbl_std[65] = { |