sbase

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

commit 3aec0ac2a4a95b4a1b04eca2502495568f0aa7c4
parent bb4d7a0e7ebcfcc14a3e692827d46fe64d8a69fb
Author: sin <sin@2f30.org>
Date:   Mon,  6 Jan 2014 18:20:26 +0000

Use a return value to signal an invalid backslash

Just for consistency with the rest of the code.

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

diff --git a/xargs.c b/xargs.c @@ -17,7 +17,7 @@ static void deinputc(int); static void fillbuf(int); static int eatspace(void); static int parsequote(int); -static void parseescape(void); +static int parseescape(void); static char *poparg(void); static void pusharg(char *); static void runcmd(void); @@ -160,7 +160,7 @@ parsequote(int q) return -1; } -static void +static int parseescape(void) { int ch; @@ -168,9 +168,9 @@ parseescape(void) if ((ch = inputc()) != EOF) { fillbuf(ch); argbpos++; - return; + return ch; } - enprintf(EXIT_FAILURE, "backslash at EOF\n"); + return -1; } static char * @@ -198,7 +198,8 @@ poparg(void) "unterminated double quote\n"); break; case '\\': - parseescape(); + if (parseescape() == -1) + enprintf(EXIT_FAILURE, "backslash at EOF\n"); break; default: fillbuf(ch);