break; // EOF.
} else if (pwc < 32 || pwc == '\'' || pwc == '"' || pwc == '\\') {
all_safe = false;
+ } else if (pwc == '`') {
+ // A rather odd case; ls quotes this but does not escape it.
+ all_safe = false;
} else {
ptr += ret;
len -= ret;
}
- } while (all_safe);
+ } while (all_safe && *ptr != '\0');
if (all_safe) {
printf("%s\n", str.c_str());
mbtowc(nullptr, 0, 0);
ptr = str.data();
len = str.size();
- for (;;) {
+ while (*ptr != '\0') {
int ret = mbtowc(nullptr, ptr, len);
if (ret == -1) {
// Malformed data.
printf("?");
++ptr;
--len;
+ continue;
} else if (ret == 0) {
break; // EOF.
}