aboutsummaryrefslogtreecommitdiff
path: root/toys/other
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-12-19 21:38:12 -0600
committerRob Landley <rob@landley.net>2013-12-19 21:38:12 -0600
commit6db8529a785e2cab142e840b6e3fbdcc2c02dd1f (patch)
treee22a0b2025f7848f05bcd4f5ed22b57956ef84ea /toys/other
parentbb5cfb270f924390c2163573cc5ed8fba9f638b8 (diff)
downloadtoybox-6db8529a785e2cab142e840b6e3fbdcc2c02dd1f.tar.gz
Don't permute toys.optargs, cleanup code (xexec()) can free it.
Diffstat (limited to 'toys/other')
-rw-r--r--toys/other/hello.c5
-rw-r--r--toys/other/pmap.c6
-rw-r--r--toys/other/pwdx.c8
3 files changed, 13 insertions, 6 deletions
diff --git a/toys/other/hello.c b/toys/other/hello.c
index e87cd6c9..eb80972e 100644
--- a/toys/other/hello.c
+++ b/toys/other/hello.c
@@ -41,6 +41,8 @@ GLOBALS(
void hello_main(void)
{
+ char **optargs;
+
printf("Hello world\n");
if (toys.optflags) printf("flags=%x\n", toys.optflags);
@@ -52,7 +54,8 @@ void hello_main(void)
TT.d_list = TT.d_list->next;
}
if (TT.e_count) printf("e was seen %ld times\n", TT.e_count);
- while (*toys.optargs) printf("optarg=%s\n", *(toys.optargs++));
+ for (optargs = toys.optargs; *optargs; optargs++)
+ printf("optarg=%s\n", *optargs);
if (toys.optflags & FLAG_walrus) printf("Saw --walrus\n");
if (TT.blubber_string) printf("--blubber=%s\n", TT.blubber_string);
}
diff --git a/toys/other/pmap.c b/toys/other/pmap.c
index 1cc04220..9ef1ade9 100644
--- a/toys/other/pmap.c
+++ b/toys/other/pmap.c
@@ -24,8 +24,10 @@ config PMAP
void pmap_main(void)
{
- while (*toys.optargs) {
- pid_t pid = atolx(*toys.optargs++);
+ char **optargs;
+
+ for (optargs = toys.optargs; *optargs; optargs++) {
+ pid_t pid = atolx(*optargs);
FILE *fp;
char *line, *oldline = 0, *name = 0,
*k = (toys.optflags & FLAG_x) ? "" : "K";
diff --git a/toys/other/pwdx.c b/toys/other/pwdx.c
index 5be49d62..b2acc411 100644
--- a/toys/other/pwdx.c
+++ b/toys/other/pwdx.c
@@ -17,11 +17,13 @@ config PWDX
void pwdx_main(void)
{
- for (; *toys.optargs; toys.optargs++) {
+ char **optargs;
+
+ for (optargs = toys.optargs; *optargs; optargs++) {
char *path;
int num_bytes;
- path = xmsprintf("/proc/%s/cwd", *toys.optargs);
+ path = xmsprintf("/proc/%s/cwd", *optargs);
num_bytes = readlink(path, toybuf, sizeof(toybuf)-1);
free(path);
@@ -32,6 +34,6 @@ void pwdx_main(void)
path = toybuf;
toybuf[num_bytes] = 0;
}
- xprintf("%s: %s\n", *toys.optargs, path);
+ xprintf("%s: %s\n", *optargs, path);
}
}