ntpd: default to FEATURE_NTP_AUTH=y
[oweals/busybox.git] / coreutils / uudecode.c
index ddce2548b87b7b77dd546ef602e46c7b365e3e1d..5ef05ee4d6beb641ab3bcc6a9797864603603ff1 100644 (file)
  * "end" line
  */
 //config:config UUDECODE
-//config:      bool "uudecode"
+//config:      bool "uudecode (5.9 kb)"
 //config:      default y
 //config:      help
-//config:        uudecode is used to decode a uuencoded file.
+//config:      uudecode is used to decode a uuencoded file.
 
 //applet:IF_UUDECODE(APPLET(uudecode, BB_DIR_USR_BIN, BB_SUID_DROP))
 
@@ -47,10 +47,16 @@ static void FAST_FUNC read_stduu(FILE *src_stream, FILE *dst_stream, int flags U
                line = xmalloc_fgets_str_len(src_stream, "\n", &line_len);
                if (!line)
                        break;
-               /* Handle both Unix and MSDOS text, and stray trailing spaces */
+               /* Handle both Unix and MSDOS text.
+                * Note: space should not be trimmed, some encoders use it instead of "`"
+                * for padding of last incomplete 4-char block.
+                */
                str_len = line_len;
-               while (--str_len >= 0 && isspace(line[str_len]))
+               while (--str_len >= 0
+                && (line[str_len] == '\n' || line[str_len] == '\r')
+               ) {
                        line[str_len] = '\0';
+               }
 
                if (strcmp(line, "end") == 0) {
                        return; /* the only non-error exit */
@@ -65,7 +71,7 @@ static void FAST_FUNC read_stduu(FILE *src_stream, FILE *dst_stream, int flags U
 
                encoded_len = line[0] * 4 / 3;
                /* Check that line is not too short. (we tolerate
-                * overly _long_ line to accommodate possible extra '`').
+                * overly _long_ line to accommodate possible extra "`").
                 * Empty line case is also caught here. */
                if (str_len <= encoded_len) {
                        break; /* go to bb_error_msg_and_die("short file"); */
@@ -114,8 +120,7 @@ int uudecode_main(int argc UNUSED_PARAM, char **argv)
        char *outname = NULL;
        char *line;
 
-       opt_complementary = "?1"; /* 1 argument max */
-       getopt32(argv, "o:", &outname);
+       getopt32(argv, "^" "o:" "\0" "?1"/* 1 arg max*/, &outname);
        argv += optind;
 
        if (!argv[0])
@@ -170,10 +175,10 @@ int uudecode_main(int argc UNUSED_PARAM, char **argv)
 //kbuild:lib-$(CONFIG_BASE64) += uudecode.o
 
 //config:config BASE64
-//config:      bool "base64"
+//config:      bool "base64 (5 kb)"
 //config:      default y
 //config:      help
-//config:        Base64 encode and decode
+//config:      Base64 encode and decode
 
 //usage:#define base64_trivial_usage
 //usage:       "[-d] [FILE]"
@@ -190,8 +195,7 @@ int base64_main(int argc UNUSED_PARAM, char **argv)
        FILE *src_stream;
        unsigned opts;
 
-       opt_complementary = "?1"; /* 1 argument max */
-       opts = getopt32(argv, "d");
+       opts = getopt32(argv, "^" "d" "\0" "?1"/* 1 arg max*/);
        argv += optind;
 
        if (!argv[0])