fix fallout from isprint() changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2009-11-20 19:14:19 +01:00
parent ad7d94bdc7
commit c270454f8f
3 changed files with 29 additions and 24 deletions

View File

@ -129,7 +129,7 @@ int wc_main(int argc UNUSED_PARAM, char **argv)
--counts[WC_CHARS]; --counts[WC_CHARS];
goto DO_EOF; /* Treat an EOF as '\r'. */ goto DO_EOF; /* Treat an EOF as '\r'. */
} }
if (isprint(c)) { if (isprint_asciionly(c)) {
++linepos; ++linepos;
if (!isspace(c)) { if (!isspace(c)) {
in_word = 1; in_word = 1;

View File

@ -30,9 +30,10 @@
#if ENABLE_LOCALE_SUPPORT #if ENABLE_LOCALE_SUPPORT
#if ENABLE_FEATURE_VI_8BIT #if ENABLE_FEATURE_VI_8BIT
# define Isprint(c) isprint(c) //FIXME: this does not work properly for Unicode anyway
# define Isprint(c) (isprint)(c)
#else #else
# define Isprint(c) (isprint(c) && (unsigned char)(c) < 0x7f) # define Isprint(c) isprint_asciionly(c)
#endif #endif
#else #else
@ -891,7 +892,7 @@ static void colon(char *buf)
li, ch); li, ch);
} else if (strncmp(cmd, "file", i) == 0) { // what File is this } else if (strncmp(cmd, "file", i) == 0) { // what File is this
if (b != -1 || e != -1) { if (b != -1 || e != -1) {
not_implemented("No address allowed on this command"); status_line_bold("No address allowed on this command");
goto vc1; goto vc1;
} }
if (args[0]) { if (args[0]) {
@ -2588,36 +2589,41 @@ static void status_line(const char *format, ...)
// copy s to buf, convert unprintable // copy s to buf, convert unprintable
static void print_literal(char *buf, const char *s) static void print_literal(char *buf, const char *s)
{ {
char *d;
unsigned char c; unsigned char c;
char b[2];
b[1] = '\0';
buf[0] = '\0'; buf[0] = '\0';
if (!s[0]) if (!s[0])
s = "(NULL)"; s = "(NULL)";
d = buf;
for (; *s; s++) { for (; *s; s++) {
int c_is_no_print; int c_is_no_print;
c = *s; c = *s;
c_is_no_print = (c & 0x80) && !Isprint(c); c_is_no_print = (c & 0x80) && !Isprint(c);
if (c_is_no_print) { if (c_is_no_print) {
strcat(buf, SOn); strcpy(d, SOn);
d += sizeof(SOn)-1;
c = '.'; c = '.';
} }
if (c < ' ' || c == 127) { if (c < ' ' || c == 0x7f) {
strcat(buf, "^"); *d++ = '^';
if (c == 127) c |= '@'; /* 0x40 */
if (c == 0x7f)
c = '?'; c = '?';
else
c += '@';
} }
b[0] = c; *d++ = c;
strcat(buf, b); *d = '\0';
if (c_is_no_print) if (c_is_no_print) {
strcat(buf, SOs); strcpy(d, SOs);
if (*s == '\n') d += sizeof(SOs)-1;
strcat(buf, "$"); }
if (strlen(buf) > MAX_INPUT_LEN - 10) // paranoia if (*s == '\n') {
*d++ = '$';
*d = '\0';
}
if (d - buf > MAX_INPUT_LEN - 10) // paranoia
break; break;
} }
} }
@ -2982,11 +2988,6 @@ static void do_cmd(int c)
default: // unrecognized command default: // unrecognized command
buf[0] = c; buf[0] = c;
buf[1] = '\0'; buf[1] = '\0';
if (c < ' ') {
buf[0] = '^';
buf[1] = c + '@';
buf[2] = '\0';
}
not_implemented(buf); not_implemented(buf);
end_cmd_q(); // stop adding to q end_cmd_q(); // stop adding to q
case 0x00: // nul- ignore case 0x00: // nul- ignore

View File

@ -5572,6 +5572,10 @@ static int process_command_subs(o_string *dest, const char *s)
} }
#endif /* ENABLE_HUSH_TICK */ #endif /* ENABLE_HUSH_TICK */
#if !ENABLE_HUSH_FUNCTIONS
#define parse_group(dest, ctx, input, ch) \
parse_group(ctx, input, ch)
#endif
static int parse_group(o_string *dest, struct parse_context *ctx, static int parse_group(o_string *dest, struct parse_context *ctx,
struct in_str *input, int ch) struct in_str *input, int ch)
{ {