--- old/common/src/fixpath.c 2014-04-15 13:28:01.338115600 -0700 +++ new/common/src/fixpath.c 2014-04-15 13:28:00.884990600 -0700 @@ -118,7 +118,7 @@ } /* - * Creates a new string from in where the first occurance of sub is + * Creates a new string from in where the first occurrence of sub is * replaced by rep. */ char *replace_substring(char *in, char *sub, char *rep) @@ -246,7 +246,7 @@ } buffer = (char*) malloc(buflen); - while((blocklen = fread(block,1,sizeof(block),atin)) > 0) { + while ((blocklen = fread(block,1,sizeof(block),atin)) > 0) { append(&buffer, &buflen, &used, block, blocklen); } buffer[used] = 0; @@ -280,16 +280,21 @@ char *current = quoted; int pass; - if(strpbrk(in_arg, " \t\n\v\r\\\"") == NULL) { + if (strlen(in_arg) == 0) { + // empty string? explicitly quote it. + return _strdup("\"\""); + } + + if (strpbrk(in_arg, " \t\n\v\r\\\"") == NULL) { return _strdup(in_arg); } // process the arg twice. Once to calculate the size and then to copy it. - for(pass=1; pass<=2; pass++) { + for (pass=1; pass<=2; pass++) { char const *arg = in_arg; // initial " - if(pass == 2) { + if (pass == 2) { *current = '\"'; } current++; @@ -328,7 +333,7 @@ *current = *arg; } current++; - } while( *arg++ != '\0'); + } while ( *arg++ != '\0'); // allocate the buffer if (pass == 1) { @@ -399,7 +404,7 @@ } rc = SetEnvironmentVariable(var, val); - if(!rc) { + if (!rc) { // Could not set var for some reason. Try to report why. const int msg_len = 80 + var_len + strlen(val); char * msg = (char *) alloca(msg_len); @@ -422,7 +427,7 @@ // handle command and it's args. while (i < argc) { char const *replaced = replace_cygdrive(argv[i]); - if(replaced[0] == '@') { + if (replaced[0] == '@') { // Found at-file! Fix it! replaced = fix_at_file(replaced); } @@ -433,7 +438,7 @@ // determine the length of the line line = NULL; // args - for(i = cmd; i < argc; i++) { + for (i = cmd; i < argc; i++) { line += (ptrdiff_t) strlen(argv[i]); } // spaces and null @@ -443,7 +448,7 @@ // copy in args. current = line; - for(i = cmd; i < argc; i++) { + for (i = cmd; i < argc; i++) { ptrdiff_t len = strlen(argv[i]); if (i != cmd) { *current++ = ' '; @@ -457,7 +462,7 @@ fprintf(stderr, "fixpath converted line >%s<\n", line); } - if(cmd == argc) { + if (cmd == argc) { if (getenv("DEBUG_FIXPATH") != NULL) { fprintf(stderr, "fixpath no command provided!\n"); } @@ -481,7 +486,7 @@ NULL, &si, &pi); - if(!rc) { + if (!rc) { // Could not start process for some reason. Try to report why: report_error("Could not start process!"); exit(126);