[hackers] [sbase] If eatspace() encounters EOF don't try to read again from stdin || sin
commit 0511ecfd8465fe44c8ba4d26278aeb884733f1ed
Author: sin <sin_AT_2f30.org>
Date: Mon Jan 6 18:12:06 2014 +0000
If eatspace() encounters EOF don't try to read again from stdin
diff --git a/xargs.c b/xargs.c
index da7754c..1bbf58c 100644
--- a/xargs.c
+++ b/xargs.c
_AT_@ -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);
_AT_@ -125,7 +125,7 @@ fillbuf(int ch)
argb[argbpos] = ch;
}
-static void
+static int
eatspace(void)
{
int ch;
_AT_@ -136,9 +136,10 @@ eatspace(void)
break;
default:
deinputc(ch);
- return;
+ return ch;
}
}
+ return -1;
}
static int
_AT_@ -176,7 +177,8 @@ poparg(void)
int ch;
argbpos = 0;
- eatspace();
+ if (eatspace() == -1)
+ return NULL;
while ((ch = inputc()) != EOF) {
switch (ch) {
case ' ': case ' ': case '
':
Received on Mon Jan 06 2014 - 19:13:32 CET
This archive was generated by hypermail 2.3.0
: Mon Jan 06 2014 - 19:24:09 CET