From d0b0a95330fd32945827b5bf9b512b9645b96678 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Wed, 17 Jun 2015 22:50:49 +1000 Subject: [PATCH] Convert skip_ctl_c_seq() and its callers (except strip_ansi()) from unsigned char to char This should make no functional difference, and cuts out a large number of unsigned char * / char * mismatch warnings. --- include/ircaux.h | 2 +- include/modval.h | 14 ++++---- include/screen.h | 13 ++++---- include/struct.h | 2 +- source/functions.c | 10 +++--- source/ircaux.c | 20 ++++++------ source/lastlog.c | 5 +-- source/screen.c | 79 ++++++++++++++++++++++------------------------ source/status.c | 26 +++++++-------- source/window.c | 2 +- 10 files changed, 83 insertions(+), 90 deletions(-) diff --git a/include/ircaux.h b/include/ircaux.h index 38e8bba..3e03eab 100644 --- a/include/ircaux.h +++ b/include/ircaux.h @@ -126,7 +126,7 @@ char * BX_strpcat (char *, const char *, ...); char * BX_strmpcat (char *, size_t, const char *, ...); char * chomp (char *); size_t BX_ccspan (const char *, int); -u_char *BX_strcpy_nocolorcodes (u_char *, const u_char *); +char *BX_strcpy_nocolorcodes(char *, const char *); unsigned long randm(unsigned long); unsigned long randt(unsigned long); unsigned long randd(unsigned long); diff --git a/include/modval.h b/include/modval.h index 9893e96..ec8cdd7 100644 --- a/include/modval.h +++ b/include/modval.h @@ -189,7 +189,7 @@ extern Function_ptr *global; #define ccscpan (*(size_t (*)(const char *, int))global[CCSPAN]) #define charcount (*(int (*)(const char *, char ))global[CHARCOUNT]) #define strpcat (*(char *(*)(char *, const char *, ...))global[STRPCAT]) -#define strcpy_nocolorcodes (*(u_char *(*)(u_char *, const u_char *))global[STRCPY_NOCOLORCODES]) +#define strcpy_nocolorcodes (*(char *(*)(char *, const char *))global[STRCPY_NOCOLORCODES]) #define cryptit (*(char *(*)(const char *))global[CRYPTIT]) #define stripdev (*(char *(*)(char *))global[STRIPDEV]) #define mangle_line (*(size_t (*)(char *, int, size_t))global[MANGLE_LINE]) @@ -275,13 +275,13 @@ extern Function_ptr *global; #define dcc_printf (*(int (*)(int, char *, ...))global[DCC_PRINTF]) /* screen.c */ -#define prepare_display (*(unsigned char **(*)(const unsigned char *, int , int *, int ))global[PREPARE_DISPLAY]) -#define add_to_window (*(void (*)(Window *, const unsigned char *))global[ADD_TO_WINDOW]) +#define prepare_display (*(char **(*)(const char *, int , int *, int ))global[PREPARE_DISPLAY]) +#define add_to_window (*(void (*)(Window *, const char *))global[ADD_TO_WINDOW]) #define skip_incoming_mirc (*(char *(*)(char *))global[SKIP_INCOMING_MIRC]) #define add_to_screen (*(void (*)(char *))global[ADD_TO_SCREEN]) -#define split_up_line (*(unsigned char **(*)(const unsigned char *, int ))global[SPLIT_UP_LINE]) -#define output_line (*(int (*)(const unsigned char *))global[OUTPUT_LINE]) -#define output_with_count (*(int (*)(const unsigned char *, int , int ))global[OUTPUT_WITH_COUNT]) +#define split_up_line (*(char **(*)(const char *, int ))global[SPLIT_UP_LINE]) +#define output_line (*(int (*)(const char *))global[OUTPUT_LINE]) +#define output_with_count (*(int (*)(const char *, int , int ))global[OUTPUT_WITH_COUNT]) #define scroll_window (*(void (*)(Window *))global[SCROLL_WINDOW]) /* Previous broken definitions - yet it still seemed to work? #define cursor_not_in_display(x) ((void) (global[CURSOR_IN_DISPLAY]((Screen *)x))) @@ -295,7 +295,7 @@ extern Function_ptr *global; #define kill_screen (*(void (*)(Screen *))global[KILL_SCREEN]) #define xterm_settitle (*(void (*)(void))global[XTERM_SETTITLE]) #define add_wait_prompt (*(void (*)(char *, void (*)(char *, char *), char *, int , int ))global[ADD_WAIT_PROMPT]) -#define skip_ctl_c_seq (*(const unsigned char *(*)(const unsigned char *, int *, int *, int ))global[SKIP_CTL_C_SEQ]) +#define skip_ctl_c_seq (*(char *(*)(const char *, int *, int *, int ))global[SKIP_CTL_C_SEQ]) #define strip_ansi (*(unsigned char *(*)(const unsigned char *))global[STRIP_ANSI]) #define create_new_screen ((Screen * (*)(void))global[CREATE_NEW_SCREEN]) #define create_additional_screen ((Window * (*)(void))global[CREATE_ADDITIONAL_SCREEN]) diff --git a/include/screen.h b/include/screen.h index c2acd43..48fdfe0 100644 --- a/include/screen.h +++ b/include/screen.h @@ -29,7 +29,7 @@ #define curr_scr_win current_screen->current_window void clear_window (Window *); - int BX_output_line (const unsigned char *); + int BX_output_line (const char *); Window *BX_create_additional_screen (void); void BX_scroll_window (Window *); void update_all_windows (void); @@ -44,15 +44,14 @@ RETSIGTYPE sig_refresh_screen (int); int check_screen_redirect (char *); void BX_kill_screen (Screen *); - int rite (Window *, const unsigned char *); ShrinkInfo resize_display (Window *); void redraw_window (Window *, int); void redraw_all_windows (void); void BX_add_to_screen (char *); void do_screens (fd_set *); - unsigned char **BX_split_up_line(const unsigned char *, int); + char **BX_split_up_line(const char *, int); void BX_xterm_settitle(void); - void BX_add_to_window(Window *, const unsigned char *); + void BX_add_to_window(Window *, const char *); Screen * BX_create_new_screen(void); @@ -62,9 +61,9 @@ Screen * BX_create_new_screen(void); u_char *BX_strip_ansi (const u_char *); char *normalize_color (int, int, int, int); -const u_char *BX_skip_ctl_c_seq (const u_char *, int *, int *, int); - u_char **BX_prepare_display (const u_char *, int, int *, int); - int BX_output_with_count (const unsigned char *, int, int); +char *BX_skip_ctl_c_seq(const char *, int *, int *, int); +char **BX_prepare_display(const char *, int, int *, int); +int BX_output_with_count(const char *, int, int); char *BX_skip_incoming_mirc (char *); /* Dont do any word-wrapping, just truncate each line at its place. */ diff --git a/include/struct.h b/include/struct.h index 7370066..5e73f05 100644 --- a/include/struct.h +++ b/include/struct.h @@ -697,7 +697,7 @@ typedef struct WindowStru int window_display; /* should we display to this window */ - void (*output_func) (struct WindowStru *, const unsigned char *); + void (*output_func) (struct WindowStru *, const char *); void (*status_output_func) (struct WindowStru *); struct ScreenStru *screen; diff --git a/source/functions.c b/source/functions.c index ccbe232..abf83aa 100644 --- a/source/functions.c +++ b/source/functions.c @@ -5757,7 +5757,7 @@ BUILT_IN_FUNCTION(function_count, input) */ BUILT_IN_FUNCTION(function_leftpc, word) { - u_char **prepared = NULL; + char **prepared; int lines = 1; int count; @@ -5766,7 +5766,7 @@ BUILT_IN_FUNCTION(function_leftpc, word) RETURN_EMPTY; prepared = prepare_display(word, count, &lines, PREPARE_NOWRAP); - RETURN_STR((char *)prepared[0]); + RETURN_STR(prepared[0]); } /* * $uname() @@ -6344,9 +6344,9 @@ BUILT_IN_FUNCTION(function_getflags, input) BUILT_IN_FUNCTION(function_numlines, input) { -int count = 0; -unsigned char **lines = NULL; -char *s = NULL; + int count = 0; + char **lines = NULL; + char *s = NULL; if (input && *input) { int cols; diff --git a/source/ircaux.c b/source/ircaux.c index 137df97..e95277e 100644 --- a/source/ircaux.c +++ b/source/ircaux.c @@ -2829,13 +2829,13 @@ char * BX_strmpcat (char *source, size_t siz, const char *format, ...) -u_char *BX_strcpy_nocolorcodes (u_char *dest, const u_char *source) +char *BX_strcpy_nocolorcodes(char *dest, const char *source) { - u_char *save = dest; + char *save = dest; do { - while (*source == 3) + while (*source == COLOR_CHAR) source = skip_ctl_c_seq(source, NULL, NULL, 0); *dest++ = *source; } @@ -2975,8 +2975,8 @@ size_t BX_mangle_line (char *incoming, int how, size_t how_much) { for (i = 0; incoming[i]; i++) { - if (incoming[i] == 0x1b) - incoming[i] = 0x5b; + if (incoming[i] == '\x1b') + incoming[i] = '\x5b'; } } @@ -3002,13 +3002,13 @@ size_t BX_mangle_line (char *incoming, int how, size_t how_much) { switch (*s) { - case 003: /* color codes */ + case COLOR_CHAR: /* color codes */ { - int lhs = 0, - rhs = 0; - char *end; + int lhs = 0, + rhs = 0; + char *end; - end = (char *)skip_ctl_c_seq(s, &lhs, &rhs, 0); + end = skip_ctl_c_seq(s, &lhs, &rhs, 0); if (!(stuff & STRIP_COLOR)) { while (s < end) diff --git a/source/lastlog.c b/source/lastlog.c index 2fcdd7b..0d36ff6 100644 --- a/source/lastlog.c +++ b/source/lastlog.c @@ -579,17 +579,15 @@ int logmsg(unsigned long log_type, char *from, int flag, char *format, ...) char *filename = NULL; char *expand = NULL; char *type = NULL; - unsigned char **lines = NULL; + char **lines = NULL; char msglog_buffer[BIG_BUFFER_SIZE+1]; - if (!get_string_var(MSGLOGFILE_VAR) || !get_string_var(CTOOLZ_DIR_VAR)) return 0; t = now; timestr = update_clock(GET_TIME); - if (format) { va_list ap; @@ -598,7 +596,6 @@ int logmsg(unsigned long log_type, char *from, int flag, char *format, ...) va_end(ap); } - switch (flag) { case 0: diff --git a/source/screen.c b/source/screen.c index 2381046..66316c9 100644 --- a/source/screen.c +++ b/source/screen.c @@ -74,10 +74,9 @@ Screen *screen_list = NULL; * ------- Which calls term_putchar(). * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - u_char **BX_prepare_display (const u_char *, int, int *, int); -static int add_to_display_list (Window *, const unsigned char *); +static int add_to_display_list(Window *, const char *); Display *new_display_line (Display *); - void BX_add_to_window (Window *, const unsigned char *); +static int rite (Window *, const char *); static char display_standout (int flag); static char display_bold (int flag); @@ -89,8 +88,6 @@ static char display_altcharset (int flag); static void put_color (int, int); -const u_char *BX_skip_ctl_c_seq (const u_char *start, int *lhs, int *rhs, int proper); - static void delchar(char **text, int cnum) { int i; @@ -204,7 +201,7 @@ void BX_add_to_screen(char *buffer) * function just dumps it onto the screen. This is because the scrollback * functions need to be able to figure out how to split things up too. */ -void BX_add_to_window(Window *window, const unsigned char *str) +void BX_add_to_window(Window *window, const char *str) { if (window->server >= 0 && get_server_redirect(window->server)) @@ -213,7 +210,7 @@ void BX_add_to_window(Window *window, const unsigned char *str) str, NULL, 0, 0); if (do_hook(WINDOW_LIST, "%u %s", window->refnum, str)) { - unsigned char **lines; + char **lines; int cols; add_to_log(window->log_fp, 0, str, window->mangler); @@ -284,7 +281,7 @@ void BX_add_to_window(Window *window, const unsigned char *str) } -u_char **BX_split_up_line (const unsigned char *str, int max_cols) +char **BX_split_up_line(const char *str, int max_cols) { int nl = 0; return prepare_display(str, max_cols, &nl, 0); @@ -362,15 +359,15 @@ u_char **BX_split_up_line (const unsigned char *str, int max_cols) * PRINTED Characters not buffer positions :-) */ #define SPLIT_EXTENT 40 -unsigned char **BX_prepare_display(const unsigned char *orig_str, +char **BX_prepare_display(const char *orig_str, int max_cols, int *lused, int flags) { int gchar_mode; -static int recursion = 0, + static int recursion = 0, output_size = 0; - int pos = 0, /* Current position in "buffer" */ + int pos = 0, /* Current position in "buffer" */ col = 0, /* Current column in display */ word_break = 0, /* Last end of word */ indent = 0, /* Start of second word */ @@ -386,9 +383,9 @@ static int recursion = 0, do_indent, /* Use indent or continued line? */ in_rev = 0, /* Are we in reverse mode? */ newline = 0; /* Number of newlines */ -static u_char **output = NULL; -const u_char *ptr = NULL; - u_char buffer[BIG_BUFFER_SIZE + 1], + static char **output = NULL; + const char *ptr = NULL; + char buffer[BIG_BUFFER_SIZE + 1], *cont_ptr = NULL, *cont = empty_string, c, @@ -404,12 +401,12 @@ const u_char *ptr = NULL; tab_max = get_int_var(TAB_VAR) ? get_int_var(TAB_MAX_VAR) : -1; nds_max = get_int_var(ND_SPACE_MAX_VAR); do_indent = get_int_var(INDENT_VAR); - words = (char *)get_string_var(WORD_BREAK_VAR); + words = get_string_var(WORD_BREAK_VAR); if (!words) words = ", "; - if (!(cont_ptr = (char *)get_string_var(CONTINUED_LINE_VAR))) - cont_ptr = (char *)empty_string; + if (!(cont_ptr = get_string_var(CONTINUED_LINE_VAR))) + cont_ptr = empty_string; buffer[0] = 0; @@ -525,7 +522,7 @@ const u_char *ptr = NULL; case COLOR_CHAR: { int lhs = 0, rhs = 0; - const u_char *end = skip_ctl_c_seq(ptr, &lhs, &rhs, 0); + const char *end = skip_ctl_c_seq(ptr, &lhs, &rhs, 0); while (ptr < end) buffer[pos++] = *ptr++; ptr = end - 1; @@ -608,7 +605,7 @@ const u_char *ptr = NULL; */ if ((col >= max_cols) || newline) { - unsigned char *pos_copy; + char *pos_copy; if (!word_break || (flags & PREPARE_NOWRAP)) word_break = max_cols /*pos - 1*/; @@ -655,7 +652,7 @@ const u_char *ptr = NULL; c = buffer[word_break]; buffer[word_break] = 0; - malloc_strcpy((char **)&(output[line++]), buffer); + malloc_strcpy(&(output[line++]), buffer); buffer[word_break] = c; @@ -693,7 +690,7 @@ const u_char *ptr = NULL; buffer[pos++] = ALL_OFF; buffer[pos] = 0; if (*buffer) - malloc_strcpy((char **)&(output[line++]),buffer); + malloc_strcpy(&(output[line++]),buffer); recursion--; new_free(&output[line]); @@ -707,7 +704,7 @@ const u_char *ptr = NULL; * This puts the given string into a scratch window. It ALWAYS suppresses * any further action (by returning a FAIL, so rite() is not called). */ -static int add_to_scratch_window_display_list (Window *window, const unsigned char *str) +static int add_to_scratch_window_display_list(Window *window, const char *str) { Display *my_line, *my_line_prev; int cnt; @@ -805,7 +802,7 @@ static int add_to_scratch_window_display_list (Window *window, const unsigned ch * not to be displayed, then 0 is returned. This function handles all * the hold_mode stuff. */ -static int add_to_display_list (Window *window, const unsigned char *str) +static int add_to_display_list(Window *window, const char *str) { if (window->scratch_line != -1) return add_to_scratch_window_display_list(window, str); @@ -886,7 +883,7 @@ static int add_to_display_list (Window *window, const unsigned char *str) * bold face will remain the same and the it won't interfere with anything * else (i.e. status line, input line). */ -int rite(Window *window, const unsigned char *str) +static int rite(Window *window, const char *str) { static int high = OFF; static int bold = OFF; @@ -933,9 +930,9 @@ static int altc = OFF; /* * A temporary wrapper function for backwards compatibility. */ -int BX_output_line(const unsigned char *str) +int BX_output_line(const char *str) { - output_with_count(str,1, 1); + output_with_count(str, 1, 1); return 0; } @@ -960,14 +957,14 @@ int BX_output_line(const unsigned char *str) * correct rendering of colors than to get just one more nanosecond of * display speed. */ -int BX_output_with_count(const unsigned char *str, int clreol, int output) +int BX_output_with_count(const char *str, int clreol, int output) { -const u_char *ptr = str; - int beep = 0, + const char *ptr = str; + int beep = 0, out = 0; - int val1, + int val1, val2; - char old_bold = 0, + char old_bold = 0, old_rev = 0, old_blink = 0, old_undl = 0, @@ -2038,11 +2035,11 @@ void BX_add_wait_prompt(char *prompt, void (*func)(char *, char *), char *data, * Se we have to actually slurp up only those digits that comprise a legal * ^C code. */ -const u_char *BX_skip_ctl_c_seq (const u_char *start, int *lhs, int *rhs, int proper) +char *BX_skip_ctl_c_seq(const char *start, int *lhs, int *rhs, int proper) { -const u_char *after = start; - u_char c1, c2; - int * val; + const char *after = start; + char c1, c2; + int *val; int lv1, rv1; /* @@ -2060,7 +2057,7 @@ const u_char *after = start; * If we're passed a non ^C code, dont do anything. */ if (*after != COLOR_CHAR) - return after; + return (char *)after; /* * This is a one-or-two-time-through loop. We find the maximum @@ -2076,7 +2073,7 @@ const u_char *after = start; */ after++; if (*after == 0) - return after; + return (char *)after; /* * Check for the very special case of a definite terminator. @@ -2084,13 +2081,13 @@ const u_char *after = start; * this ends the code without starting a new one */ if (after[0] == '-' && after[1] == '1') - return after + 2; + return (char *)after + 2; /* * Further checks against a lonely old naked ^C. */ - if (!isdigit(after[0]) && after[0] != ',') - return after; + if (!isdigit((unsigned char)after[0]) && after[0] != ',') + return (char *)after; /* @@ -2191,7 +2188,7 @@ const u_char *after = start; break; } - return after; + return (char *)after; } /* diff --git a/source/status.c b/source/status.c index b576997..14c30b8 100644 --- a/source/status.c +++ b/source/status.c @@ -448,9 +448,9 @@ static char *convert_format(Window *win, char *format, int k) void fix_status_buffer(Window *win, char *buffer, int in_status) { -unsigned char rhs_buffer[3*BIG_BUFFER_SIZE + 1]; -unsigned char lhs_buffer[3*BIG_BUFFER_SIZE + 1]; -unsigned char lhs_fillchar[6], + char rhs_buffer[3*BIG_BUFFER_SIZE + 1]; + char lhs_buffer[3*BIG_BUFFER_SIZE + 1]; + char lhs_fillchar[6], rhs_fillchar[6], *fillchar = lhs_fillchar, *lhp = lhs_buffer, @@ -458,7 +458,7 @@ unsigned char lhs_fillchar[6], *cp, *start_rhs = 0, *str = NULL, *ptr = NULL; -int in_rhs = 0, + int in_rhs = 0, pr_lhs = 0, pr_rhs = 0, *prc = &pr_lhs; @@ -517,7 +517,7 @@ int in_rhs = 0, */ else if (*ptr == COLOR_CHAR) { - const u_char *end = skip_ctl_c_seq(ptr, NULL, NULL, 0); + const char *end = skip_ctl_c_seq(ptr, NULL, NULL, 0); while (ptr < end) *cp++ = *ptr++; } @@ -572,7 +572,7 @@ char *stat_convert_format(Window *win, char *form) { int map, key, i, pos = 0; char *ptr = form; - unsigned char buffer[2 * BIG_BUFFER_SIZE + 1]; + char buffer[2 * BIG_BUFFER_SIZE + 1]; if (!form || !*form) return m_strdup(empty_string); @@ -662,11 +662,11 @@ void BX_build_status(Window *win, char *format, int unused) void make_status(Window *win) { - u_char buffer [BIG_BUFFER_SIZE + 1]; - u_char lhs_buffer [BIG_BUFFER_SIZE + 1]; - u_char rhs_buffer [BIG_BUFFER_SIZE + 1]; - char *func_value[MAX_FUNCTIONS+10] = {NULL}; - u_char *ptr; + char buffer[BIG_BUFFER_SIZE + 1]; + char lhs_buffer[BIG_BUFFER_SIZE + 1]; + char rhs_buffer[BIG_BUFFER_SIZE + 1]; + char *func_value[MAX_FUNCTIONS+10] = {NULL}; + char *ptr; int len = 1, status_line, @@ -678,7 +678,7 @@ void make_status(Window *win) */ for (status_line = 0 ; status_line < 1+win->double_status + win->status_lines; status_line++) { - u_char lhs_fillchar[6], + char lhs_fillchar[6], rhs_fillchar[6], *fillchar = lhs_fillchar, *lhp = lhs_buffer, @@ -785,7 +785,7 @@ void make_status(Window *win) */ else if (*ptr == COLOR_CHAR) { - const u_char *end = skip_ctl_c_seq(ptr, NULL, NULL, 0); + const char *end = skip_ctl_c_seq(ptr, NULL, NULL, 0); while (ptr < end) *cp++ = *ptr++; } diff --git a/source/window.c b/source/window.c index 79f3c0b..b88fc05 100644 --- a/source/window.c +++ b/source/window.c @@ -3144,7 +3144,7 @@ static Window *window_echo (Window *window, char **args, char *usage) else to_echo = *args, *args = NULL; - add_to_window(window, (const unsigned char *)to_echo); + add_to_window(window, to_echo); return window; }