From 877dedb8251be47b3614a371434081ae9b7b358b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 27 May 2016 00:46:38 +0200 Subject: cp: add -u/--update and --remove-destination Based on the patch by wdlkmpx@gmail.com function old new delta copy_file 1546 1644 +98 add_partition 1270 1362 +92 ask_and_unlink 95 133 +38 do_iproute 132 157 +25 decode_one_format 710 715 +5 cp_main 369 374 +5 ubirename_main 198 202 +4 read_package_field 232 230 -2 bb_make_directory 421 412 -9 packed_usage 30505 30476 -29 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 7/3 up/down: 267/-40) Total: 227 bytes Signed-off-by: Denys Vlasenko --- libbb/copy_file.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'libbb') diff --git a/libbb/copy_file.c b/libbb/copy_file.c index a4be875d2..23bcf2e82 100644 --- a/libbb/copy_file.c +++ b/libbb/copy_file.c @@ -64,6 +64,11 @@ static int ask_and_unlink(const char *dest, int flags) bb_perror_msg("can't create '%s'", dest); return -1; /* error */ } +#if ENABLE_FEATURE_CP_LONG_OPTIONS + if (flags & FILEUTILS_RMDEST) + if (flags & FILEUTILS_VERBOSE) + printf("removed '%s'\n", dest); +#endif return 1; /* ok (to try again) */ } @@ -210,6 +215,22 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags) goto preserve_mode_ugid_time; } + if (dest_exists) { + if (flags & FILEUTILS_UPDATE) { + if (source_stat.st_mtime <= dest_stat.st_mtime) { + return 0; /* source file must be newer */ + } + } +#if ENABLE_FEATURE_CP_LONG_OPTIONS + if (flags & FILEUTILS_RMDEST) { + ovr = ask_and_unlink(dest, flags); + if (ovr <= 0) + return ovr; + dest_exists = 0; + } +#endif + } + if (flags & (FILEUTILS_MAKE_SOFTLINK|FILEUTILS_MAKE_HARDLINK)) { int (*lf)(const char *oldpath, const char *newpath); make_links: -- cgit v1.2.3-55-g6feb From 8e95068c7f28fe2a1e31b01636e3ed29eed09ef8 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 31 May 2016 02:42:49 +0200 Subject: Make busybox an optional applet If it's disabled, code shrinks by about 900 bytes: function old new delta usr_bin 10 - -10 usr_sbin 11 - -11 install_dir 20 - -20 applet_install_loc 184 - -184 run_applet_and_exit 686 21 -665 ------------------------------------------------------------------------------ (add/remove: 0/4 grow/shrink: 0/1 up/down: 0/-890) Total: -890 bytes text data bss dec hex filename 911327 493 7336 919156 e0674 busybox_old 909848 493 7336 917677 e00ad busybox_unstripped but busybox executable by itself does not say anything useful: $ busybox busybox: applet not found Based on the patch by Ron Yorston Signed-off-by: Denys Vlasenko --- Config.in | 12 ++++++++++++ libbb/appletlib.c | 10 +++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'libbb') diff --git a/Config.in b/Config.in index 0a0b5d7cb..3d1870966 100644 --- a/Config.in +++ b/Config.in @@ -116,9 +116,21 @@ config FEATURE_COMPRESS_USAGE and have very little memory, this might not be a win. Otherwise, you probably want this. +config BUSYBOX + bool "Include busybox applet" + default y + help + The busybox applet provides general help regarding busybox and + allows the included applets to be listed. It's also required + if applet links are to be installed at runtime. + + If you can live without these features disabling this will save + some space. + config FEATURE_INSTALLER bool "Support --install [-s] to install applet links at runtime" default y + depends on BUSYBOX help Enable 'busybox --install [-s]' support. This will allow you to use busybox at runtime to create hard links or symlinks for all the diff --git a/libbb/appletlib.c b/libbb/appletlib.c index b682e6b85..281123c37 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -701,7 +701,7 @@ static void install_links(const char *busybox, int use_symbolic_links, continue; } } -# else +# elif ENABLE_BUSYBOX static void install_links(const char *busybox UNUSED_PARAM, int use_symbolic_links UNUSED_PARAM, char *custom_install_dir UNUSED_PARAM) @@ -709,6 +709,7 @@ static void install_links(const char *busybox UNUSED_PARAM, } # endif +# if ENABLE_BUSYBOX /* If we were called as "busybox..." */ static int busybox_main(char **argv) { @@ -784,10 +785,10 @@ static int busybox_main(char **argv) const char *a = applet_names; dup2(1, 2); while (*a) { -# if ENABLE_FEATURE_INSTALLER +# if ENABLE_FEATURE_INSTALLER if (argv[1][6]) /* --list-full? */ full_write2_str(install_dir[APPLET_INSTALL_LOC(i)] + 1); -# endif +# endif full_write2_str(a); full_write2_str("\n"); i++; @@ -843,6 +844,7 @@ static int busybox_main(char **argv) /* POSIX: "If a command is not found, the exit status shall be 127" */ exit(127); } +# endif void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv) { @@ -886,8 +888,10 @@ void FAST_FUNC run_applet_and_exit(const char *name, char **argv) { int applet; +# if ENABLE_BUSYBOX if (is_prefixed_with(name, "busybox")) exit(busybox_main(argv)); +# endif /* find_applet_by_name() search is more expensive, so goes second */ applet = find_applet_by_name(name); if (applet >= 0) -- cgit v1.2.3-55-g6feb From b684d1b1864ba9d7968de5565823f8e42f1dc448 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 19 May 2016 17:31:59 +0200 Subject: libbb: fix time parsing of [[CC]YY]MMDDhhmm[.SS]. Closes 8951 If SS is not given a value, it is assumed to be zero. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/touch.html Signed-off-by: Natanael Copa Signed-off-by: Denys Vlasenko --- libbb/time.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libbb') diff --git a/libbb/time.c b/libbb/time.c index aa19a47d4..82e6cb172 100644 --- a/libbb/time.c +++ b/libbb/time.c @@ -186,6 +186,7 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm) } else { bb_error_msg_and_die(bb_msg_invalid_date, date_str); } + ptm->tm_sec = 0; /* assume zero if [.SS] is not given */ if (end == '.') { /* xxx.SS */ if (sscanf(strchr(date_str, '.') + 1, "%u%c", -- cgit v1.2.3-55-g6feb From ba12081a9e9b2d90d1924546bc9097abf52cf2b5 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 7 Jun 2016 10:26:24 +0100 Subject: Allow "busybox " to work when busybox is disabled A recent commit made it possible to disable BusyBox's --install and --list options. However it also stopped "busybox " from working. Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- libbb/appletlib.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libbb') diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 281123c37..b6fe1dad2 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -956,6 +956,10 @@ int main(int argc UNUSED_PARAM, char **argv) #else lbb_prepare("busybox" IF_FEATURE_INDIVIDUAL(, argv)); +#if !ENABLE_BUSYBOX + if (argv[1] && is_prefixed_with(bb_basename(argv[0]), "busybox")) + argv++; +#endif applet_name = argv[0]; if (applet_name[0] == '-') applet_name++; -- cgit v1.2.3-55-g6feb From ce824aecf216536beed00d7817a614ffb8572239 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 7 Jun 2016 12:12:07 +0100 Subject: libbb: move common code into run_applet_and_exit Both calls to run_applet_and_exit are followed by the same code to print an error message and return status 127. Remove this duplication and make run_applet_and_exit static. function old new delta run_applet_and_exit 675 667 -8 main 119 92 -27 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-35) Total: -35 bytes Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- include/libbb.h | 2 -- libbb/appletlib.c | 21 ++++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) (limited to 'libbb') diff --git a/include/libbb.h b/include/libbb.h index a21f4204a..e39021eb1 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1239,8 +1239,6 @@ const struct hwtype *get_hwntype(int type) FAST_FUNC; #ifndef BUILD_INDIVIDUAL extern int find_applet_by_name(const char *name) FAST_FUNC; -/* Returns only if applet is not found. */ -extern void run_applet_and_exit(const char *name, char **argv) FAST_FUNC; extern void run_applet_no_and_exit(int a, char **argv) NORETURN FAST_FUNC; #endif diff --git a/libbb/appletlib.c b/libbb/appletlib.c index b6fe1dad2..480bf50fc 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -52,6 +52,7 @@ #include "usage_compressed.h" +static void run_applet_and_exit(const char *name, char **argv) NORETURN; #if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE static const char usage_messages[] ALIGN1 = UNPACKED_USAGE; @@ -837,12 +838,6 @@ static int busybox_main(char **argv) * "#!/bin/busybox"-style wrappers */ applet_name = bb_get_last_path_component_nostrip(argv[0]); run_applet_and_exit(applet_name, argv); - - /*bb_error_msg_and_die("applet not found"); - sucks in printf */ - full_write2_str(applet_name); - full_write2_str(": applet not found\n"); - /* POSIX: "If a command is not found, the exit status shall be 127" */ - exit(127); } # endif @@ -884,7 +879,7 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv) exit(applet_main[applet_no](argc, argv)); } -void FAST_FUNC run_applet_and_exit(const char *name, char **argv) +static NORETURN void run_applet_and_exit(const char *name, char **argv) { int applet; @@ -896,6 +891,12 @@ void FAST_FUNC run_applet_and_exit(const char *name, char **argv) applet = find_applet_by_name(name); if (applet >= 0) run_applet_no_and_exit(applet, argv); + + /*bb_error_msg_and_die("applet not found"); - links in printf */ + full_write2_str(applet_name); + full_write2_str(": applet not found\n"); + /* POSIX: "If a command is not found, the exit status shall be 127" */ + exit(127); } #endif /* !defined(SINGLE_APPLET_MAIN) */ @@ -968,11 +969,5 @@ int main(int argc UNUSED_PARAM, char **argv) parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */ run_applet_and_exit(applet_name, argv); - - /*bb_error_msg_and_die("applet not found"); - sucks in printf */ - full_write2_str(applet_name); - full_write2_str(": applet not found\n"); - /* POSIX: "If a command is not found, the exit status shall be 127" */ - exit(127); #endif } -- cgit v1.2.3-55-g6feb From bb0bf287d8fcb59a7d44661681576f77845dedbc Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 19 Jun 2016 21:54:04 +0200 Subject: randomconfig fixes 2 Signed-off-by: Denys Vlasenko --- libbb/Kbuild.src | 1 + scripts/randomtest | 2 ++ testsuite/ar.tests | 2 +- testsuite/tar.tests | 4 ++-- 4 files changed, 6 insertions(+), 3 deletions(-) (limited to 'libbb') diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index b08ce1158..52a90e9a1 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src @@ -145,6 +145,7 @@ lib-$(CONFIG_FTPD) += correct_password.o lib-$(CONFIG_PASSWD) += pw_encrypt.o update_passwd.o obscure.o lib-$(CONFIG_CHPASSWD) += pw_encrypt.o update_passwd.o lib-$(CONFIG_CRYPTPW) += pw_encrypt.o +lib-$(CONFIG_MKPASSWD) += pw_encrypt.o lib-$(CONFIG_SULOGIN) += pw_encrypt.o correct_password.o lib-$(CONFIG_VLOCK) += pw_encrypt.o correct_password.o lib-$(CONFIG_SU) += pw_encrypt.o correct_password.o diff --git a/scripts/randomtest b/scripts/randomtest index 41f252ad7..287f1c771 100755 --- a/scripts/randomtest +++ b/scripts/randomtest @@ -115,6 +115,8 @@ fi # Build! nice -n 10 make $MAKEOPTS 2>&1 | tee make.log +grep 'Rerun make' make.log \ +&& nice -n 10 make $MAKEOPTS 2>&1 | tee -a make.log # Return exitcode 1 if busybox executable does not exist test -x busybox diff --git a/testsuite/ar.tests b/testsuite/ar.tests index 0a8eb9b32..ad7b8fe5f 100755 --- a/testsuite/ar.tests +++ b/testsuite/ar.tests @@ -15,7 +15,7 @@ testing "ar creates archives" \ "$(md5sum /dev/null testing "ar replaces things in archives" \ "echo 'blah!' >file1 && echo 'blast!' >file2 && ar cr test.a README file1 file2 && mv file2 file1 && ar cr test.a file1 && ar p test.a file1" \ diff --git a/testsuite/tar.tests b/testsuite/tar.tests index 890a73dd5..e9021662e 100755 --- a/testsuite/tar.tests +++ b/testsuite/tar.tests @@ -266,7 +266,7 @@ SKIP= # The correct implementation unlinks target before # creating the second file. # We test that /tmp/passwd remains empty: -optional UUDECODE FEATURE_SEAMLESS_BZ2 +optional UUDECODE FEATURE_TAR_AUTODETECT FEATURE_SEAMLESS_BZ2 testing "tar does not extract into symlinks" "\ >>/tmp/passwd && uudecode -o input && tar xf input 2>&1 && rm passwd; cat /tmp/passwd; echo \$? " "\ @@ -282,7 +282,7 @@ l4/V8LDoe90yiWJhOJvIypgEfxdyRThQkBVn/bI= " SKIP= # And same with -k -optional UUDECODE FEATURE_SEAMLESS_BZ2 +optional UUDECODE FEATURE_TAR_AUTODETECT FEATURE_SEAMLESS_BZ2 testing "tar -k does not extract into symlinks" "\ >>/tmp/passwd && uudecode -o input && tar xf input -k 2>&1 && rm passwd; cat /tmp/passwd; echo \$? " "\ -- cgit v1.2.3-55-g6feb From 1b0dcc02dd5a101d1a62f2111892a41621be96cf Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 5 Jul 2016 14:07:50 +0100 Subject: libbb: suppress warning about run_applet_and_exit When busybox is configured to contain a single applet an unnecessary declaration of run_applet_and_exit results in a warning. Move the declaration to avoid this. Reported-by: Lauri Kasanen Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- libbb/appletlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libbb') diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 480bf50fc..791b81c17 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -52,8 +52,6 @@ #include "usage_compressed.h" -static void run_applet_and_exit(const char *name, char **argv) NORETURN; - #if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE static const char usage_messages[] ALIGN1 = UNPACKED_USAGE; #else @@ -711,6 +709,8 @@ static void install_links(const char *busybox UNUSED_PARAM, # endif # if ENABLE_BUSYBOX +static void run_applet_and_exit(const char *name, char **argv) NORETURN; + /* If we were called as "busybox..." */ static int busybox_main(char **argv) { -- cgit v1.2.3-55-g6feb From f4f8fe841cf2df761eaade204a13e6fde6639666 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 5 Jul 2016 21:43:28 +0200 Subject: build system: fix a few warnings for allnoconfig build Not that allnoconfig build is useful in any way... Signed-off-by: Denys Vlasenko --- applets/usage_pod.c | 2 ++ docs/busybox_footer.pod | 2 -- libbb/appletlib.c | 30 +++++++++++++++++------------- 3 files changed, 19 insertions(+), 15 deletions(-) (limited to 'libbb') diff --git a/applets/usage_pod.c b/applets/usage_pod.c index 0b1c4aadb..ccc166aed 100644 --- a/applets/usage_pod.c +++ b/applets/usage_pod.c @@ -90,6 +90,8 @@ int main(void) printf("%s\n\n", usage_array[i].aname); } } + printf("=back\n\n"); + return 0; } diff --git a/docs/busybox_footer.pod b/docs/busybox_footer.pod index c346c736b..92748eb72 100644 --- a/docs/busybox_footer.pod +++ b/docs/busybox_footer.pod @@ -1,5 +1,3 @@ -=back - =head1 LIBC NSS GNU Libc (glibc) uses the Name Service Switch (NSS) to configure the behavior diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 791b81c17..c341817e2 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -841,6 +841,7 @@ static int busybox_main(char **argv) } # endif +# if NUM_APPLETS > 0 void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv) { int argc = 1; @@ -858,15 +859,15 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv) * "true" and "false" are also special. */ if (1 -#if defined APPLET_NO_test +# if defined APPLET_NO_test && applet_no != APPLET_NO_test -#endif -#if defined APPLET_NO_true +# endif +# if defined APPLET_NO_true && applet_no != APPLET_NO_true -#endif -#if defined APPLET_NO_false +# endif +# if defined APPLET_NO_false && applet_no != APPLET_NO_false -#endif +# endif ) { if (argc == 2 && strcmp(argv[1], "--help") == 0) { /* Make "foo --help" exit with 0: */ @@ -878,19 +879,22 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv) check_suid(applet_no); exit(applet_main[applet_no](argc, argv)); } +# endif /* NUM_APPLETS > 0 */ static NORETURN void run_applet_and_exit(const char *name, char **argv) { - int applet; - # if ENABLE_BUSYBOX if (is_prefixed_with(name, "busybox")) exit(busybox_main(argv)); # endif +# if NUM_APPLETS > 0 /* find_applet_by_name() search is more expensive, so goes second */ - applet = find_applet_by_name(name); - if (applet >= 0) - run_applet_no_and_exit(applet, argv); + { + int applet = find_applet_by_name(name); + if (applet >= 0) + run_applet_no_and_exit(applet, argv); + } +# endif /*bb_error_msg_and_die("applet not found"); - links in printf */ full_write2_str(applet_name); @@ -957,10 +961,10 @@ int main(int argc UNUSED_PARAM, char **argv) #else lbb_prepare("busybox" IF_FEATURE_INDIVIDUAL(, argv)); -#if !ENABLE_BUSYBOX +# if !ENABLE_BUSYBOX if (argv[1] && is_prefixed_with(bb_basename(argv[0]), "busybox")) argv++; -#endif +# endif applet_name = argv[0]; if (applet_name[0] == '-') applet_name++; -- cgit v1.2.3-55-g6feb From 237bedd499c58034a1355484d6d4d906f0180308 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 6 Jul 2016 21:58:02 +0200 Subject: getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST In many cases, this aqllows to drop use of opt_complementary. Approximately -400 bytes: function old new delta getopt32 1423 1502 +79 opt_string 17 18 +1 OPT_STR 24 25 +1 uniq_main 416 406 -10 timeout_main 279 269 -10 sulogin_main 270 260 -10 readprofile_main 1825 1815 -10 ps_main 543 533 -10 pidof_main 245 235 -10 pgrep_main 611 601 -10 od_main 2600 2590 -10 mkfs_minix_main 2684 2674 -10 mkfs_ext2_main 2603 2593 -10 microcom_main 712 702 -10 makemime_main 315 305 -10 ionice_main 282 272 -10 inetd_main 2074 2064 -10 ifplugd_main 1144 1134 -10 halt_main 353 343 -10 getopt_main 636 626 -10 fdisk_main 2854 2844 -10 env_main 206 196 -10 dmesg_main 319 309 -10 conspy_main 1214 1204 -10 awk_main 981 971 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/22 up/down: 81/-220) Total: -139 bytes text data bss dec hex filename 919373 906 14060 934339 e41c3 busybox_old 918969 906 14060 933935 e402f busybox_unstripped Signed-off-by: Denys Vlasenko --- archival/tar.c | 15 ++++----- coreutils/du.c | 8 ++--- coreutils/env.c | 3 +- coreutils/od_bloaty.c | 3 +- coreutils/sort.c | 5 ++- coreutils/split.c | 4 +-- coreutils/tail.c | 4 +-- coreutils/uniq.c | 3 +- debianutils/run_parts.c | 4 +-- editors/awk.c | 8 ++--- editors/diff.c | 4 +-- editors/sed.c | 5 ++- findutils/grep.c | 8 ++--- init/halt.c | 3 +- libbb/getopt32.c | 82 ++++++++++++++++++++++++++++++++------------- libbb/parse_config.c | 4 +-- loginutils/cryptpw.c | 4 +-- loginutils/getty.c | 4 +-- loginutils/sulogin.c | 3 +- mailutils/makemime.c | 3 +- mailutils/popmaildir.c | 4 +-- mailutils/reformime.c | 4 +-- mailutils/sendmail.c | 4 +-- miscutils/conspy.c | 4 +-- miscutils/ionice.c | 3 +- miscutils/microcom.c | 3 +- miscutils/timeout.c | 3 +- miscutils/ubi_tools.c | 8 ++--- networking/arping.c | 4 +-- networking/ftpd.c | 6 ++-- networking/ifplugd.c | 5 ++- networking/inetd.c | 4 +-- networking/nc_bloaty.c | 4 +-- networking/ntpd.c | 4 +-- networking/ping.c | 4 +-- networking/tcpudp.c | 4 +-- networking/telnetd.c | 4 +-- networking/traceroute.c | 4 +-- networking/udhcp/d6_dhcpc.c | 4 +-- networking/udhcp/dhcpc.c | 4 +-- networking/wget.c | 3 +- networking/whois.c | 4 +-- procps/pgrep.c | 3 +- procps/pidof.c | 3 +- procps/ps.c | 3 +- procps/watch.c | 4 +-- runit/chpst.c | 4 +-- runit/sv.c | 4 +-- selinux/setfiles.c | 6 ++-- sysklogd/syslogd.c | 6 ++-- util-linux/dmesg.c | 3 +- util-linux/fdisk.c | 3 +- util-linux/getopt.c | 3 +- util-linux/mkfs_ext2.c | 3 +- util-linux/mkfs_minix.c | 3 +- util-linux/mkfs_reiser.c | 4 +-- util-linux/mount.c | 4 +-- util-linux/readprofile.c | 3 +- 58 files changed, 168 insertions(+), 159 deletions(-) (limited to 'libbb') diff --git a/archival/tar.c b/archival/tar.c index 7434e22e4..8e315c610 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -980,7 +980,6 @@ int tar_main(int argc UNUSED_PARAM, char **argv) /* Prepend '-' to the first argument if required */ opt_complementary = "--:" // first arg is options "tt:vv:" // count -t,-v - IF_FEATURE_TAR_FROM("X::T::") // cumulative lists #if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM "\xff::" // --exclude=PATTERN is a list #endif @@ -1032,13 +1031,13 @@ int tar_main(int argc UNUSED_PARAM, char **argv) #endif opt = getopt32(argv, "txC:f:Oopvk" - IF_FEATURE_TAR_CREATE( "ch" ) - IF_FEATURE_SEAMLESS_BZ2( "j" ) - IF_FEATURE_SEAMLESS_LZMA("a" ) - IF_FEATURE_TAR_FROM( "T:X:") - IF_FEATURE_SEAMLESS_GZ( "z" ) - IF_FEATURE_SEAMLESS_XZ( "J" ) - IF_FEATURE_SEAMLESS_Z( "Z" ) + IF_FEATURE_TAR_CREATE( "ch" ) + IF_FEATURE_SEAMLESS_BZ2( "j" ) + IF_FEATURE_SEAMLESS_LZMA("a" ) + IF_FEATURE_TAR_FROM( "T:*X:*") + IF_FEATURE_SEAMLESS_GZ( "z" ) + IF_FEATURE_SEAMLESS_XZ( "J" ) + IF_FEATURE_SEAMLESS_Z( "Z" ) IF_FEATURE_TAR_NOPRESERVE_TIME("m") IF_FEATURE_TAR_LONG_OPTIONS("\xf9:") // --strip-components , &base_dir // -C dir diff --git a/coreutils/du.c b/coreutils/du.c index 1240bcbbc..5f104736b 100644 --- a/coreutils/du.c +++ b/coreutils/du.c @@ -226,8 +226,8 @@ int du_main(int argc UNUSED_PARAM, char **argv) * ignore -a. This is consistent with -s being equivalent to -d 0. */ #if ENABLE_FEATURE_HUMAN_READABLE - opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s:d+"; - opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &G.max_print_depth); + opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s"; + opt = getopt32(argv, "aHkLsx" "d:+" "lc" "hm", &G.max_print_depth); argv += optind; if (opt & OPT_h_for_humans) { G.disp_unit = 0; @@ -239,8 +239,8 @@ int du_main(int argc UNUSED_PARAM, char **argv) G.disp_unit = 1024; } #else - opt_complementary = "H-L:L-H:s-d:d-s:d+"; - opt = getopt32(argv, "aHkLsx" "d:" "lc", &G.max_print_depth); + opt_complementary = "H-L:L-H:s-d:d-s"; + opt = getopt32(argv, "aHkLsx" "d:+" "lc", &G.max_print_depth); argv += optind; #if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K if (opt & OPT_k_kbytes) { diff --git a/coreutils/env.c b/coreutils/env.c index 807ef13e9..cdfc30e14 100644 --- a/coreutils/env.c +++ b/coreutils/env.c @@ -54,11 +54,10 @@ int env_main(int argc UNUSED_PARAM, char **argv) unsigned opts; llist_t *unset_env = NULL; - opt_complementary = "u::"; #if ENABLE_FEATURE_ENV_LONG_OPTIONS applet_long_options = env_longopts; #endif - opts = getopt32(argv, "+iu:", &unset_env); + opts = getopt32(argv, "+iu:+", &unset_env); argv += optind; if (argv[0] && LONE_DASH(argv[0])) { opts |= 1; diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c index c8a654165..f13bdfc11 100644 --- a/coreutils/od_bloaty.c +++ b/coreutils/od_bloaty.c @@ -62,7 +62,7 @@ enum { }; #define OD_GETOPT32() getopt32(argv, \ - "A:N:abcdfhij:lot:vxsS:w::", \ + "A:N:abcdfhij:lot:*vxsS:w:+:", \ /* -w with optional param */ \ /* -S was -s and also had optional parameter */ \ /* but in coreutils 6.3 it was renamed and now has */ \ @@ -1212,7 +1212,6 @@ int od_main(int argc UNUSED_PARAM, char **argv) address_pad_len_char = '7'; /* Parse command line */ - opt_complementary = "w+:t::"; /* -w N, -t is a list */ #if ENABLE_LONG_OPTS applet_long_options = od_longopts; #endif diff --git a/coreutils/sort.c b/coreutils/sort.c index 9139d9f47..34a41999b 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c @@ -73,7 +73,7 @@ */ /* These are sort types */ -static const char OPT_STR[] ALIGN1 = "ngMucszbrdfimS:T:o:k:t:"; +static const char OPT_STR[] ALIGN1 = "ngMucszbrdfimS:T:o:k:*t:"; enum { FLAG_n = 1, /* Numeric sort */ FLAG_g = 2, /* Sort using strtod() */ @@ -358,8 +358,7 @@ int sort_main(int argc UNUSED_PARAM, char **argv) /* Parse command line options */ /* -o and -t can be given at most once */ - opt_complementary = "o--o:t--t:" /* -t, -o: at most one of each */ - "k::"; /* -k takes list */ + opt_complementary = "o--o:t--t"; /* -t, -o: at most one of each */ opts = getopt32(argv, OPT_STR, &str_ignored, &str_ignored, &str_o, &lst_k, &str_t); /* global b strips leading and trailing spaces */ if (opts & FLAG_b) diff --git a/coreutils/split.c b/coreutils/split.c index e67c3de66..19d58a21b 100644 --- a/coreutils/split.c +++ b/coreutils/split.c @@ -81,8 +81,8 @@ int split_main(int argc UNUSED_PARAM, char **argv) setup_common_bufsiz(); - opt_complementary = "?2:a+"; /* max 2 args; -a N */ - opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len); + opt_complementary = "?2"; /* max 2 args; -a N */ + opt = getopt32(argv, "l:b:a:+", &count_p, &count_p, &suffix_len); if (opt & SPLIT_OPT_l) cnt = XATOOFF(count_p); diff --git a/coreutils/tail.c b/coreutils/tail.c index 39f87679e..57ad0f3b7 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c @@ -121,8 +121,8 @@ int tail_main(int argc, char **argv) #endif /* -s NUM, -F imlies -f */ - IF_FEATURE_FANCY_TAIL(opt_complementary = "s+:Ff";) - opt = getopt32(argv, "fc:n:" IF_FEATURE_FANCY_TAIL("qs:vF"), + IF_FEATURE_FANCY_TAIL(opt_complementary = "Ff";) + opt = getopt32(argv, "fc:n:" IF_FEATURE_FANCY_TAIL("qs:+vF"), &str_c, &str_n IF_FEATURE_FANCY_TAIL(,&sleep_period)); #define FOLLOW (opt & 0x1) #define COUNT_BYTES (opt & 0x2) diff --git a/coreutils/uniq.c b/coreutils/uniq.c index e0133998a..ec7bde418 100644 --- a/coreutils/uniq.c +++ b/coreutils/uniq.c @@ -50,8 +50,7 @@ int uniq_main(int argc UNUSED_PARAM, char **argv) skip_fields = skip_chars = 0; max_chars = INT_MAX; - opt_complementary = "f+:s+:w+"; - opt = getopt32(argv, "cduf:s:w:", &skip_fields, &skip_chars, &max_chars); + opt = getopt32(argv, "cduf:+s:+w:+", &skip_fields, &skip_chars, &max_chars); argv += optind; input_filename = argv[0]; diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c index c671b9252..0bb666abc 100644 --- a/debianutils/run_parts.c +++ b/debianutils/run_parts.c @@ -181,8 +181,8 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv) applet_long_options = runparts_longopts; #endif /* We require exactly one argument: the directory name */ - opt_complementary = "=1:a::"; - getopt32(argv, "a:u:", &arg_list, &umask_p); + opt_complementary = "=1"; + getopt32(argv, "a:*u:", &arg_list, &umask_p); umask(xstrtou_range(umask_p, 8, 0, 07777)); diff --git a/editors/awk.c b/editors/awk.c index 69816464d..d0269b9f4 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -72,12 +72,9 @@ #define OPTSTR_AWK \ - "F:v:f:" \ - IF_FEATURE_AWK_GNU_EXTENSIONS("e:") \ + "F:v:*f:*" \ + IF_FEATURE_AWK_GNU_EXTENSIONS("e:*") \ "W:" -#define OPTCOMPLSTR_AWK \ - "v::f::" \ - IF_FEATURE_AWK_GNU_EXTENSIONS("e::") enum { OPTBIT_F, /* define field separator */ OPTBIT_v, /* define variable */ @@ -3209,7 +3206,6 @@ int awk_main(int argc, char **argv) *s1 = '='; } } - opt_complementary = OPTCOMPLSTR_AWK; opt = getopt32(argv, OPTSTR_AWK, &opt_F, &list_v, &list_f, IF_FEATURE_AWK_GNU_EXTENSIONS(&list_e,) NULL); argv += optind; argc -= optind; diff --git a/editors/diff.c b/editors/diff.c index ff269360f..75229ad8c 100644 --- a/editors/diff.c +++ b/editors/diff.c @@ -982,11 +982,11 @@ int diff_main(int argc UNUSED_PARAM, char **argv) INIT_G(); /* exactly 2 params; collect multiple -L