1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

toupper(), tolower(), isspace(), is..etc..() aren't safe with chars in some

systems, use our own is_...() functions now instead.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2348 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2002-01-27 20:45:59 +00:00 committed by cras
parent 820c9d3d82
commit f4897860b5
35 changed files with 112 additions and 95 deletions

View File

@ -72,6 +72,23 @@ const char *get_irssi_config(void);
if (a) { g_free(a); (a) = NULL; } \ if (a) { g_free(a); (a) = NULL; } \
} G_STMT_END } G_STMT_END
/* ctype.h isn't safe with chars, use our own instead */
#define i_toupper(x) toupper((int) (unsigned char) (x))
#define i_tolower(x) tolower((int) (unsigned char) (x))
#define i_isalnum(x) isalnum((int) (unsigned char) (x))
#define i_isalpha(x) isalpha((int) (unsigned char) (x))
#define i_isascii(x) isascii((int) (unsigned char) (x))
#define i_isblank(x) isblank((int) (unsigned char) (x))
#define i_iscntrl(x) iscntrl((int) (unsigned char) (x))
#define i_isdigit(x) isdigit((int) (unsigned char) (x))
#define i_isgraph(x) isgraph((int) (unsigned char) (x))
#define i_islower(x) islower((int) (unsigned char) (x))
#define i_isprint(x) isprint((int) (unsigned char) (x))
#define i_ispunct(x) ispunct((int) (unsigned char) (x))
#define i_isspace(x) isspace((int) (unsigned char) (x))
#define i_isupper(x) isupper((int) (unsigned char) (x))
#define i_isxdigit(x) isxdigit((int) (unsigned char) (x))
typedef struct _IPADDR IPADDR; typedef struct _IPADDR IPADDR;
typedef struct _CONFIG_REC CONFIG_REC; typedef struct _CONFIG_REC CONFIG_REC;
typedef struct _CONFIG_NODE CONFIG_NODE; typedef struct _CONFIG_NODE CONFIG_NODE;

View File

@ -557,15 +557,15 @@ static int get_cmd_options(char **data, int ignore_unknown,
} }
(*data)++; (*data)++;
if (**data == '-' && isspace((*data)[1])) { if (**data == '-' && i_isspace((*data)[1])) {
/* -- option means end of options even /* -- option means end of options even
if next word starts with - */ if next word starts with - */
(*data)++; (*data)++;
while (isspace(**data)) (*data)++; while (i_isspace(**data)) (*data)++;
break; break;
} }
if (!isspace(**data)) { if (!i_isspace(**data)) {
option = cmd_get_param(data); option = cmd_get_param(data);
} else { } else {
option = "-"; option = "-";
@ -610,14 +610,14 @@ static int get_cmd_options(char **data, int ignore_unknown,
*optlist[pos] == '!') *optlist[pos] == '!')
option = NULL; option = NULL;
while (isspace(**data)) (*data)++; while (i_isspace(**data)) (*data)++;
continue; continue;
} }
if (option == NULL) if (option == NULL)
break; break;
if (*optlist[pos] == '@' && !isdigit(**data)) if (*optlist[pos] == '@' && !i_isdigit(**data))
break; /* expected a numeric argument */ break; /* expected a numeric argument */
/* save the argument */ /* save the argument */
@ -628,7 +628,7 @@ static int get_cmd_options(char **data, int ignore_unknown,
} }
option = NULL; option = NULL;
while (isspace(**data)) (*data)++; while (i_isspace(**data)) (*data)++;
} }
return 0; return 0;

View File

@ -126,7 +126,7 @@ int find_substr(const char *list, const char *item)
return FALSE; return FALSE;
for (;;) { for (;;) {
while (isspace((gint) *list)) list++; while (i_isspace(*list)) list++;
if (*list == '\0') break; if (*list == '\0') break;
ptr = strchr(list, ' '); ptr = strchr(list, ' ');
@ -324,7 +324,7 @@ char *stristr(const char *data, const char *key)
if (key[pos] == '\0') if (key[pos] == '\0')
return (char *) data; return (char *) data;
if (toupper(data[pos]) == toupper(key[pos])) if (i_toupper(data[pos]) == i_toupper(key[pos]))
pos++; pos++;
else { else {
data++; data++;
@ -337,7 +337,7 @@ char *stristr(const char *data, const char *key)
#define isbound(c) \ #define isbound(c) \
((unsigned char) (c) < 128 && \ ((unsigned char) (c) < 128 && \
(isspace((int) (c)) || ispunct((int) (c)))) (i_isspace(c) || i_ispunct(c)))
char *strstr_full_case(const char *data, const char *key, int icase) char *strstr_full_case(const char *data, const char *key, int icase)
{ {
@ -364,7 +364,7 @@ char *strstr_full_case(const char *data, const char *key, int icase)
return (char *) data; return (char *) data;
} }
match = icase ? (toupper(data[pos]) == toupper(key[pos])) : match = icase ? (i_toupper(data[pos]) == i_toupper(key[pos])) :
data[pos] == key[pos]; data[pos] == key[pos];
if (match && (pos != 0 || data == start || isbound(data[-1]))) if (match && (pos != 0 || data == start || isbound(data[-1])))
@ -473,7 +473,7 @@ unsigned int g_istr_hash(gconstpointer v)
unsigned int h = 0, g; unsigned int h = 0, g;
while (*s != '\0') { while (*s != '\0') {
h = (h << 4) + toupper(*s); h = (h << 4) + i_toupper(*s);
if ((g = h & 0xf0000000UL)) { if ((g = h & 0xf0000000UL)) {
h = h ^ (g >> 24); h = h ^ (g >> 24);
h = h ^ g; h = h ^ g;
@ -493,7 +493,7 @@ int match_wildcards(const char *cmask, const char *data)
newmask = mask = g_strdup(cmask); newmask = mask = g_strdup(cmask);
for (; *mask != '\0' && *data != '\0'; mask++) { for (; *mask != '\0' && *data != '\0'; mask++) {
if (*mask != '*') { if (*mask != '*') {
if (*mask != '?' && toupper(*mask) != toupper(*data)) if (*mask != '?' && i_toupper(*mask) != i_toupper(*data))
break; break;
data++; data++;
@ -539,7 +539,7 @@ int is_numeric(const char *str, char end_char)
return FALSE; return FALSE;
while (*str != '\0' && *str != end_char) { while (*str != '\0' && *str != end_char) {
if (!isdigit(*str)) return FALSE; if (!i_isdigit(*str)) return FALSE;
str++; str++;
} }
@ -756,9 +756,9 @@ int expand_escape(const char **data)
case 'c': case 'c':
/* control character (\cA = ^A) */ /* control character (\cA = ^A) */
(*data)++; (*data)++;
return toupper(**data) - 64; return i_toupper(**data) - 64;
default: default:
if (!isdigit(**data)) if (!i_isdigit(**data))
return -1; return -1;
/* octal */ /* octal */

View File

@ -582,7 +582,7 @@ char *net_getservbyport(int port)
int is_ipv4_address(const char *host) int is_ipv4_address(const char *host)
{ {
while (*host != '\0') { while (*host != '\0') {
if (*host != '.' && !isdigit(*host)) if (*host != '.' && !i_isdigit(*host))
return 0; return 0;
host++; host++;
} }

View File

@ -28,7 +28,7 @@
#include "masks.h" #include "masks.h"
#define isalnumhigh(a) \ #define isalnumhigh(a) \
(isalnum(a) || (unsigned char) (a) >= 128) (i_isalnum(a) || (unsigned char) (a) >= 128)
static void nick_hash_add(CHANNEL_REC *channel, NICK_REC *nick) static void nick_hash_add(CHANNEL_REC *channel, NICK_REC *nick)
{ {
@ -532,10 +532,10 @@ int nick_match_msg(CHANNEL_REC *channel, const char *msg, const char *nick)
/* check if it matches for alphanumeric parts of nick */ /* check if it matches for alphanumeric parts of nick */
while (*nick != '\0' && *msg != '\0') { while (*nick != '\0' && *msg != '\0') {
if (toupper(*nick) == toupper(*msg)) { if (i_toupper(*nick) == i_toupper(*msg)) {
/* total match */ /* total match */
msg++; msg++;
} else if (isalnum(*msg) && !isalnum(*nick)) { } else if (i_isalnum(*msg) && !i_isalnum(*nick)) {
/* some strange char in your nick, pass it */ /* some strange char in your nick, pass it */
fullmatch = FALSE; fullmatch = FALSE;
} else } else
@ -552,7 +552,7 @@ int nick_match_msg(CHANNEL_REC *channel, const char *msg, const char *nick)
/* remove the rest of the non-alphanum chars /* remove the rest of the non-alphanum chars
from nick and check if it then matches. */ from nick and check if it then matches. */
fullmatch = FALSE; fullmatch = FALSE;
while (*nick != '\0' && !isalnum(*nick)) while (*nick != '\0' && !i_isalnum(*nick))
nick++; nick++;
} }

View File

@ -30,10 +30,10 @@
#define ALIGN_PAD 0x04 #define ALIGN_PAD 0x04
#define isvarchar(c) \ #define isvarchar(c) \
(isalnum(c) || (c) == '_') (i_isalnum(c) || (c) == '_')
#define isarg(c) \ #define isarg(c) \
(isdigit(c) || (c) == '*' || (c) == '~' || (c) == '-') (i_isdigit(c) || (c) == '*' || (c) == '~' || (c) == '-')
static SPECIAL_HISTORY_FUNC history_func = NULL; static SPECIAL_HISTORY_FUNC history_func = NULL;
@ -54,7 +54,7 @@ static char *get_argument(char **cmd, char **arglist)
/* get last argument */ /* get last argument */
arg = max = argcount-1; arg = max = argcount-1;
} else { } else {
if (isdigit(**cmd)) { if (i_isdigit(**cmd)) {
/* first argument */ /* first argument */
arg = max = (**cmd)-'0'; arg = max = (**cmd)-'0';
(*cmd)++; (*cmd)++;
@ -63,7 +63,7 @@ static char *get_argument(char **cmd, char **arglist)
if (**cmd == '-') { if (**cmd == '-') {
/* get more than one argument */ /* get more than one argument */
(*cmd)++; (*cmd)++;
if (!isdigit(**cmd)) if (!i_isdigit(**cmd))
max = -1; /* get all the rest */ max = -1; /* get all the rest */
else { else {
max = (**cmd)-'0'; max = (**cmd)-'0';
@ -163,7 +163,7 @@ static char *get_variable(char **cmd, SERVER_REC *server, void *item,
get_argument(cmd, arglist); get_argument(cmd, arglist);
} }
if (isalpha(**cmd) && isvarchar((*cmd)[1])) { if (i_isalpha(**cmd) && isvarchar((*cmd)[1])) {
/* long variable name.. */ /* long variable name.. */
return get_long_variable(cmd, server, item, free_ret, getname); return get_long_variable(cmd, server, item, free_ret, getname);
} }
@ -287,7 +287,7 @@ static int get_alignment_args(char **data, int *align, int *flags, char *pad)
/* '!' = don't cut, '-' = right padding */ /* '!' = don't cut, '-' = right padding */
str = *data; str = *data;
while (*str != '\0' && *str != ']' && !isdigit(*str)) { while (*str != '\0' && *str != ']' && !i_isdigit(*str)) {
if (*str == '!') if (*str == '!')
*flags &= ~ALIGN_CUT; *flags &= ~ALIGN_CUT;
else if (*str == '-') else if (*str == '-')
@ -296,11 +296,11 @@ static int get_alignment_args(char **data, int *align, int *flags, char *pad)
*flags &= ~ALIGN_PAD; *flags &= ~ALIGN_PAD;
str++; str++;
} }
if (!isdigit(*str)) if (!i_isdigit(*str))
return FALSE; /* expecting number */ return FALSE; /* expecting number */
/* get the alignment size */ /* get the alignment size */
while (isdigit(*str)) { while (i_isdigit(*str)) {
*align = (*align) * 10 + (*str-'0'); *align = (*align) * 10 + (*str-'0');
str++; str++;
} }

View File

@ -393,7 +393,7 @@ static GList *completion_nicks_nonstrict(CHANNEL_REC *channel,
/* remove non alnum chars from nick */ /* remove non alnum chars from nick */
in = rec->nick; out = str; in = rec->nick; out = str;
while (*in != '\0') { while (*in != '\0') {
if (isalnum(*in)) if (i_isalnum(*in))
*out++ = *in; *out++ = *in;
in++; in++;
} }

View File

@ -41,7 +41,7 @@ static int last_want_space, last_line_pos;
((c) == ',') ((c) == ',')
#define isseparator(c) \ #define isseparator(c) \
(isspace((int) (c)) || isseparator_notspace(c)) (i_isspace(c) || isseparator_notspace(c))
void chat_completion_init(void); void chat_completion_init(void);
void chat_completion_deinit(void); void chat_completion_deinit(void);
@ -489,7 +489,7 @@ static char *line_get_command(const char *line, char **args, int aliases)
} else { } else {
checkcmd = g_strndup(line, (int) (ptr-line)); checkcmd = g_strndup(line, (int) (ptr-line));
while (isspace(*ptr)) ptr++; while (i_isspace(*ptr)) ptr++;
cmdargs = ptr; cmdargs = ptr;
} }

View File

@ -37,7 +37,7 @@
#include "hilight-text.h" #include "hilight-text.h"
#include "printtext.h" #include "printtext.h"
#define ishighalnum(c) ((unsigned char) (c) >= 128 || isalnum(c)) #define ishighalnum(c) ((unsigned char) (c) >= 128 || i_isalnum(c))
static GHashTable *printnicks; static GHashTable *printnicks;
@ -67,7 +67,7 @@ char *expand_emphasis(WI_ITEM_REC *item, const char *text)
/* check that the beginning marker starts a word, and /* check that the beginning marker starts a word, and
that the matching end marker ends a word */ that the matching end marker ends a word */
if ((pos > 0 && !isspace(bgn[-1])) || !ishighalnum(bgn[1])) if ((pos > 0 && !i_isspace(bgn[-1])) || !ishighalnum(bgn[1]))
continue; continue;
if ((end = strchr(bgn+1, *bgn)) == NULL) if ((end = strchr(bgn+1, *bgn)) == NULL)
continue; continue;

View File

@ -266,7 +266,7 @@ static void settings_save_fe(const char *fname)
static void settings_save_confirm(const char *line, char *fname) static void settings_save_confirm(const char *line, char *fname)
{ {
if (toupper(line[0]) == 'Y') if (i_toupper(line[0]) == 'Y')
settings_save_fe(fname); settings_save_fe(fname);
g_free(fname); g_free(fname);
} }
@ -304,7 +304,7 @@ static void cmd_save(const char *data)
static void settings_clean_confirm(const char *line) static void settings_clean_confirm(const char *line)
{ {
if (toupper(line[0]) == 'Y') if (i_toupper(line[0]) == 'Y')
settings_clean_invalid(); settings_clean_invalid();
} }

View File

@ -699,7 +699,7 @@ static const char *get_ansi_color(THEME_REC *theme, const char *str,
for (;; str++) { for (;; str++) {
if (*str == '\0') return start; if (*str == '\0') return start;
if (isdigit((int) *str)) { if (i_isdigit(*str)) {
num = num*10 + (*str-'0'); num = num*10 + (*str-'0');
continue; continue;
} }
@ -758,7 +758,7 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
fg = fg_ret == NULL ? -1 : *fg_ret; fg = fg_ret == NULL ? -1 : *fg_ret;
bg = bg_ret == NULL ? -1 : *bg_ret; bg = bg_ret == NULL ? -1 : *bg_ret;
if (!isdigit((int) **str) && **str != ',') { if (!i_isdigit(**str) && **str != ',') {
fg = -1; fg = -1;
bg = -1; bg = -1;
} else { } else {
@ -766,7 +766,7 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
if (**str != ',') { if (**str != ',') {
fg = **str-'0'; fg = **str-'0';
(*str)++; (*str)++;
if (isdigit((int) **str)) { if (i_isdigit(**str)) {
fg = fg*10 + (**str-'0'); fg = fg*10 + (**str-'0');
(*str)++; (*str)++;
} }
@ -774,12 +774,12 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
if (**str == ',') { if (**str == ',') {
/* background color */ /* background color */
(*str)++; (*str)++;
if (!isdigit((int) **str)) if (!i_isdigit(**str))
bg = -1; bg = -1;
else { else {
bg = **str-'0'; bg = **str-'0';
(*str)++; (*str)++;
if (isdigit((int) **str)) { if (i_isdigit(**str)) {
bg = bg*10 + (**str-'0'); bg = bg*10 + (**str-'0');
(*str)++; (*str)++;
} }

View File

@ -265,7 +265,7 @@ static int expand_key(const char *key, GSList **out)
start = NULL; last_hyphen = TRUE; start = NULL; last_hyphen = TRUE;
for (; *key != '\0'; key++) { for (; *key != '\0'; key++) {
if (start != NULL) { if (start != NULL) {
if (isalnum(*key) || *key == '_') { if (i_isalnum(*key) || *key == '_') {
/* key combo continues */ /* key combo continues */
continue; continue;
} }
@ -291,7 +291,7 @@ static int expand_key(const char *key, GSList **out)
expand_out_char(*out, *key); expand_out_char(*out, *key);
expand_out_char(*out, '-'); expand_out_char(*out, '-');
last_hyphen = FALSE; /* optional */ last_hyphen = FALSE; /* optional */
} else if (last_hyphen && isalnum(*key) && !isdigit(*key)) { } else if (last_hyphen && i_isalnum(*key) && !i_isdigit(*key)) {
/* possibly beginning of keycombo */ /* possibly beginning of keycombo */
start = key; start = key;
last_hyphen = FALSE; last_hyphen = FALSE;

View File

@ -332,7 +332,7 @@ static char *theme_format_expand_abstract(THEME_REC *theme,
NULL, NULL, flags); NULL, NULL, flags);
len = strlen(data); len = strlen(data);
if (len > 1 && isdigit(data[len-1]) && data[len-2] == '$') { if (len > 1 && i_isdigit(data[len-1]) && data[len-2] == '$') {
/* ends with $<digit> .. this breaks things if next /* ends with $<digit> .. this breaks things if next
character is digit or '-' */ character is digit or '-' */
char digit, *tmp; char digit, *tmp;

View File

@ -50,7 +50,7 @@ void translate_output(char *text)
} }
#define gethex(a) \ #define gethex(a) \
(isdigit(a) ? ((a)-'0') : (toupper(a)-'A'+10)) (i_isdigit(a) ? ((a)-'0') : (i_toupper(a)-'A'+10))
void translation_parse_line(const char *str, int *pos) void translation_parse_line(const char *str, int *pos)
{ {

View File

@ -397,7 +397,7 @@ static void event_received(IRC_SERVER_REC *server, const char *data,
g_return_if_fail(data != NULL); g_return_if_fail(data != NULL);
if (!isdigit((gint) *data)) { if (!i_isdigit(*data)) {
printtext(server, NULL, MSGLEVEL_CRAP, "%s", data); printtext(server, NULL, MSGLEVEL_CRAP, "%s", data);
return; return;
} }

View File

@ -293,9 +293,9 @@ void gui_entry_erase_word(GUI_ENTRY_REC *entry, int to_space)
while (entry->text->str[to] != ' ' && to > 0) while (entry->text->str[to] != ' ' && to > 0)
to--; to--;
} else { } else {
while (!isalnum(entry->text->str[to]) && to > 0) while (!i_isalnum(entry->text->str[to]) && to > 0)
to--; to--;
while (isalnum(entry->text->str[to]) && to > 0) while (i_isalnum(entry->text->str[to]) && to > 0)
to--; to--;
} }
if (to > 0) to++; if (to > 0) to++;
@ -323,9 +323,9 @@ void gui_entry_erase_next_word(GUI_ENTRY_REC *entry, int to_space)
while (entry->text->str[to] != ' ' && to < entry->text->len) while (entry->text->str[to] != ' ' && to < entry->text->len)
to++; to++;
} else { } else {
while (!isalnum(entry->text->str[to]) && to < entry->text->len) while (!i_isalnum(entry->text->str[to]) && to < entry->text->len)
to++; to++;
while (isalnum(entry->text->str[to]) && to < entry->text->len) while (i_isalnum(entry->text->str[to]) && to < entry->text->len)
to++; to++;
} }
@ -386,9 +386,9 @@ static void gui_entry_move_words_left(GUI_ENTRY_REC *entry, int count, int to_sp
while (pos > 0 && entry->text->str[pos-1] != ' ') while (pos > 0 && entry->text->str[pos-1] != ' ')
pos--; pos--;
} else { } else {
while (pos > 0 && !isalnum(entry->text->str[pos-1])) while (pos > 0 && !i_isalnum(entry->text->str[pos-1]))
pos--; pos--;
while (pos > 0 && isalnum(entry->text->str[pos-1])) while (pos > 0 && i_isalnum(entry->text->str[pos-1]))
pos--; pos--;
} }
count--; count--;
@ -409,9 +409,9 @@ static void gui_entry_move_words_right(GUI_ENTRY_REC *entry, int count, int to_s
while (pos < entry->text->len && entry->text->str[pos] != ' ') while (pos < entry->text->len && entry->text->str[pos] != ' ')
pos++; pos++;
} else { } else {
while (pos < entry->text->len && !isalnum(entry->text->str[pos])) while (pos < entry->text->len && !i_isalnum(entry->text->str[pos]))
pos++; pos++;
while (pos < entry->text->len && isalnum(entry->text->str[pos])) while (pos < entry->text->len && i_isalnum(entry->text->str[pos]))
pos++; pos++;
} }
count--; count--;

View File

@ -265,7 +265,7 @@ static void check_oldcrap(void)
str[0] = '\0'; str[0] = '\0';
fgets(str, sizeof(str), stdin); fgets(str, sizeof(str), stdin);
if (toupper(str[0]) == 'Y' || str[0] == '\n' || str[0] == '\0') if (i_toupper(str[0]) == 'Y' || str[0] == '\n' || str[0] == '\0')
remove(path); remove(path);
g_free(path); g_free(path);
} }

View File

@ -964,7 +964,7 @@ static void cmd_window_stick(const char *data)
while (*data == ' ') data++; while (*data == ' ') data++;
} }
if (g_strncasecmp(data, "OF", 2) == 0 || toupper(*data) == 'N') { if (g_strncasecmp(data, "OF", 2) == 0 || i_toupper(*data) == 'N') {
/* unset sticky */ /* unset sticky */
if (!WINDOW_GUI(win)->sticky) { if (!WINDOW_GUI(win)->sticky) {
printformat_window(win, MSGLEVEL_CLIENTERROR, printformat_window(win, MSGLEVEL_CLIENTERROR,

View File

@ -568,7 +568,7 @@ char *tparm(const char *str, ...) {
return OOPS; return OOPS;
i = 0; i = 0;
sp++; sp++;
while(isdigit(*sp)) while(i_isdigit(*sp))
i = 10 * i + *sp++ - '0'; i = 10 * i + *sp++ - '0';
if (*sp++ != '}' || pushnum(i)) if (*sp++ != '}' || pushnum(i))
return OOPS; return OOPS;

View File

@ -342,7 +342,7 @@ static void botnet_connect_event_uplink(BOT_REC *bot, const char *data)
/* nick already in use, change it by adding a number /* nick already in use, change it by adding a number
at the end of it */ at the end of it */
p = botnet->nick+strlen(botnet->nick); p = botnet->nick+strlen(botnet->nick);
while (p > botnet->nick && isdigit(p[-1])) p--; while (p > botnet->nick && i_isdigit(p[-1])) p--;
num = *p == '\0' ? 2 : atoi(p)+1; *p = '\0'; num = *p == '\0' ? 2 : atoi(p)+1; *p = '\0';
str = g_strdup_printf("%s%d", botnet->nick, num); str = g_strdup_printf("%s%d", botnet->nick, num);
g_free(botnet->nick); botnet->nick = str; g_free(botnet->nick); botnet->nick = str;

View File

@ -266,7 +266,7 @@ GNode *bot_find_path(BOTNET_REC *botnet, const char *nick)
static int is_ip_mask(const char *addr) static int is_ip_mask(const char *addr)
{ {
while (*addr != '\0') { while (*addr != '\0') {
if (!isdigit(*addr) && *addr != '.' && if (!i_isdigit(*addr) && *addr != '.' &&
*addr != '*' && *addr != '?') return FALSE; *addr != '*' && *addr != '?') return FALSE;
addr++; addr++;
} }

View File

@ -208,13 +208,13 @@ static int parse_custom_ban(const char *type)
ban_type = 0; ban_type = 0;
list = g_strsplit(type, " ", -1); list = g_strsplit(type, " ", -1);
for (n = 0; list[n] != NULL; n++) { for (n = 0; list[n] != NULL; n++) {
if (toupper(list[n][0]) == 'N') if (i_toupper(list[n][0]) == 'N')
ban_type |= IRC_MASK_NICK; ban_type |= IRC_MASK_NICK;
else if (toupper(list[n][0]) == 'U') else if (i_toupper(list[n][0]) == 'U')
ban_type |= IRC_MASK_USER; ban_type |= IRC_MASK_USER;
else if (toupper(list[n][0]) == 'H') else if (i_toupper(list[n][0]) == 'H')
ban_type |= IRC_MASK_HOST | IRC_MASK_DOMAIN; ban_type |= IRC_MASK_HOST | IRC_MASK_DOMAIN;
else if (toupper(list[n][0]) == 'D') else if (i_toupper(list[n][0]) == 'D')
ban_type |= IRC_MASK_DOMAIN; ban_type |= IRC_MASK_DOMAIN;
} }
g_strfreev(list); g_strfreev(list);
@ -228,15 +228,15 @@ static int parse_ban_type(const char *type)
g_return_val_if_fail(type != NULL, 0); g_return_val_if_fail(type != NULL, 0);
if (toupper(type[0]) == 'N') if (i_toupper(type[0]) == 'N')
return BAN_TYPE_NORMAL; return BAN_TYPE_NORMAL;
if (toupper(type[0]) == 'U') if (i_toupper(type[0]) == 'U')
return BAN_TYPE_USER; return BAN_TYPE_USER;
if (toupper(type[0]) == 'H') if (i_toupper(type[0]) == 'H')
return BAN_TYPE_HOST; return BAN_TYPE_HOST;
if (toupper(type[0]) == 'D') if (i_toupper(type[0]) == 'D')
return BAN_TYPE_DOMAIN; return BAN_TYPE_DOMAIN;
if (toupper(type[0]) == 'C') { if (i_toupper(type[0]) == 'C') {
pos = strchr(type, ' '); pos = strchr(type, ' ');
if (pos != NULL) if (pos != NULL)
return parse_custom_ban(pos+1); return parse_custom_ban(pos+1);

View File

@ -41,7 +41,7 @@ static char *get_domain_mask(char *host)
if (is_ipv4_address(host)) { if (is_ipv4_address(host)) {
/* it's an IP address, change last digit to * */ /* it's an IP address, change last digit to * */
ptr = strrchr(host, '.'); ptr = strrchr(host, '.');
if (ptr != NULL && isdigit(ptr[1])) if (ptr != NULL && i_isdigit(ptr[1]))
strcpy(ptr+1, "*"); strcpy(ptr+1, "*");
} else { } else {
/* if more than one dot, skip the first /* if more than one dot, skip the first

View File

@ -51,7 +51,7 @@ NICK_REC *irc_nicklist_insert(IRC_CHANNEL_REC *channel, const char *nick,
} }
#define isnickchar(a) \ #define isnickchar(a) \
(isalnum((int) (a)) || (a) == '`' || (a) == '-' || (a) == '_' || \ (i_isalnum(a) || (a) == '`' || (a) == '-' || (a) == '_' || \
(a) == '[' || (a) == ']' || (a) == '{' || (a) == '}' || \ (a) == '[' || (a) == ']' || (a) == '{' || (a) == '}' || \
(a) == '|' || (a) == '\\' || (a) == '^') (a) == '|' || (a) == '\\' || (a) == '^')
@ -64,7 +64,7 @@ char *irc_nick_strip(const char *nick)
spos = stripped = g_strdup(nick); spos = stripped = g_strdup(nick);
while (isnickchar(*nick)) { while (isnickchar(*nick)) {
if (isalnum((int) *nick)) if (i_isalnum(*nick))
*spos++ = *nick; *spos++ = *nick;
nick++; nick++;
} }

View File

@ -152,19 +152,19 @@ static char *split_nicks(const char *cmd, char **pre, char **nicks, char **post,
*pre = g_strdup(cmd); *pre = g_strdup(cmd);
*post = *nicks = NULL; *post = *nicks = NULL;
for (p = *pre; *p != '\0'; p++) { for (p = *pre; *p != '\0'; p++) {
if (!isspace(*p)) if (!i_isspace(*p))
continue; continue;
if (arg == 1) { if (arg == 1) {
/* text after nicks */ /* text after nicks */
*p++ = '\0'; *p++ = '\0';
while (isspace(*p)) p++; while (i_isspace(*p)) p++;
*post = p; *post = p;
break; break;
} }
/* find nicks */ /* find nicks */
while (isspace(p[1])) p++; while (i_isspace(p[1])) p++;
if (--arg == 1) { if (--arg == 1) {
*p = '\0'; *p = '\0';
*nicks = p+1; *nicks = p+1;

View File

@ -282,7 +282,7 @@ int quitmsg_is_split(const char *msg)
/* top-domain1 must be 2+ chars long and contain only alphabets */ /* top-domain1 must be 2+ chars long and contain only alphabets */
p = host2-1; p = host2-1;
while (p[-1] != '.') { while (p[-1] != '.') {
if (!isalpha(p[-1])) if (!i_isalpha(p[-1]))
return FALSE; return FALSE;
p--; p--;
} }
@ -291,7 +291,7 @@ int quitmsg_is_split(const char *msg)
/* top-domain2 must be 2+ chars long and contain only alphabets */ /* top-domain2 must be 2+ chars long and contain only alphabets */
p = host2+strlen(host2); p = host2+strlen(host2);
while (p[-1] != '.') { while (p[-1] != '.') {
if (!isalpha(p[-1])) if (!i_isalpha(p[-1]))
return FALSE; return FALSE;
p--; p--;
} }

View File

@ -311,7 +311,7 @@ static int redirect_args_match(const char *event_args,
start = event_args; start = event_args;
while (*arg != '\0') { while (*arg != '\0') {
while (*arg != '\0' && *arg != ' ' && *event_args != '\0') { while (*arg != '\0' && *arg != ' ' && *event_args != '\0') {
if (toupper(*arg) != toupper(*event_args)) if (i_toupper(*arg) != i_toupper(*event_args))
break; break;
arg++; event_args++; arg++; event_args++;
} }
@ -505,7 +505,7 @@ server_redirect_get(IRC_SERVER_REC *server, const char *event,
if (signal == NULL) { if (signal == NULL) {
/* unknown event - redirect to the default signal. */ /* unknown event - redirect to the default signal. */
if (strncmp(event, "event ", 6) == 0 && if (strncmp(event, "event ", 6) == 0 &&
isdigit(event[6])) { i_isdigit(event[6])) {
signal = (*redirect)->default_signal; signal = (*redirect)->default_signal;
if (*match == MATCH_NONE) if (*match == MATCH_NONE)
*match = MATCH_START; *match = MATCH_START;

View File

@ -456,7 +456,7 @@ static void cmd_mircdcc(const char *data, SERVER_REC *server,
dcc = item_get_dcc((WI_ITEM_REC *) item); dcc = item_get_dcc((WI_ITEM_REC *) item);
if (dcc == NULL) return; if (dcc == NULL) return;
dcc->mirc_ctcp = toupper(*data) != 'N' && dcc->mirc_ctcp = i_toupper(*data) != 'N' &&
g_strncasecmp(data, "OF", 2) != 0; g_strncasecmp(data, "OF", 2) != 0;
} }

View File

@ -153,7 +153,7 @@ int config_get_bool(CONFIG_REC *rec, const char *section, const char *key, int d
str = config_get_str(rec, section, key, NULL); str = config_get_str(rec, section, key, NULL);
if (str == NULL) return def; if (str == NULL) return def;
return toupper(*str) == 'T' || toupper(*str) == 'Y'; return i_toupper(*str) == 'T' || i_toupper(*str) == 'Y';
} }
/* Return value of key `value_key' from list item where `key' is `value' */ /* Return value of key `value_key' from list item where `key' is `value' */
@ -224,8 +224,8 @@ int config_node_get_bool(CONFIG_NODE *parent, const char *key, int def)
str = config_node_get_str(parent, key, NULL); str = config_node_get_str(parent, key, NULL);
if (str == NULL) return def; if (str == NULL) return def;
return toupper(*str) == 'T' || toupper(*str) == 'Y' || return i_toupper(*str) == 'T' || i_toupper(*str) == 'Y' ||
(toupper(*str) == 'O' && toupper(str[1]) == 'N'); (i_toupper(*str) == 'O' && i_toupper(str[1]) == 'N');
} }
/* Get the value of keys `key' and `key_value' and put them to /* Get the value of keys `key' and `key_value' and put them to

View File

@ -32,7 +32,7 @@ static unsigned int g_istr_hash(gconstpointer v)
unsigned int h = 0, g; unsigned int h = 0, g;
while (*s != '\0') { while (*s != '\0') {
h = (h << 4) + toupper(*s); h = (h << 4) + i_toupper(*s);
if ((g = h & 0xf0000000UL)) { if ((g = h & 0xf0000000UL)) {
h = h ^ (g >> 24); h = h ^ (g >> 24);
h = h ^ g; h = h ^ g;

View File

@ -77,7 +77,7 @@ static int config_has_specials(const char *text)
g_return_val_if_fail(text != NULL, FALSE); g_return_val_if_fail(text != NULL, FALSE);
while (*text != '\0') { while (*text != '\0') {
if (!isalnum((int) *text) && *text != '_') if (!i_isalnum(*text) && *text != '_')
return TRUE; return TRUE;
text++; text++;
} }

View File

@ -17,19 +17,19 @@ static void configLine(poptContext con, char * line) {
if (strncmp(line, con->appName, nameLength)) return; if (strncmp(line, con->appName, nameLength)) return;
line += nameLength; line += nameLength;
if (!*line || !isspace(*line)) return; if (!*line || !i_isspace(*line)) return;
while (*line && isspace(*line)) line++; while (*line && i_isspace(*line)) line++;
entryType = line; entryType = line;
while (!*line || !isspace(*line)) line++; while (!*line || !i_isspace(*line)) line++;
*line++ = '\0'; *line++ = '\0';
while (*line && isspace(*line)) line++; while (*line && i_isspace(*line)) line++;
if (!*line) return; if (!*line) return;
opt = line; opt = line;
while (!*line || !isspace(*line)) line++; while (!*line || !i_isspace(*line)) line++;
*line++ = '\0'; *line++ = '\0';
while (*line && isspace(*line)) line++; while (*line && i_isspace(*line)) line++;
if (!*line) return; if (!*line) return;
if (opt[0] == '-' && opt[1] == '-') if (opt[0] == '-' && opt[1] == '-')
@ -92,7 +92,7 @@ int poptReadConfigFile(poptContext con, char * fn) {
case '\n': case '\n':
*dst = '\0'; *dst = '\0';
dst = buf; dst = buf;
while (*dst && isspace(*dst)) dst++; while (*dst && i_isspace(*dst)) dst++;
if (*dst && *dst != '#') { if (*dst && *dst != '#') {
configLine(con, dst); configLine(con, dst);
} }

View File

@ -94,15 +94,15 @@ static void singleOptionHelp(FILE * f, int maxLeftCol,
helpLength = strlen(help); helpLength = strlen(help);
while (helpLength > lineLength) { while (helpLength > lineLength) {
ch = help + lineLength - 1; ch = help + lineLength - 1;
while (ch > help && !isspace(*ch)) ch--; while (ch > help && !i_isspace(*ch)) ch--;
if (ch == help) break; /* give up */ if (ch == help) break; /* give up */
while (ch > (help + 1) && isspace(*ch)) ch--; while (ch > (help + 1) && i_isspace(*ch)) ch--;
ch++; ch++;
sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength); sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
fprintf(f, format, help, " "); fprintf(f, format, help, " ");
help = ch; help = ch;
while (isspace(*help) && *help) help++; while (i_isspace(*help) && *help) help++;
helpLength = strlen(help); helpLength = strlen(help);
} }

View File

@ -45,7 +45,7 @@ int poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) {
if (*src != quote) *buf++ = '\\'; if (*src != quote) *buf++ = '\\';
} }
*buf++ = *src; *buf++ = *src;
} else if (isspace(*src)) { } else if (isspace((int) (unsigned char) *src)) {
if (*argv[argc]) { if (*argv[argc]) {
buf++, argc++; buf++, argc++;
if (argc == argvAlloced) { if (argc == argvAlloced) {

View File

@ -178,7 +178,7 @@ void script_fix_name(char *name)
if (p != NULL) *p = '\0'; if (p != NULL) *p = '\0';
while (*name != '\0') { while (*name != '\0') {
if (*name != '_' && !isalnum(*name)) if (*name != '_' && !i_isalnum(*name))
*name = '_'; *name = '_';
name++; name++;
} }