diff options
author | Rob Landley <rob@landley.net> | 2018-08-31 15:02:21 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2018-08-31 15:14:12 -0500 |
commit | 8993496e496cdbc80643b69d049d05bbd7f596b3 (patch) | |
tree | 8790f2ada6dfdc0e98265672cac9b8ae07bfce56 | |
parent | 198b2b48345c175dc184258677fd48043dc1a78b (diff) | |
download | toybox-8993496e496cdbc80643b69d049d05bbd7f596b3.tar.gz |
Convert option style.
-rw-r--r-- | toys/posix/cp.c | 18 | ||||
-rw-r--r-- | toys/posix/cpio.c | 16 | ||||
-rw-r--r-- | toys/posix/cut.c | 3 | ||||
-rw-r--r-- | toys/posix/date.c | 18 | ||||
-rw-r--r-- | toys/posix/df.c | 6 | ||||
-rw-r--r-- | toys/posix/du.c | 4 | ||||
-rw-r--r-- | toys/posix/expand.c | 4 |
7 files changed, 31 insertions, 38 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c index 216d4592..373ac13e 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -97,12 +97,11 @@ config INSTALL GLOBALS( union { + // install's options struct { - // install's options - char *group; - char *user; - char *mode; + char *g, *o, *m; } i; + // cp's options struct { char *preserve; } c; @@ -469,10 +468,9 @@ static inline int cp_flag_v(void) { return FLAG_v; }; static int install_node(struct dirtree *try) { - try->st.st_mode = (TT.i.mode) - ? string_to_mode(TT.i.mode, try->st.st_mode) : 0755; - if (TT.i.group) try->st.st_gid = TT.gid; - if (TT.i.user) try->st.st_uid = TT.uid; + try->st.st_mode = TT.i.m ? string_to_mode(TT.i.m, try->st.st_mode) : 0755; + if (TT.i.g) try->st.st_gid = TT.gid; + if (TT.i.o) try->st.st_uid = TT.uid; // Always returns 0 because no -r cp_node(try); @@ -511,8 +509,8 @@ void install_main(void) if (flags & FLAG_v) toys.optflags |= cp_flag_v(); if (flags & (FLAG_p|FLAG_o|FLAG_g)) toys.optflags |= cp_flag_p(); - if (TT.i.user) TT.uid = xgetuid(TT.i.user); - if (TT.i.group) TT.gid = xgetgid(TT.i.group); + if (TT.i.o) TT.uid = xgetuid(TT.i.o); + if (TT.i.g) TT.gid = xgetgid(TT.i.g); TT.callback = install_node; cp_main(); diff --git a/toys/posix/cpio.c b/toys/posix/cpio.c index 6ce3ef1c..f9da69e1 100644 --- a/toys/posix/cpio.c +++ b/toys/posix/cpio.c @@ -41,9 +41,7 @@ config CPIO #include "toys.h" GLOBALS( - char *archive; - char *pass; - char *fmt; + char *F, *p, *H; ) // Read strings, tail padded to 4 byte alignment. Argument "align" is amount @@ -87,7 +85,7 @@ void cpio_main(void) // In passthrough mode, parent stays in original dir and generates archive // to pipe, child does chdir to new dir and reads archive from stdin (pipe). - if (TT.pass) { + if (TT.p) { if (toys.stacktop) { // xpopen() doesn't return from child due to vfork(), instead restarts // with !toys.stacktop @@ -96,14 +94,14 @@ void cpio_main(void) } else { // child toys.optflags |= FLAG_i; - xchdir(TT.pass); + xchdir(TT.p); } } - if (TT.archive) { + if (TT.F) { int perm = (toys.optflags & FLAG_o) ? O_CREAT|O_WRONLY|O_TRUNC : O_RDONLY; - afd = xcreate(TT.archive, perm, 0644); + afd = xcreate(TT.F, perm, 0644); } // read cpio archive @@ -282,7 +280,7 @@ void cpio_main(void) sprintf(toybuf, "070701%040X%056X%08XTRAILER!!!", 1, 0x0b, 0)+4); } } - if (TT.archive) xclose(afd); + if (TT.F) xclose(afd); - if (TT.pass) toys.exitval |= xpclose(pid, pipe); + if (TT.p) toys.exitval |= xpclose(pid, pipe); } diff --git a/toys/posix/cut.c b/toys/posix/cut.c index 83582aaa..0b12ab14 100644 --- a/toys/posix/cut.c +++ b/toys/posix/cut.c @@ -39,8 +39,7 @@ config CUT #include "toys.h" GLOBALS( - char *d; - char *O; + char *d, *O; struct arg_list *select[5]; // we treat them the same, so loop through int pairs; diff --git a/toys/posix/date.c b/toys/posix/date.c index 56eb02bd..7a42fc81 100644 --- a/toys/posix/date.c +++ b/toys/posix/date.c @@ -48,9 +48,7 @@ config DATE #include "toys.h" GLOBALS( - char *file; - char *setfmt; - char *showdate; + char *r, *D, *d; unsigned nano; ) @@ -166,18 +164,18 @@ void date_main(void) memset(&tm, 0, sizeof(struct tm)); - if (TT.showdate) { - if (TT.setfmt) { - char *s = strptime(TT.showdate, TT.setfmt+(*TT.setfmt=='+'), &tm); + if (TT.d) { + if (TT.D) { + char *s = strptime(TT.d, TT.D+(*TT.D=='+'), &tm); if (!s || *s) goto bad_showdate; - } else if (parse_default(TT.showdate, &tm)) goto bad_showdate; + } else if (parse_default(TT.d, &tm)) goto bad_showdate; } else { struct timespec ts; struct stat st; - if (TT.file) { - xstat(TT.file, &st); + if (TT.r) { + xstat(TT.r, &st); ts = st.st_mtim; } else clock_gettime(CLOCK_REALTIME, &ts); @@ -228,7 +226,7 @@ void date_main(void) return; bad_showdate: - setdate = TT.showdate; + setdate = TT.d; bad_setdate: perror_exit("bad date '%s'", setdate); } diff --git a/toys/posix/df.c b/toys/posix/df.c index 64eabf2e..fa136275 100644 --- a/toys/posix/df.c +++ b/toys/posix/df.c @@ -32,7 +32,7 @@ config DF #include "toys.h" GLOBALS( - struct arg_list *fstype; + struct arg_list *t; long units; int column_widths[5]; @@ -104,10 +104,10 @@ static void show_mt(struct mtab_list *mt, int measuring) if (!mt) return; // If we have -t, skip other filesystem types - if (TT.fstype) { + if (TT.t) { struct arg_list *al; - for (al = TT.fstype; al; al = al->next) + for (al = TT.t; al; al = al->next) if (!strcmp(mt->type, al->arg)) break; if (!al) return; diff --git a/toys/posix/du.c b/toys/posix/du.c index e315d3a3..d2f57277 100644 --- a/toys/posix/du.c +++ b/toys/posix/du.c @@ -37,7 +37,7 @@ config DU #include "toys.h" GLOBALS( - long maxdepth; + long d; unsigned long depth, total; dev_t st_dev; @@ -54,7 +54,7 @@ static void print(long long size, struct dirtree *node) { char *name = "total"; - if (TT.depth > TT.maxdepth) return; + if (TT.depth > TT.d) return; if (toys.optflags & FLAG_h) { human_readable(toybuf, size, 0); diff --git a/toys/posix/expand.c b/toys/posix/expand.c index d4914ab5..301d361e 100644 --- a/toys/posix/expand.c +++ b/toys/posix/expand.c @@ -26,7 +26,7 @@ config EXPAND #include "toys.h" GLOBALS( - struct arg_list *tabs; + struct arg_list *t; unsigned tabcount, *tab; ) @@ -93,7 +93,7 @@ static int parse_tablist(unsigned *tablist) struct arg_list *tabs; int tabcount = 0; - for (tabs = TT.tabs; tabs; tabs = tabs->next) { + for (tabs = TT.t; tabs; tabs = tabs->next) { char *s = tabs->arg; while (*s) { |