diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-14 14:09:23 +1000 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-14 14:09:23 +1000 |
commit | ee7c9b2c212fc7db80cce945e094fc2601092283 (patch) | |
tree | 24e51b27dbc3e9ab0b00c5839a6822604c02187c /coreutils | |
parent | f28d4b20905b5b1f52ffa52060a0c6caf4b055ba (diff) | |
parent | 99862cbfad9c36b4f8f4378c3a7a9f077c239f20 (diff) | |
download | busybox-w32-ee7c9b2c212fc7db80cce945e094fc2601092283.tar.gz busybox-w32-ee7c9b2c212fc7db80cce945e094fc2601092283.tar.bz2 busybox-w32-ee7c9b2c212fc7db80cce945e094fc2601092283.zip |
Merge remote branch 'origin/master'
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/ls.c | 3 | ||||
-rw-r--r-- | coreutils/tee.c | 8 | ||||
-rw-r--r-- | coreutils/uudecode.c | 53 |
3 files changed, 32 insertions, 32 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index ab66b42c1..1a670201c 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -573,7 +573,8 @@ static unsigned print_name(const char *name) | |||
573 | putchar('\\'); | 573 | putchar('\\'); |
574 | len++; | 574 | len++; |
575 | } | 575 | } |
576 | putchar(*name++); | 576 | putchar(*name); |
577 | name++; | ||
577 | } | 578 | } |
578 | putchar('"'); | 579 | putchar('"'); |
579 | return len; | 580 | return len; |
diff --git a/coreutils/tee.c b/coreutils/tee.c index 8db9042aa..2e1e367f2 100644 --- a/coreutils/tee.c +++ b/coreutils/tee.c | |||
@@ -70,8 +70,8 @@ int tee_main(int argc, char **argv) | |||
70 | while ((c = safe_read(STDIN_FILENO, buf, sizeof(buf))) > 0) { | 70 | while ((c = safe_read(STDIN_FILENO, buf, sizeof(buf))) > 0) { |
71 | fp = files; | 71 | fp = files; |
72 | do | 72 | do |
73 | fwrite(buf, 1, c, *fp++); | 73 | fwrite(buf, 1, c, *fp); |
74 | while (*fp); | 74 | while (*++fp); |
75 | } | 75 | } |
76 | if (c < 0) { /* Make sure read errors are signaled. */ | 76 | if (c < 0) { /* Make sure read errors are signaled. */ |
77 | retval = EXIT_FAILURE; | 77 | retval = EXIT_FAILURE; |
@@ -81,8 +81,8 @@ int tee_main(int argc, char **argv) | |||
81 | while ((c = getchar()) != EOF) { | 81 | while ((c = getchar()) != EOF) { |
82 | fp = files; | 82 | fp = files; |
83 | do | 83 | do |
84 | putc(c, *fp++); | 84 | putc(c, *fp); |
85 | while (*fp); | 85 | while (*++fp); |
86 | } | 86 | } |
87 | #endif | 87 | #endif |
88 | 88 | ||
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 207fb0b8d..0da9b0988 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c | |||
@@ -77,18 +77,21 @@ static void read_stduu(FILE *src_stream, FILE *dst_stream) | |||
77 | 77 | ||
78 | static void read_base64(FILE *src_stream, FILE *dst_stream) | 78 | static void read_base64(FILE *src_stream, FILE *dst_stream) |
79 | { | 79 | { |
80 | int term_count = 1; | 80 | int term_count = 0; |
81 | 81 | ||
82 | while (1) { | 82 | while (1) { |
83 | unsigned char translated[4]; | 83 | unsigned char translated[4]; |
84 | int count = 0; | 84 | int count = 0; |
85 | 85 | ||
86 | /* Process one group of 4 chars */ | ||
86 | while (count < 4) { | 87 | while (count < 4) { |
87 | char *table_ptr; | 88 | char *table_ptr; |
88 | int ch; | 89 | int ch; |
89 | 90 | ||
90 | /* Get next _valid_ character. | 91 | /* Get next _valid_ character. |
91 | * global vector bb_uuenc_tbl_base64[] contains this string: | 92 | * bb_uuenc_tbl_base64[] contains this string: |
93 | * 0 1 2 3 4 5 6 | ||
94 | * 012345678901234567890123456789012345678901234567890123456789012345 | ||
92 | * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n" | 95 | * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n" |
93 | */ | 96 | */ |
94 | do { | 97 | do { |
@@ -103,42 +106,38 @@ static void read_base64(FILE *src_stream, FILE *dst_stream) | |||
103 | bb_error_msg_and_die("short file"); | 106 | bb_error_msg_and_die("short file"); |
104 | } | 107 | } |
105 | table_ptr = strchr(bb_uuenc_tbl_base64, ch); | 108 | table_ptr = strchr(bb_uuenc_tbl_base64, ch); |
106 | } while (table_ptr == NULL); | 109 | } while (!table_ptr); |
107 | 110 | ||
108 | /* Convert encoded character to decimal */ | 111 | /* Convert encoded character to decimal */ |
109 | ch = table_ptr - bb_uuenc_tbl_base64; | 112 | ch = table_ptr - bb_uuenc_tbl_base64; |
110 | 113 | ||
111 | if (*table_ptr == '=') { | 114 | if (ch == 65 /* '\n' */) { |
112 | if (term_count == 0) { | 115 | /* Terminating "====" line? */ |
113 | translated[count] = '\0'; | 116 | if (term_count == 4) |
114 | break; | 117 | return; /* yes */ |
115 | } | ||
116 | term_count++; | ||
117 | } else if (*table_ptr == '\n') { | ||
118 | /* Check for terminating line */ | ||
119 | if (term_count == 5) { | ||
120 | return; | ||
121 | } | ||
122 | term_count = 1; | ||
123 | continue; | ||
124 | } else { | ||
125 | translated[count] = ch; | ||
126 | count++; | ||
127 | term_count = 0; | 118 | term_count = 0; |
119 | continue; | ||
120 | } | ||
121 | /* ch is 64 is char was '=', otherwise 0..63 */ | ||
122 | translated[count] = ch & 63; /* 64 -> 0 */ | ||
123 | if (ch == 64) { | ||
124 | term_count++; | ||
125 | break; | ||
128 | } | 126 | } |
127 | count++; | ||
129 | } | 128 | } |
130 | 129 | ||
131 | /* Merge 6 bit chars to 8 bit */ | 130 | /* Merge 6 bit chars to 8 bit. |
132 | if (count > 1) { | 131 | * count can be < 4 when we decode the tail: |
132 | * "eQ==" -> "y", not "y NUL NUL" | ||
133 | */ | ||
134 | if (count > 1) | ||
133 | fputc(translated[0] << 2 | translated[1] >> 4, dst_stream); | 135 | fputc(translated[0] << 2 | translated[1] >> 4, dst_stream); |
134 | } | 136 | if (count > 2) |
135 | if (count > 2) { | ||
136 | fputc(translated[1] << 4 | translated[2] >> 2, dst_stream); | 137 | fputc(translated[1] << 4 | translated[2] >> 2, dst_stream); |
137 | } | 138 | if (count > 3) |
138 | if (count > 3) { | ||
139 | fputc(translated[2] << 6 | translated[3], dst_stream); | 139 | fputc(translated[2] << 6 | translated[3], dst_stream); |
140 | } | 140 | } /* while (1) */ |
141 | } | ||
142 | } | 141 | } |
143 | 142 | ||
144 | #if ENABLE_UUDECODE | 143 | #if ENABLE_UUDECODE |