svn commit: trunk/busybox: coreutils libbb
vda at busybox.net
vda at busybox.net
Tue Jun 12 07:24:13 UTC 2007
Author: vda
Date: 2007-06-12 00:24:11 -0700 (Tue, 12 Jun 2007)
New Revision: 18797
Log:
uudecode: nuke duplicate base64_table[]. saves 65 bytes
Modified:
trunk/busybox/coreutils/uudecode.c
trunk/busybox/libbb/uuencode.c
Changeset:
Modified: trunk/busybox/coreutils/uudecode.c
===================================================================
--- trunk/busybox/coreutils/uudecode.c 2007-06-11 16:31:55 UTC (rev 18796)
+++ trunk/busybox/coreutils/uudecode.c 2007-06-12 07:24:11 UTC (rev 18797)
@@ -68,8 +68,6 @@
static void read_base64(FILE *src_stream, FILE *dst_stream)
{
- static const char base64_table[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n";
int term_count = 1;
while (1) {
@@ -80,17 +78,20 @@
char *table_ptr;
int ch;
- /* Get next _valid_ character */
+ /* Get next _valid_ character.
+ * global vector bb_uuenc_tbl_base64[] contains this string:
+ * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n"
+ */
do {
ch = fgetc(src_stream);
if (ch == EOF) {
bb_error_msg_and_die("short file");
}
- table_ptr = strchr(base64_table, ch);
+ table_ptr = strchr(bb_uuenc_tbl_base64, ch);
} while (table_ptr == NULL);
- /* Convert encoded charcter to decimal */
- ch = table_ptr - base64_table;
+ /* Convert encoded character to decimal */
+ ch = table_ptr - bb_uuenc_tbl_base64;
if (*table_ptr == '=') {
if (term_count == 0) {
Modified: trunk/busybox/libbb/uuencode.c
===================================================================
--- trunk/busybox/libbb/uuencode.c 2007-06-11 16:31:55 UTC (rev 18796)
+++ trunk/busybox/libbb/uuencode.c 2007-06-12 07:24:11 UTC (rev 18797)
@@ -8,7 +8,7 @@
#include "libbb.h"
/* Conversion table. for base 64 */
-const char bb_uuenc_tbl_base64[65] = {
+const char bb_uuenc_tbl_base64[65 + 2] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
@@ -17,7 +17,8 @@
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/',
- '=' /* termination character */
+ '=' /* termination character */,
+ '\n', '\0' /* needed for uudecode.c */
};
const char bb_uuenc_tbl_std[65] = {
More information about the busybox-cvs
mailing list