return 1;
}
-/**
- * Return the filename, turning any newlines into '?'s. This ensures that
- * outputting it on a line of its own cannot generate an empty line. This
- * function can handle only 2 names at a time!
- **/
+/* Return the filename, turning any non-printable characters into '?'s.
+ * This ensures that outputting it on a line of its own cannot generate an
+ * empty line. This function can return only MAX_SAFE_NAMES values at a
+ * time! The returned value can be longer than MAXPATHLEN (because we
+ * may be trying to output an error about a too-long filename)! */
const char *safe_fname(const char *fname)
{
#define MAX_SAFE_NAMES 4
ndx = (ndx + 1) % MAX_SAFE_NAMES;
for (t = fbuf[ndx]; *fname; fname++) {
- if (!isprint(*fname))
+ if (!isprint(*(uchar*)fname))
*t++ = '?';
else
*t++ = *fname;
if (strcmp(s+1, "orig") == 0)
continue;
} else if (s_len > 2 && had_tilde
- && s[1] == '~' && isdigit(s[2]))
+ && s[1] == '~' && isdigit(*(uchar*)(s+2)))
continue;
*len_ptr = s_len;
suf = s;
break;
/* Determine if the suffix is all digits. */
for (s++, s_len--; s_len > 0; s++, s_len--) {
- if (!isdigit(*s))
+ if (!isdigit(*(uchar*)s))
return suf;
}
/* An all-digit suffix may not be that signficant. */