This fix from christos@zoulas.com (Christos Zoulas) based on ache's

ports/shells/tcsh/patches/patch-ac fixes the problem with 8-bit characters
not highlighting properly.
This commit is contained in:
obrien 2000-04-20 05:02:30 +00:00
parent efebb8d2fa
commit cd1e9aaaab

View File

@ -1,4 +1,4 @@
/* $Header: /src/pub/tcsh/tc.prompt.c,v 3.37 2000/01/14 22:57:29 christos Exp $ */ /* $Header: /src/pub/tcsh/tc.prompt.c,v 3.38 2000/04/18 19:40:46 christos Exp $ */
/* /*
* tc.prompt.c: Prompt printing stuff * tc.prompt.c: Prompt printing stuff
*/ */
@ -36,7 +36,7 @@
*/ */
#include "sh.h" #include "sh.h"
RCSID("$Id: tc.prompt.c,v 3.37 2000/01/14 22:57:29 christos Exp $") RCSID("$Id: tc.prompt.c,v 3.38 2000/04/18 19:40:46 christos Exp $")
#include "ed.h" #include "ed.h"
#include "tw.h" #include "tw.h"
@ -186,9 +186,10 @@ tprintf(what, buf, fmt, siz, str, tim, info)
Char *z, *q; Char *z, *q;
Char attributes = 0; Char attributes = 0;
static int print_prompt_did_ding = 0; static int print_prompt_did_ding = 0;
const char *cz;
Char buff[BUFSIZE]; Char buff[BUFSIZE];
char cbuff[BUFSIZE]; /* Need to be unsigned to avoid sign extension */
const unsigned char *cz;
unsigned char cbuff[BUFSIZE];
Char *p = buf; Char *p = buf;
Char *ep = &p[siz]; Char *ep = &p[siz];
@ -218,9 +219,11 @@ tprintf(what, buf, fmt, siz, str, tim, info)
switch (*cp) { switch (*cp) {
case 'R': case 'R':
if (what == FMT_HISTORY) if (what == FMT_HISTORY)
fmthist('R', info, str = cbuff, sizeof(cbuff)); fmthist('R', info, (char *) (cz = cbuff), sizeof(cbuff));
else
cz = (unsigned char *) str;
if (str != NULL) if (str != NULL)
for (; *str; *p++ = attributes | *str++) for (; *cz; *p++ = attributes | *cz++)
if (p >= ep) break; if (p >= ep) break;
break; break;
case '#': case '#':
@ -233,10 +236,12 @@ tprintf(what, buf, fmt, siz, str, tim, info)
fmthist('h', info, (char *) cbuff, sizeof(cbuff)); fmthist('h', info, (char *) cbuff, sizeof(cbuff));
break; break;
case FMT_SCHED: case FMT_SCHED:
(void) xsnprintf((char *) cbuff, sizeof(cbuff), "%d", *(int *)info); (void) xsnprintf((char *) cbuff, sizeof(cbuff), "%d",
*(int *)info);
break; break;
default: default:
(void) xsnprintf((char *) cbuff, sizeof(cbuff), "%d", eventno + 1); (void) xsnprintf((char *) cbuff, sizeof(cbuff), "%d",
eventno + 1);
break; break;
} }
for (cz = cbuff; *cz; *p++ = attributes | *cz++) for (cz = cbuff; *cz; *p++ = attributes | *cz++)
@ -297,10 +302,11 @@ tprintf(what, buf, fmt, siz, str, tim, info)
case 'M': case 'M':
#ifndef HAVENOUTMP #ifndef HAVENOUTMP
if (what == FMT_WHO) if (what == FMT_WHO)
cz = who_info(info, 'M', (char *) cbuff, sizeof(cbuff)); cz = (unsigned char *) who_info(info, 'M',
(char *) cbuff, sizeof(cbuff));
else else
#endif /* HAVENOUTMP */ #endif /* HAVENOUTMP */
cz = getenv("HOST"); cz = (unsigned char *) getenv("HOST");
/* /*
* Bug pointed out by Laurent Dami <dami@cui.unige.ch>: don't * Bug pointed out by Laurent Dami <dami@cui.unige.ch>: don't
* derefrence that NULL (if HOST is not set)... * derefrence that NULL (if HOST is not set)...
@ -313,10 +319,11 @@ tprintf(what, buf, fmt, siz, str, tim, info)
case 'm': case 'm':
#ifndef HAVENOUTMP #ifndef HAVENOUTMP
if (what == FMT_WHO) if (what == FMT_WHO)
cz = who_info(info, 'm', (char *) cbuff, sizeof(cbuff)); cz = (unsigned char *) who_info(info, 'm', (char *) cbuff,
sizeof(cbuff));
else else
#endif /* HAVENOUTMP */ #endif /* HAVENOUTMP */
cz = getenv("HOST"); cz = (unsigned char *) getenv("HOST");
if (cz != NULL) if (cz != NULL)
for ( ; *cz && (what == FMT_WHO || *cz != '.') for ( ; *cz && (what == FMT_WHO || *cz != '.')
@ -429,7 +436,8 @@ tprintf(what, buf, fmt, siz, str, tim, info)
case 'n': case 'n':
#ifndef HAVENOUTMP #ifndef HAVENOUTMP
if (what == FMT_WHO) { if (what == FMT_WHO) {
cz = who_info(info, 'n', (char *) cbuff, sizeof(cbuff)); cz = (unsigned char *) who_info(info, 'n',
(char *) cbuff, sizeof(cbuff));
for (; cz && *cz ; *p++ = attributes | *cz++) for (; cz && *cz ; *p++ = attributes | *cz++)
if (p >= ep) break; if (p >= ep) break;
} }
@ -444,7 +452,8 @@ tprintf(what, buf, fmt, siz, str, tim, info)
case 'l': case 'l':
#ifndef HAVENOUTMP #ifndef HAVENOUTMP
if (what == FMT_WHO) { if (what == FMT_WHO) {
cz = who_info(info, 'l', (char *) cbuff, sizeof(cbuff)); cz = (unsigned char *) who_info(info, 'l',
(char *) cbuff, sizeof(cbuff));
for (; cz && *cz ; *p++ = attributes | *cz++) for (; cz && *cz ; *p++ = attributes | *cz++)
if (p >= ep) break; if (p >= ep) break;
} }
@ -457,7 +466,8 @@ tprintf(what, buf, fmt, siz, str, tim, info)
} }
break; break;
case 'd': case 'd':
for (cz = day_list[t->tm_wday]; *cz; *p++ = attributes | *cz++) for (cz = (unsigned char *) day_list[t->tm_wday]; *cz;
*p++ = attributes | *cz++)
if (p >= ep) break; if (p >= ep) break;
break; break;
case 'D': case 'D':
@ -466,8 +476,9 @@ tprintf(what, buf, fmt, siz, str, tim, info)
break; break;
case 'w': case 'w':
if (p >= ep - 5) break; if (p >= ep - 5) break;
for (cz = month_list[t->tm_mon]; *cz;) for (cz = (unsigned char *) month_list[t->tm_mon]; *cz;
*p++ = attributes | *cz++; *p++ = attributes | *cz++);
if (p >= ep) break;
break; break;
case 'W': case 'W':
if (p >= ep - 3) break; if (p >= ep - 3) break;