Rename pusharg() to deinputstr()

This commit is contained in:
sin 2014-01-08 20:22:10 +00:00
parent e96144118e
commit cec487585c

26
xargs.c
View File

@ -19,7 +19,7 @@ static int eatspace(void);
static int parsequote(int); static int parsequote(int);
static int parseescape(void); static int parseescape(void);
static char *poparg(void); static char *poparg(void);
static void pusharg(char *); static void deinputstr(char *);
static void waitchld(void); static void waitchld(void);
static void runcmd(void); static void runcmd(void);
@ -86,7 +86,7 @@ main(int argc, char *argv[])
i >= NARGS - 1) { i >= NARGS - 1) {
if (strlen(arg) + 1 > argmaxsz) if (strlen(arg) + 1 > argmaxsz)
enprintf(EXIT_FAILURE, "insufficient argument space\n"); enprintf(EXIT_FAILURE, "insufficient argument space\n");
pusharg(arg); deinputstr(arg);
break; break;
} }
cmd[i] = strdup(arg); cmd[i] = strdup(arg);
@ -122,6 +122,15 @@ deinputc(int ch)
ungetc(ch, stdin); ungetc(ch, stdin);
} }
static void
deinputstr(char *arg)
{
char *p;
for (p = &arg[strlen(arg) - 1]; p >= arg; p--)
deinputc(*p);
}
static void static void
fillargbuf(int ch) fillargbuf(int ch)
{ {
@ -157,10 +166,8 @@ parsequote(int q)
int ch; int ch;
while ((ch = inputc()) != EOF) { while ((ch = inputc()) != EOF) {
if (ch == q) { if (ch == q)
fillargbuf('\0');
return 0; return 0;
}
if (ch != '\n') { if (ch != '\n') {
fillargbuf(ch); fillargbuf(ch);
argbpos++; argbpos++;
@ -225,15 +232,6 @@ out:
return NULL; return NULL;
} }
static void
pusharg(char *arg)
{
char *p;
for (p = &arg[strlen(arg) - 1]; p >= arg; p--)
deinputc(*p);
}
static void static void
waitchld(void) waitchld(void)
{ {