Allow to change the output format

The new test option allows to restore the past
behaviour, just in case...
This commit is contained in:
Andrea Mazzoleni 2016-10-11 20:30:12 +02:00
parent 97c01d35f4
commit faa530e83e
7 changed files with 102 additions and 17 deletions

View file

@ -430,14 +430,22 @@ bail:
/* LCOV_EXCL_STOP */
}
const char* esc_shell(const char* str, char* buffer)
const char* esc_shell_multi(const char** str_map, unsigned str_max, char* buffer)
{
char* begin = buffer;
char* end = begin + ESC_MAX;
char* p = begin;
unsigned str_mac;
const char* str;
#ifdef _WIN32
int has_quote = strchr(str, ' ') != 0;
int has_quote = 0;
for (str_mac = 0; str_mac < str_max; ++str_mac) {
str = str_map[str_mac];
if (strchr(str, ' ') != 0)
has_quote = 1;
}
if (has_quote) {
if (p == end)
@ -447,9 +455,23 @@ const char* esc_shell(const char* str, char* buffer)
#endif
/* copy string with escaping */
while (*str) {
str_mac = 0;
str = str_map[str_mac];
while (1) {
/* get the next char */
char c = *str;
/* if one string is finished, go to the next */
while (c == 0 && str_mac + 1 < str_max) {
++str_mac;
str = str_map[str_mac];
c = *str;
}
/* if we read all the strings, stop */
if (!c)
break;
switch (c) {
#ifdef _WIN32
/*