From 41c147f40ef5d1fad211e2473fa47a47e45dfc2d Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sun, 12 Apr 2015 14:31:42 +0200 Subject: better variable parser for worker commands (I think) --- src/worker.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/worker.c b/src/worker.c index c73eb7e..17c7f5e 100644 --- a/src/worker.c +++ b/src/worker.c @@ -362,11 +362,26 @@ static char *expand_system_variables( const char *s ) fprintf( stderr, "ERROR: out of memory while substituting variables in '%s'\n", s ); state = ERROR; } - - if( state == ERROR ) { - return NULL; + + switch( state ) { + case COPYING: + // fine + break; + + case DOLLAR: + case OPEN_BRACE: + case VARIABLE: + fprintf( stderr, "ERROR: unterminated variable reference in '%s'\n", s ); + break; + + case CLOSE_BRACE: + fprintf( stderr, "ERROR: illegal state while parsing command '%s'\n", s ); + break; + + case ERROR: + return NULL; } - + return r; } -- cgit v1.2.3-54-g00ecf