From 1ed2fb40c919a25fe6920680cf898d0b4870c60e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 Jun 2010 14:09:48 +0200 Subject: ash: cosmetics, no code changes Signed-off-by: Denys Vlasenko --- shell/ash.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'shell/ash.c') diff --git a/shell/ash.c b/shell/ash.c index 90680e849..fcaa7b18e 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -46,6 +46,7 @@ #include #include #include +#include #include "shell_common.h" #include "math.h" @@ -7310,7 +7311,7 @@ shellexec(char **argv, const char *path, int idx) #endif clearredir(/*drop:*/ 1); - envp = listvars(VEXPORT, VUNSET, 0); + envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL); if (strchr(argv[0], '/') != NULL #if ENABLE_FEATURE_SH_STANDALONE || (applet_no = find_applet_by_name(argv[0])) >= 0 @@ -12468,7 +12469,7 @@ unsetfunc(const char *name) struct tblentry *cmdp; cmdp = cmdlookup(name, 0); - if (cmdp!= NULL && cmdp->cmdtype == CMDFUNCTION) + if (cmdp != NULL && cmdp->cmdtype == CMDFUNCTION) delete_cmd_entry(); } @@ -12485,7 +12486,7 @@ unsetcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) int flag = 0; int ret = 0; - while ((i = nextopt("vf")) != '\0') { + while ((i = nextopt("vf")) != 0) { flag = i; } @@ -12502,11 +12503,6 @@ unsetcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) return ret & 1; } - -/* setmode.c */ - -#include - static const unsigned char timescmd_str[] ALIGN1 = { ' ', offsetof(struct tms, tms_utime), '\n', offsetof(struct tms, tms_stime), @@ -12514,7 +12510,6 @@ static const unsigned char timescmd_str[] ALIGN1 = { '\n', offsetof(struct tms, tms_cstime), 0 }; - static int FAST_FUNC timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) { @@ -12533,14 +12528,15 @@ timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) s/60, s%60, ((t - s * clk_tck) * 1000) / clk_tck, p[0]); - } while (*(p += 2)); + p += 2; + } while (*p); return 0; } #if ENABLE_SH_MATH_SUPPORT /* - * The let builtin. partial stolen from GNU Bash, the Bourne Again SHell. + * The let builtin. Partially stolen from GNU Bash, the Bourne Again SHell. * Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc. * * Copyright (C) 2003 Vladimir Oleynik @@ -12559,18 +12555,6 @@ letcmd(int argc UNUSED_PARAM, char **argv) return !i; } -#endif /* SH_MATH_SUPPORT */ - - -/* ============ miscbltin.c - * - * Miscellaneous builtins. - */ - -#undef rflag - -#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 1 -typedef enum __rlimit_resource rlim_t; #endif /* -- cgit v1.2.3 From 7df28bbb8fa3ba2878c288401c898ec477e55df1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 Jun 2010 14:23:47 +0200 Subject: ash: fix unset in standalone mode Signed-off-by: Denys Vlasenko --- shell/ash.c | 1 + shell/ash_test/ash-standalone/var_standalone1.right | 1 + shell/ash_test/ash-standalone/var_standalone1.tests | 2 ++ 3 files changed, 4 insertions(+) create mode 100644 shell/ash_test/ash-standalone/var_standalone1.right create mode 100755 shell/ash_test/ash-standalone/var_standalone1.tests (limited to 'shell/ash.c') diff --git a/shell/ash.c b/shell/ash.c index fcaa7b18e..74fe8617b 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -7252,6 +7252,7 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char ** #if ENABLE_FEATURE_SH_STANDALONE if (applet_no >= 0) { if (APPLET_IS_NOEXEC(applet_no)) { + clearenv(); while (*envp) putenv(*envp++); run_applet_no_and_exit(applet_no, argv); diff --git a/shell/ash_test/ash-standalone/var_standalone1.right b/shell/ash_test/ash-standalone/var_standalone1.right new file mode 100644 index 000000000..37457fd74 --- /dev/null +++ b/shell/ash_test/ash-standalone/var_standalone1.right @@ -0,0 +1 @@ +Done: 1 diff --git a/shell/ash_test/ash-standalone/var_standalone1.tests b/shell/ash_test/ash-standalone/var_standalone1.tests new file mode 100755 index 000000000..1e905ba75 --- /dev/null +++ b/shell/ash_test/ash-standalone/var_standalone1.tests @@ -0,0 +1,2 @@ +VAR=42 $THIS_SH -c 'unset VAR; env | grep ^VAR' +echo Done: $? -- cgit v1.2.3 From b87c17cd16f1b23a07a65ee90a3e30a49992fa51 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 Jun 2010 15:15:24 +0200 Subject: *: stop defining _GNU_SOURCE in source files, it's in CFLAGS anyway Signed-off-by: Denys Vlasenko --- e2fsprogs/old_e2fsprogs/e2fsck.c | 4 ---- libbb/get_line_from_file.c | 5 ----- modutils/depmod.c | 2 -- shell/ash.c | 6 ------ util-linux/hwclock.c | 7 ------- 5 files changed, 24 deletions(-) (limited to 'shell/ash.c') diff --git a/e2fsprogs/old_e2fsprogs/e2fsck.c b/e2fsprogs/old_e2fsprogs/e2fsck.c index 7384bc453..4c4c78d00 100644 --- a/e2fsprogs/old_e2fsprogs/e2fsck.c +++ b/e2fsprogs/old_e2fsprogs/e2fsck.c @@ -29,10 +29,6 @@ * Licensed under GPLv2 or later, see file License in this tarball for details. */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 /* get strnlen() */ -#endif - #include "e2fsck.h" /*Put all of our defines here to clean things up*/ #define _(x) x diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c index 3cb46d240..cbfb45b7c 100644 --- a/libbb/get_line_from_file.c +++ b/libbb/get_line_from_file.c @@ -9,11 +9,6 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -/* for getline() [GNUism] -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif -*/ #include "libbb.h" /* This function reads an entire line from a text file, up to a newline diff --git a/modutils/depmod.c b/modutils/depmod.c index 4718c4dcb..c734f142b 100644 --- a/modutils/depmod.c +++ b/modutils/depmod.c @@ -8,8 +8,6 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -#undef _GNU_SOURCE -#define _GNU_SOURCE #include "libbb.h" #include "modutils.h" #include /* uname() */ diff --git a/shell/ash.c b/shell/ash.c index 74fe8617b..171740768 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -36,12 +36,6 @@ #define JOBS ENABLE_ASH_JOB_CONTROL -#if DEBUG -# ifndef _GNU_SOURCE -# define _GNU_SOURCE -# endif -#endif - #include "busybox.h" /* for applet_names */ #include #include diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 416271b31..3da2e23c3 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -12,13 +12,6 @@ #include #include "rtc_.h" -#if ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS -# ifndef _GNU_SOURCE -# define _GNU_SOURCE -# endif -#endif - - /* diff code is disabled: it's not sys/hw clock diff, it's some useless * "time between hwclock was started and we saw CMOS tick" quantity. * It's useless since hwclock is started at a random moment, -- cgit v1.2.3 From 8cd9f343e74ca65f36c42a44e845716ba5411663 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 Jun 2010 15:36:48 +0200 Subject: ash: times builtin: use unsigned type; take free-of-charge modulo Signed-off-by: Denys Vlasenko --- shell/ash.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'shell/ash.c') diff --git a/shell/ash.c b/shell/ash.c index 171740768..f581b5bdf 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -12508,7 +12508,7 @@ static const unsigned char timescmd_str[] ALIGN1 = { static int FAST_FUNC timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) { - long clk_tck, s, t; + unsigned long clk_tck, s, t; const unsigned char *p; struct tms buf; @@ -12519,9 +12519,10 @@ timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) do { t = *(clock_t *)(((char *) &buf) + p[1]); s = t / clk_tck; - out1fmt("%ldm%ld.%.3lds%c", - s/60, s%60, - ((t - s * clk_tck) * 1000) / clk_tck, + t = t % clk_tck; + out1fmt("%lum%lu.%03lus%c", + s / 60, s % 60, + (t * 1000) / clk_tck, p[0]); p += 2; } while (*p); -- cgit v1.2.3