mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Use single-quote quoting instead of backslash quoting
This commit is contained in:
@@ -138,15 +138,30 @@ std::string format_commandline(int argc, char **argv) {
|
||||
std::string out;
|
||||
|
||||
for (int i = 0; i < argc; i++) {
|
||||
bool need_quote = false;
|
||||
for (char *cp = argv[i]; *cp != '\0'; cp++) {
|
||||
if (*cp == ' ' || *cp == '\\') {
|
||||
out.push_back('\\');
|
||||
out.push_back(*cp);
|
||||
} else {
|
||||
out.push_back(*cp);
|
||||
if (!isalpha(*cp) && !isdigit(*cp) &&
|
||||
*cp != '/' && *cp != '-' && *cp != '_' && *cp != '@' && *cp != ':' &&
|
||||
*cp != '.' && *cp != '%' && *cp != ',') {
|
||||
need_quote = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (need_quote) {
|
||||
out.push_back('\'');
|
||||
for (char *cp = argv[i]; *cp != '\0'; cp++) {
|
||||
if (*cp == '\'') {
|
||||
out.append("'\"'\"'");
|
||||
} else {
|
||||
out.push_back(*cp);
|
||||
}
|
||||
}
|
||||
out.push_back('\'');
|
||||
} else {
|
||||
out.append(argv[i]);
|
||||
}
|
||||
|
||||
if (i + 1 < argc) {
|
||||
out.push_back(' ');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user