If eatspace() encounters EOF don't try to read again from stdin

This commit is contained in:
sin 2014-01-06 18:12:06 +00:00
parent ef57a609ca
commit 0511ecfd84

10
xargs.c
View File

@ -15,7 +15,7 @@ enum {
static int inputc(void); static int inputc(void);
static void deinputc(int); static void deinputc(int);
static void fillbuf(int); static void fillbuf(int);
static void eatspace(void); static int eatspace(void);
static int parsequote(int); static int parsequote(int);
static void parseescape(void); static void parseescape(void);
static char *poparg(void); static char *poparg(void);
@ -125,7 +125,7 @@ fillbuf(int ch)
argb[argbpos] = ch; argb[argbpos] = ch;
} }
static void static int
eatspace(void) eatspace(void)
{ {
int ch; int ch;
@ -136,9 +136,10 @@ eatspace(void)
break; break;
default: default:
deinputc(ch); deinputc(ch);
return; return ch;
} }
} }
return -1;
} }
static int static int
@ -176,7 +177,8 @@ poparg(void)
int ch; int ch;
argbpos = 0; argbpos = 0;
eatspace(); if (eatspace() == -1)
return NULL;
while ((ch = inputc()) != EOF) { while ((ch = inputc()) != EOF) {
switch (ch) { switch (ch) {
case ' ': case '\t': case '\n': case ' ': case '\t': case '\n':