aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-08-25 15:32:22 -0500
committerRob Landley <rob@landley.net>2018-08-25 15:32:22 -0500
commit482c422f8e8ec517de071266d425b425c4628103 (patch)
tree709d459ba58b1416c340ffedab69faf21d4bee99
parent79c403179b603a9f3c8cd120a93c2f560017864b (diff)
downloadtoybox-482c422f8e8ec517de071266d425b425c4628103.tar.gz
Convert more argument variables in GLOBALS() to new style.
-rw-r--r--toys/posix/patch.c15
-rw-r--r--toys/posix/ps.c33
-rw-r--r--toys/posix/renice.c4
-rw-r--r--toys/posix/sed.c3
-rw-r--r--toys/posix/split.c18
-rw-r--r--toys/posix/strings.c4
-rw-r--r--toys/posix/tail.c11
-rw-r--r--toys/posix/touch.c12
-rw-r--r--toys/posix/ulimit.c9
9 files changed, 41 insertions, 68 deletions
diff --git a/toys/posix/patch.c b/toys/posix/patch.c
index 181af2a1..1a3c7bbb 100644
--- a/toys/posix/patch.c
+++ b/toys/posix/patch.c
@@ -18,7 +18,7 @@
* -F fuzz (number, default 2)
* [file] which file to patch
-USE_PATCH(NEWTOY(patch, "(dry-run)"USE_TOYBOX_DEBUG("x")"d:ulp#i:R", TOYFLAG_USR|TOYFLAG_BIN))
+USE_PATCH(NEWTOY(patch, "(dry-run)"USE_TOYBOX_DEBUG("x")"ulp#d:i:R", TOYFLAG_USR|TOYFLAG_BIN))
config PATCH
bool "patch"
@@ -48,9 +48,8 @@ config PATCH
#include "toys.h"
GLOBALS(
- char *infile;
- long prefix;
- char *dir;
+ char *i, *d;
+ long p;
struct double_list *current_hunk;
long oldline, oldlen, newline, newlen;
@@ -265,10 +264,10 @@ void patch_main(void)
strip = 0;
char *oldname = NULL, *newname = NULL;
- if (TT.infile) TT.filepatch = xopenro(TT.infile);
+ if (TT.i) TT.filepatch = xopenro(TT.i);
TT.filein = TT.fileout = -1;
- if (TT.dir) xchdir(TT.dir);
+ if (TT.d) xchdir(TT.d);
// Loop through the lines in the patch
for (;;) {
@@ -380,7 +379,7 @@ void patch_main(void)
// handle -p path truncation.
for (i = 0, s = name; *s;) {
- if ((toys.optflags & FLAG_p) && TT.prefix == i) break;
+ if ((toys.optflags & FLAG_p) && TT.p == i) break;
if (*s++ != '/') continue;
while (*s == '/') s++;
name = s;
@@ -392,7 +391,7 @@ void patch_main(void)
xunlink(name);
state = 0;
// If we've got a file to open, do so.
- } else if (!(toys.optflags & FLAG_p) || i <= TT.prefix) {
+ } else if (!(toys.optflags & FLAG_p) || i <= TT.p) {
// If the old file was null, we're creating a new one.
if ((!strcmp(oldname, "/dev/null") || !oldsum) && access(name, F_OK))
{
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index 5133b69b..27dc63c5 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -190,40 +190,19 @@ config PKILL
GLOBALS(
union {
struct {
- struct arg_list *G;
- struct arg_list *g;
- struct arg_list *U;
- struct arg_list *u;
- struct arg_list *t;
- struct arg_list *s;
- struct arg_list *p;
- struct arg_list *O;
- struct arg_list *o;
- struct arg_list *P;
- struct arg_list *k;
+ struct arg_list *G, *g, *U, *u, *t, *s, *p, *O, *o, *P, *k;
} ps;
struct {
- long n;
- long m;
+ long n, m;
char *d;
long s;
- struct arg_list *u;
- struct arg_list *p;
- struct arg_list *o;
- struct arg_list *k;
- struct arg_list *O;
+ struct arg_list *u, *p, *o, *k, *O;
long d_ms;
} top;
struct {
char *L;
- struct arg_list *G;
- struct arg_list *g;
- struct arg_list *P;
- struct arg_list *s;
- struct arg_list *t;
- struct arg_list *U;
- struct arg_list *u;
+ struct arg_list *G, *g, *P, *s, *t, *U, *u;
char *d;
void *regexes, *snapshot;
@@ -399,8 +378,8 @@ struct typography {
{"READ", "Data read", 6, SLOT_rchar},
{"WRITE", "Data written", 6, SLOT_wchar},
{"IO", "Data I/O", 6, SLOT_iobytes},
- {"DREAD", "Disk Read", 6, SLOT_rbytes},
- {"DWRITE", "Disk write", 6, SLOT_wbytes},
+ {"DREAD", "Data read from disk", 6, SLOT_rbytes},
+ {"DWRITE", "Data written to disk", 6, SLOT_wbytes},
{"SWAP", "Swap I/O", 6, SLOT_swap},
{"DIO", "Disk I/O", 6, SLOT_diobytes},
diff --git a/toys/posix/renice.c b/toys/posix/renice.c
index 489eb138..c1167c8c 100644
--- a/toys/posix/renice.c
+++ b/toys/posix/renice.c
@@ -17,7 +17,7 @@ config RENICE
#include "toys.h"
GLOBALS(
- long nArgu;
+ long n;
)
void renice_main(void) {
@@ -42,7 +42,7 @@ void renice_main(void) {
continue;
}
- if (setpriority(which, id, getpriority(which, id)+TT.nArgu) < 0)
+ if (setpriority(which, id, getpriority(which, id)+TT.n) < 0)
perror_msg("setpriority %d", id);
}
}
diff --git a/toys/posix/sed.c b/toys/posix/sed.c
index 17d8bcde..ea4d0055 100644
--- a/toys/posix/sed.c
+++ b/toys/posix/sed.c
@@ -170,8 +170,7 @@ config SED
#include "toys.h"
GLOBALS(
- struct arg_list *f;
- struct arg_list *e;
+ struct arg_list *f, *e;
// processed pattern list
struct double_list *pattern;
diff --git a/toys/posix/split.c b/toys/posix/split.c
index 98d70c2a..0da8da6a 100644
--- a/toys/posix/split.c
+++ b/toys/posix/split.c
@@ -28,9 +28,7 @@ config SPLIT
#include "toys.h"
GLOBALS(
- long lines;
- long bytes;
- long suflen;
+ long l, b, a;
char *outfile;
)
@@ -56,23 +54,23 @@ static void do_split(int infd, char *in)
}
// Start new output file?
- if ((TT.bytes && !bytesleft) || (TT.lines && !linesleft)) {
+ if ((TT.b && !bytesleft) || (TT.l && !linesleft)) {
char *s = TT.outfile + strlen(TT.outfile);
j = filenum++;
- for (i = 0; i<TT.suflen; i++) {
+ for (i = 0; i<TT.a; i++) {
*(--s) = 'a'+(j%26);
j /= 26;
}
if (j) error_exit("bad suffix");
- bytesleft = TT.bytes;
- linesleft = TT.lines;
+ bytesleft = TT.b;
+ linesleft = TT.l;
if (outfd != -1) close(outfd);
outfd = xcreate(TT.outfile, O_RDWR|O_CREAT|O_TRUNC, st.st_mode & 0777);
}
// Write next chunk of output.
- if (TT.lines) {
+ if (TT.l) {
for (i = pos; i < len; ) {
if (toybuf[i++] == '\n' && !--linesleft) break;
if (!--bytesleft) break;
@@ -97,11 +95,11 @@ static void do_split(int infd, char *in)
void split_main(void)
{
- if (!TT.bytes && !TT.lines) TT.lines = 1000;
+ if (!TT.b && !TT.l) TT.l = 1000;
// Allocate template for output filenames
TT.outfile = xmprintf("%s%*c", (toys.optc == 2) ? toys.optargs[1] : "x",
- (int)TT.suflen, ' ');
+ (int)TT.a, ' ');
// We only ever use one input, but this handles '-' or no input for us.
loopfiles(toys.optargs, do_split);
diff --git a/toys/posix/strings.c b/toys/posix/strings.c
index 911fc452..e33ae960 100644
--- a/toys/posix/strings.c
+++ b/toys/posix/strings.c
@@ -32,13 +32,13 @@ config STRINGS
#include "toys.h"
GLOBALS(
- long num;
+ long n;
char *t;
)
static void do_strings(int fd, char *filename)
{
- int nread, i, wlen = TT.num, count = 0;
+ int nread, i, wlen = TT.n, count = 0;
off_t offset = 0;
char *string = 0, pattern[8];
diff --git a/toys/posix/tail.c b/toys/posix/tail.c
index 675d815d..bf997864 100644
--- a/toys/posix/tail.c
+++ b/toys/posix/tail.c
@@ -34,8 +34,7 @@ config TAIL_SEEK
#include <sys/inotify.h>
GLOBALS(
- long lines;
- long bytes;
+ long n, c;
int file_no, ffd, *files;
)
@@ -134,7 +133,7 @@ static int try_lseek(int fd, long bytes, long lines)
// Called for each file listed on command line, and/or stdin
static void do_tail(int fd, char *name)
{
- long bytes = TT.bytes, lines = TT.lines;
+ long bytes = TT.c, lines = TT.n;
int linepop = 1;
if (toys.optflags & FLAG_f) {
@@ -166,7 +165,7 @@ static void do_tail(int fd, char *name)
dlist_add_nomalloc((void *)&list, (void *)new);
// If tracing bytes, add until we have enough, discarding overflow.
- if (TT.bytes) {
+ if (TT.c) {
bytes += new->len;
if (bytes > 0) {
while (list->len <= bytes) {
@@ -229,11 +228,11 @@ void tail_main(void)
// handle old "-42" style arguments
if (arg && *arg == '-' && arg[1]) {
- TT.lines = atolx(*(args++));
+ TT.n = atolx(*(args++));
toys.optc--;
} else {
// if nothing specified, default -n to -10
- TT.lines = -10;
+ TT.n = -10;
}
}
diff --git a/toys/posix/touch.c b/toys/posix/touch.c
index 214d6cf9..5e5588b1 100644
--- a/toys/posix/touch.c
+++ b/toys/posix/touch.c
@@ -27,9 +27,7 @@ config TOUCH
#include "toys.h"
GLOBALS(
- char *time;
- char *file;
- char *date;
+ char *t, *r, *d;
)
void touch_main(void)
@@ -52,10 +50,10 @@ void touch_main(void)
// List of search types
if (toys.optflags & FLAG_d) {
format = (char *[]){"%Y-%m-%dT%T", "%Y-%m-%d %T", 0};
- date = TT.date;
+ date = TT.d;
} else {
format = (char *[]){"%m%d%H%M", "%y%m%d%H%M", "%C%y%m%d%H%M", 0};
- date = TT.time;
+ date = TT.t;
}
// Trailing Z means UTC timezone, don't expect libc to know this.
@@ -101,10 +99,10 @@ void touch_main(void)
// Set time from -r?
- if (TT.file) {
+ if (TT.r) {
struct stat st;
- xstat(TT.file, &st);
+ xstat(TT.r, &st);
ts[0] = st.st_atim;
ts[1] = st.st_mtim;
}
diff --git a/toys/posix/ulimit.c b/toys/posix/ulimit.c
index 0aedd2cc..4fa01618 100644
--- a/toys/posix/ulimit.c
+++ b/toys/posix/ulimit.c
@@ -17,6 +17,7 @@
* runtime). We support -P to affect processes other than us.
USE_ULIMIT(NEWTOY(ulimit, ">1P#<1SHavutsrRqpnmlifedc[-SH][!apvutsrRqnmlifedc]", TOYFLAG_USR|TOYFLAG_BIN))
+USE_ULIMIT(OLDTOY(prlimit, ulimit, TOYFLAG_USR|TOYFLAG_BIN))
config ULIMIT
bool "ulimit"
@@ -45,7 +46,7 @@ config ULIMIT
#include "toys.h"
GLOBALS(
- long pid;
+ long P;
)
// This is a linux kernel syscall added in 2.6.36 (git c022a0acad53) which
@@ -70,14 +71,14 @@ void ulimit_main(void)
if ((toys.optflags&(FLAG_a|FLAG_p)) && toys.optc) error_exit("can't set -ap");
// Fetch data
- if (!(toys.optflags&FLAG_P)) TT.pid = getppid();
+ if (!(toys.optflags&FLAG_P)) TT.P = getppid();
for (i=0; i<sizeof(map); i++) {
char *flags="cdefilmnpqRrstuv";
int get = toys.optflags&(FLAG_a|(1<<i));
- if (get && prlimit(TT.pid, map[i], 0, &rr)) perror_exit("-%c", flags[i]);
+ if (get && prlimit(TT.P, map[i], 0, &rr)) perror_exit("-%c", flags[i]);
if (!toys.optc) {
if (toys.optflags&FLAG_a) printf("-%c: ", flags[i]);
if (get) {
@@ -112,6 +113,6 @@ void ulimit_main(void)
if (toys.optflags&FLAG_H) rr.rlim_max = val;
else rr.rlim_cur = val;
- if (prlimit(TT.pid, map[i], &rr, 0)) perror_exit(0);
+ if (prlimit(TT.P, map[i], &rr, 0)) perror_exit(0);
}
}