diff options
Diffstat (limited to 'src/worker.c')
-rw-r--r-- | src/worker.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/worker.c b/src/worker.c index 17c7f5e..7529394 100644 --- a/src/worker.c +++ b/src/worker.c @@ -11,7 +11,9 @@ #include <stdio.h> #include <string.h> +#ifndef _WIN32 #include <strings.h> +#endif #include <stdlib.h> #include <ctype.h> @@ -263,11 +265,11 @@ static char *expand_system_variables( const char *s ) size_t r_size = strlen( s ) * 2; char *r = (char *)malloc( r_size ); char *d = r; - enum { COPYING, DOLLAR, OPEN_BRACE, VARIABLE, CLOSE_BRACE, ERROR } state = COPYING; + enum { COPYING, DOLLAR, OPEN_BRACE, VARIABLE, CLOSE_BRACE, _ERROR } state = COPYING; const char *var = NULL; const char *p = s; - while( state != ERROR && *p != '\0' && d - r < r_size - 1 ) { + while( state != _ERROR && *p != '\0' && d - r < r_size - 1 ) { switch( state ) { case COPYING: if( *p == '$' ) { @@ -286,14 +288,14 @@ static char *expand_system_variables( const char *s ) p++; } else { fprintf( stderr, "ERROR: Unexpected '{' at position %d in '%s'\n", (int)( p - s ), s ); - state = ERROR; + state = _ERROR; } break; case OPEN_BRACE: if( *p == '}' ) { fprintf( stderr, "ERROR: Empty variable declaration '${}' at position %d in '%s'\n", (int)( p - s ), s ); - state = ERROR; + state = _ERROR; p++; } else if( isalpha( *p ) ) { // ok, part of variable name @@ -302,7 +304,7 @@ static char *expand_system_variables( const char *s ) p++; } else { fprintf( stderr, "ERROR: Illegal character '%c' at position %d in variable in '%s'\n", *p, (int)( p - s ), s ); - state = ERROR; + state = _ERROR; } break; @@ -314,7 +316,7 @@ static char *expand_system_variables( const char *s ) p++; } else { fprintf( stderr, "ERROR: Illegal character '%c' at position %d in variable in '%s'\n", *p, (int)( p - s ), s ); - state = ERROR; + state = _ERROR; } break; @@ -346,12 +348,12 @@ static char *expand_system_variables( const char *s ) state = COPYING; } else { fprintf( stderr, "ERROR: Unknown variable '${%*s}' at position %d in '%s'\n", (int)( p-var ), var, (int)( p - s ), s ); - state = ERROR; + state = _ERROR; } p++; break; - case ERROR: + case _ERROR: default: break; } @@ -360,7 +362,7 @@ static char *expand_system_variables( const char *s ) if( d - r >= r_size - 1 ) { fprintf( stderr, "ERROR: out of memory while substituting variables in '%s'\n", s ); - state = ERROR; + state = _ERROR; } switch( state ) { @@ -378,7 +380,7 @@ static char *expand_system_variables( const char *s ) fprintf( stderr, "ERROR: illegal state while parsing command '%s'\n", s ); break; - case ERROR: + case _ERROR: return NULL; } |