Author: Niko Tyni Description: Allow empty strings as command-line parameters --- a/src/speedy_frontend.c +++ b/src/speedy_frontend.c @@ -535,7 +535,26 @@ ADD_STRING(b, s, l); } } + /* Terminate with zero-length string */ + ADDCHAR(b, 0); +} + +/* Copy a block of strings into the buffer, including empty strings */ +static void add_strings_with_empty(register SpeedyBuf *b, register const char * const * p) +{ + int l; + register const char *s; + /* Add strings in p array */ + for (; (s = *p); ++p) { + if ((l = strlen(s))) { + ADD_STRING(b, s, l); + } else { + /* add a 1-byte long string containing just '\0' */ + l = 1; + ADD_STRING(b, s, l); + } + } /* Terminate with zero-length string */ ADDCHAR(b, 0); } @@ -560,7 +579,7 @@ /* Add env and argv */ add_strings(sb, envp); - add_strings(sb, scr_argv+1); + add_strings_with_empty(sb, scr_argv+1); /* Put script filename into buffer */ add_string(sb, script_fname, strlen(script_fname));