Skip to content
Commits on Source (2)
......@@ -23,13 +23,12 @@ static char *colour_set=NULL;
extern struct user * const user;
/* return colour code sequence */
char *colour(char *text, int *concealed)
char *colour(char *text)
{
static char line[40];
int i;
line[0]=0;
*concealed = 0;
/* system colour chart */
if (strchr("0123456789",text[0]))
......@@ -59,19 +58,6 @@ char *colour(char *text, int *concealed)
return(line);
}
#ifdef CHILDISH
/* hidden text ? */
if (strchr("Hh", text[0]) &&
strchr("Hh", text[1]) )
{
/* return 'normal' colour code, and set 'concealed' */
line[i++]='m';
line[i]=0;
*concealed = 1;
return(line);
}
#endif
/* high intensity mode? */
if (isupper(text[0]))
{
......
......@@ -7,7 +7,7 @@ void init_colour(void);
void destroy_colours(void);
void colour_load(char *file, int quiet);
void colour_free(void);
char *colour(char *text, int *concealed);
char *colour(char *text);
char *get_colour(void);
#endif /* COLOUR_H */
......@@ -1063,9 +1063,6 @@ void format_message(const char *format, ...)
void display_message(const char *text, int beeps, int newline)
{
static int count = 0;
int len;
int ptr;
int concealed = 0;
char line[MAXTEXTLENGTH];
int i, j, colrstart;
int hascolour;
......@@ -1073,73 +1070,56 @@ void display_message(const char *text, int beeps, int newline)
char *colr = NULL;
int endline;
int convert_warnings=0;
size_t not_in_local=0;
const unsigned char *ptr = (const unsigned char *)text;
const unsigned char *end;
size_t not_in_local = 0;
size_t len;
if (text==NULL || strlen(text)==0)
{
sprintf(line,_("Error: Urk, no message to print.\n"));
write(1,line,strlen(line));
if (text == NULL || (len = strlen(text)) == 0) {
printf("%s", _("Error: Urk, no message to print.\n"));
return;
}
if (UseRL && disable_rl(1)) count = 0;
len=strlen(text);
ptr=0;
i=0;
hascolour=0;
colrstart=-1;
end = ptr + len;
while (len-ptr > 0)
{
if (text[ptr]==033)
{
while (ptr < end) {
if (*ptr == 033) {
char str[3];
ptr++;
if(len-ptr>0)
{
if( ((unsigned char)text[ptr] & 192) == 192 )
{
if (ptr < end) {
if ((*ptr & 192) == 192) {
ptr++;
str[0]='-';
while( ((unsigned char)text[ptr] & 192) == 128 && len-ptr > 0)
{
str[0] = '-';
while ((*ptr & 192) == 128 && ptr < end)
ptr++;
}
}
else
{
str[0]=text[ptr];
} else {
str[0] = *ptr;
ptr++;
}
}
if(len-ptr>0)
{
if(((unsigned char)text[ptr] & 192)==192 )
{
if (ptr < end) {
if((*ptr & 192) == 192) {
ptr++;
str[1]='-';
while( ((unsigned char)text[ptr] & 192) == 128 && len-ptr > 0)
{
str[1] = '-';
while((*ptr & 192) == 128 && ptr < end)
ptr++;
}
}
else
{
str[1]=text[ptr];
} else {
str[1] = *ptr;
ptr++;
}
}
/* escape sequence, skip next two chars */
if (s_colouroff(user))
{
goto eolprint;
}
hascolour++;
str[2]=0;
colr=colour(str, &concealed);
hascolour++;
str[2] = 0;
colr = colour(str);
if (colr!=NULL)
{
......@@ -1148,52 +1128,26 @@ void display_message(const char *text, int beeps, int newline)
else
colrstart = i;
for (j=0;j<strlen(colr);j++)
line[i++]=colr[j];
}
}else
if (text[ptr]>=040 && text[ptr]<=0176)
{
if (concealed)
{
ptr++;
for (j = 0; j < strlen(colr); j++)
line[i++] = colr[j];
}
else
{
line[i++]=text[ptr++];
count++;
} else if (*ptr >= 040 && *ptr <= 0176) {
line[i++] = *ptr;
count++;
colrstart = -1;
ptr++;
} else if ((*ptr & 192) == 192) {
line[i++] = *ptr;
count++;
colrstart = -1;
ptr++;
// stops us randomly splitting over a unicode multibyte character
while ((*ptr & 192) == 128 && ptr < end) {
line[i++] = *ptr;
colrstart = -1;
}
}else
if ( (text[ptr] & 192) == 192 )
{
if (concealed)
{
ptr++;
}
else
{
line[i++]=text[ptr++];
count++;
colrstart = -1;
}
// stops us randomly spliting over a unicode multibyte character
while( ((unsigned char)text[ptr] & 192) == 128 && len-ptr > 0 )
{
if (concealed)
{
ptr++;
}
else
{
line[i++]=text[ptr++];
colrstart = -1;
}
}
}
else
{
} else {
ptr++;
}
if (i >= (MAXTEXTLENGTH-20))
......@@ -1204,9 +1158,9 @@ void display_message(const char *text, int beeps, int newline)
}
eolprint:
if (s_nolinewrap(user))
endline = (ptr >= len);
endline = (ptr >= end);
else
endline = ((count >= screen_width) || (ptr >= len));
endline = ((count >= screen_width) || (ptr >= end));
if (endline)
{
......@@ -1217,7 +1171,7 @@ eolprint:
line[i++]='m';
}
if (newline || (ptr<len))
if (newline || (ptr < end))
{
line[i++]='\n';
count=0;
......@@ -1226,7 +1180,7 @@ eolprint:
line[i]='\0';
printline_in_local(line, &convert_warnings, &not_in_local);
if (ptr>=len)
if (ptr >= end)
{
i=0;
if (newline) count=0;
......@@ -1240,8 +1194,8 @@ eolprint:
hascolour &&
colr!=NULL)
{
for (j=0;j<strlen(colr);j++)
line[i++]=colr[j];
for (j=0; j < strlen(colr); j++)
line[i++] = colr[j];
}
}
}
......