sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 0511ecfd8465fe44c8ba4d26278aeb884733f1ed
parent ef57a609cae68dae28285d5dab123c259e0a9185
Author: sin <sin@2f30.org>
Date:   Mon,  6 Jan 2014 18:12:06 +0000

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

Diffstat:
Mxargs.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

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