summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-01-27 20:45:59 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-01-27 20:45:59 +0000
commitf4897860b50e2d1cc3b97a00d1f5a2e9e9c04faa (patch)
treea9d1400865e53ac8e5b68ca37b1cb9d081bd8467
parent820c9d3d8288c8d6dfb3172750bc26adea76f66c (diff)
downloadirssi-f4897860b50e2d1cc3b97a00d1f5a2e9e9c04faa.zip
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
-rw-r--r--src/common.h17
-rw-r--r--src/core/commands.c12
-rw-r--r--src/core/misc.c18
-rw-r--r--src/core/network.c2
-rw-r--r--src/core/nicklist.c8
-rw-r--r--src/core/special-vars.c16
-rw-r--r--src/fe-common/core/chat-completion.c2
-rw-r--r--src/fe-common/core/completion.c4
-rw-r--r--src/fe-common/core/fe-messages.c4
-rw-r--r--src/fe-common/core/fe-settings.c4
-rw-r--r--src/fe-common/core/formats.c10
-rw-r--r--src/fe-common/core/keyboard.c4
-rw-r--r--src/fe-common/core/themes.c2
-rw-r--r--src/fe-common/core/translation.c2
-rw-r--r--src/fe-common/irc/fe-events.c2
-rw-r--r--src/fe-text/gui-entry.c16
-rw-r--r--src/fe-text/irssi.c2
-rw-r--r--src/fe-text/mainwindows.c2
-rw-r--r--src/fe-text/tparm.c2
-rw-r--r--src/irc/bot/botnet-connection.c2
-rw-r--r--src/irc/bot/botnet.c2
-rw-r--r--src/irc/core/bans.c18
-rw-r--r--src/irc/core/irc-masks.c2
-rw-r--r--src/irc/core/irc-nicklist.c4
-rw-r--r--src/irc/core/irc.c6
-rw-r--r--src/irc/core/netsplit.c4
-rw-r--r--src/irc/core/servers-redirect.c4
-rw-r--r--src/irc/dcc/dcc-chat.c2
-rw-r--r--src/lib-config/get.c6
-rw-r--r--src/lib-config/parse.c2
-rw-r--r--src/lib-config/write.c2
-rw-r--r--src/lib-popt/poptconfig.c14
-rw-r--r--src/lib-popt/popthelp.c6
-rw-r--r--src/lib-popt/poptparse.c2
-rw-r--r--src/perl/perl-core.c2
35 files changed, 112 insertions, 95 deletions
diff --git a/src/common.h b/src/common.h
index 6f9a3cbb..4e3dd852 100644
--- a/src/common.h
+++ b/src/common.h
@@ -72,6 +72,23 @@ const char *get_irssi_config(void);
if (a) { g_free(a); (a) = NULL; } \
} 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 _CONFIG_REC CONFIG_REC;
typedef struct _CONFIG_NODE CONFIG_NODE;
diff --git a/src/core/commands.c b/src/core/commands.c
index f1119069..f066d674 100644
--- a/src/core/commands.c
+++ b/src/core/commands.c
@@ -557,15 +557,15 @@ static int get_cmd_options(char **data, int ignore_unknown,
}
(*data)++;
- if (**data == '-' && isspace((*data)[1])) {
+ if (**data == '-' && i_isspace((*data)[1])) {
/* -- option means end of options even
if next word starts with - */
(*data)++;
- while (isspace(**data)) (*data)++;
+ while (i_isspace(**data)) (*data)++;
break;
}
- if (!isspace(**data)) {
+ if (!i_isspace(**data)) {
option = cmd_get_param(data);
} else {
option = "-";
@@ -610,14 +610,14 @@ static int get_cmd_options(char **data, int ignore_unknown,
*optlist[pos] == '!')
option = NULL;
- while (isspace(**data)) (*data)++;
+ while (i_isspace(**data)) (*data)++;
continue;
}
if (option == NULL)
break;
- if (*optlist[pos] == '@' && !isdigit(**data))
+ if (*optlist[pos] == '@' && !i_isdigit(**data))
break; /* expected a numeric argument */
/* save the argument */
@@ -628,7 +628,7 @@ static int get_cmd_options(char **data, int ignore_unknown,
}
option = NULL;
- while (isspace(**data)) (*data)++;
+ while (i_isspace(**data)) (*data)++;
}
return 0;
diff --git a/src/core/misc.c b/src/core/misc.c
index f67e8c7d..d57c7f66 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -126,7 +126,7 @@ int find_substr(const char *list, const char *item)
return FALSE;
for (;;) {
- while (isspace((gint) *list)) list++;
+ while (i_isspace(*list)) list++;
if (*list == '\0') break;
ptr = strchr(list, ' ');
@@ -324,7 +324,7 @@ char *stristr(const char *data, const char *key)
if (key[pos] == '\0')
return (char *) data;
- if (toupper(data[pos]) == toupper(key[pos]))
+ if (i_toupper(data[pos]) == i_toupper(key[pos]))
pos++;
else {
data++;
@@ -337,7 +337,7 @@ char *stristr(const char *data, const char *key)
#define isbound(c) \
((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)
{
@@ -364,7 +364,7 @@ char *strstr_full_case(const char *data, const char *key, int icase)
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];
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;
while (*s != '\0') {
- h = (h << 4) + toupper(*s);
+ h = (h << 4) + i_toupper(*s);
if ((g = h & 0xf0000000UL)) {
h = h ^ (g >> 24);
h = h ^ g;
@@ -493,7 +493,7 @@ int match_wildcards(const char *cmask, const char *data)
newmask = mask = g_strdup(cmask);
for (; *mask != '\0' && *data != '\0'; mask++) {
if (*mask != '*') {
- if (*mask != '?' && toupper(*mask) != toupper(*data))
+ if (*mask != '?' && i_toupper(*mask) != i_toupper(*data))
break;
data++;
@@ -539,7 +539,7 @@ int is_numeric(const char *str, char end_char)
return FALSE;
while (*str != '\0' && *str != end_char) {
- if (!isdigit(*str)) return FALSE;
+ if (!i_isdigit(*str)) return FALSE;
str++;
}
@@ -756,9 +756,9 @@ int expand_escape(const char **data)
case 'c':
/* control character (\cA = ^A) */
(*data)++;
- return toupper(**data) - 64;
+ return i_toupper(**data) - 64;
default:
- if (!isdigit(**data))
+ if (!i_isdigit(**data))
return -1;
/* octal */
diff --git a/src/core/network.c b/src/core/network.c
index 07dbe477..17f91d90 100644
--- a/src/core/network.c
+++ b/src/core/network.c
@@ -582,7 +582,7 @@ char *net_getservbyport(int port)
int is_ipv4_address(const char *host)
{
while (*host != '\0') {
- if (*host != '.' && !isdigit(*host))
+ if (*host != '.' && !i_isdigit(*host))
return 0;
host++;
}
diff --git a/src/core/nicklist.c b/src/core/nicklist.c
index 01e590fa..b7e85407 100644
--- a/src/core/nicklist.c
+++ b/src/core/nicklist.c
@@ -28,7 +28,7 @@
#include "masks.h"
#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)
{
@@ -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 */
while (*nick != '\0' && *msg != '\0') {
- if (toupper(*nick) == toupper(*msg)) {
+ if (i_toupper(*nick) == i_toupper(*msg)) {
/* total match */
msg++;
- } else if (isalnum(*msg) && !isalnum(*nick)) {
+ } else if (i_isalnum(*msg) && !i_isalnum(*nick)) {
/* some strange char in your nick, pass it */
fullmatch = FALSE;
} 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
from nick and check if it then matches. */
fullmatch = FALSE;
- while (*nick != '\0' && !isalnum(*nick))
+ while (*nick != '\0' && !i_isalnum(*nick))
nick++;
}
diff --git a/src/core/special-vars.c b/src/core/special-vars.c
index d961bd58..36d0743c 100644
--- a/src/core/special-vars.c
+++ b/src/core/special-vars.c
@@ -30,10 +30,10 @@
#define ALIGN_PAD 0x04
#define isvarchar(c) \
- (isalnum(c) || (c) == '_')
+ (i_isalnum(c) || (c) == '_')
#define isarg(c) \
- (isdigit(c) || (c) == '*' || (c) == '~' || (c) == '-')
+ (i_isdigit(c) || (c) == '*' || (c) == '~' || (c) == '-')
static SPECIAL_HISTORY_FUNC history_func = NULL;
@@ -54,7 +54,7 @@ static char *get_argument(char **cmd, char **arglist)
/* get last argument */
arg = max = argcount-1;
} else {
- if (isdigit(**cmd)) {
+ if (i_isdigit(**cmd)) {
/* first argument */
arg = max = (**cmd)-'0';
(*cmd)++;
@@ -63,7 +63,7 @@ static char *get_argument(char **cmd, char **arglist)
if (**cmd == '-') {
/* get more than one argument */
(*cmd)++;
- if (!isdigit(**cmd))
+ if (!i_isdigit(**cmd))
max = -1; /* get all the rest */
else {
max = (**cmd)-'0';
@@ -163,7 +163,7 @@ static char *get_variable(char **cmd, SERVER_REC *server, void *item,
get_argument(cmd, arglist);
}
- if (isalpha(**cmd) && isvarchar((*cmd)[1])) {
+ if (i_isalpha(**cmd) && isvarchar((*cmd)[1])) {
/* long variable name.. */
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 */
str = *data;
- while (*str != '\0' && *str != ']' && !isdigit(*str)) {
+ while (*str != '\0' && *str != ']' && !i_isdigit(*str)) {
if (*str == '!')
*flags &= ~ALIGN_CUT;
else if (*str == '-')
@@ -296,11 +296,11 @@ static int get_alignment_args(char **data, int *align, int *flags, char *pad)
*flags &= ~ALIGN_PAD;
str++;
}
- if (!isdigit(*str))
+ if (!i_isdigit(*str))
return FALSE; /* expecting number */
/* get the alignment size */
- while (isdigit(*str)) {
+ while (i_isdigit(*str)) {
*align = (*align) * 10 + (*str-'0');
str++;
}
diff --git a/src/fe-common/core/chat-completion.c b/src/fe-common/core/chat-completion.c
index bf92196a..6b988a1c 100644
--- a/src/fe-common/core/chat-completion.c
+++ b/src/fe-common/core/chat-completion.c
@@ -393,7 +393,7 @@ static GList *completion_nicks_nonstrict(CHANNEL_REC *channel,
/* remove non alnum chars from nick */
in = rec->nick; out = str;
while (*in != '\0') {
- if (isalnum(*in))
+ if (i_isalnum(*in))
*out++ = *in;
in++;
}
diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c
index 1b7d4465..399465ed 100644
--- a/src/fe-common/core/completion.c
+++ b/src/fe-common/core/completion.c
@@ -41,7 +41,7 @@ static int last_want_space, last_line_pos;
((c) == ',')
#define isseparator(c) \
- (isspace((int) (c)) || isseparator_notspace(c))
+ (i_isspace(c) || isseparator_notspace(c))
void chat_completion_init(void);
void chat_completion_deinit(void);
@@ -489,7 +489,7 @@ static char *line_get_command(const char *line, char **args, int aliases)
} else {
checkcmd = g_strndup(line, (int) (ptr-line));
- while (isspace(*ptr)) ptr++;
+ while (i_isspace(*ptr)) ptr++;
cmdargs = ptr;
}
diff --git a/src/fe-common/core/fe-messages.c b/src/fe-common/core/fe-messages.c
index ffb46ca4..4b4e4db4 100644
--- a/src/fe-common/core/fe-messages.c
+++ b/src/fe-common/core/fe-messages.c
@@ -37,7 +37,7 @@
#include "hilight-text.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;
@@ -67,7 +67,7 @@ char *expand_emphasis(WI_ITEM_REC *item, const char *text)
/* check that the beginning marker starts a word, and
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;
if ((end = strchr(bgn+1, *bgn)) == NULL)
continue;
diff --git a/src/fe-common/core/fe-settings.c b/src/fe-common/core/fe-settings.c
index 1bf0a954..bb4405fa 100644
--- a/src/fe-common/core/fe-settings.c
+++ b/src/fe-common/core/fe-settings.c
@@ -266,7 +266,7 @@ static void settings_save_fe(const 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);
g_free(fname);
}
@@ -304,7 +304,7 @@ static void cmd_save(const char *data)
static void settings_clean_confirm(const char *line)
{
- if (toupper(line[0]) == 'Y')
+ if (i_toupper(line[0]) == 'Y')
settings_clean_invalid();
}
diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c
index 4e0561bb..65b54ce6 100644
--- a/src/fe-common/core/formats.c
+++ b/src/fe-common/core/formats.c
@@ -699,7 +699,7 @@ static const char *get_ansi_color(THEME_REC *theme, const char *str,
for (;; str++) {
if (*str == '\0') return start;
- if (isdigit((int) *str)) {
+ if (i_isdigit(*str)) {
num = num*10 + (*str-'0');
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;
bg = bg_ret == NULL ? -1 : *bg_ret;
- if (!isdigit((int) **str) && **str != ',') {
+ if (!i_isdigit(**str) && **str != ',') {
fg = -1;
bg = -1;
} else {
@@ -766,7 +766,7 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
if (**str != ',') {
fg = **str-'0';
(*str)++;
- if (isdigit((int) **str)) {
+ if (i_isdigit(**str)) {
fg = fg*10 + (**str-'0');
(*str)++;
}
@@ -774,12 +774,12 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
if (**str == ',') {
/* background color */
(*str)++;
- if (!isdigit((int) **str))
+ if (!i_isdigit(**str))
bg = -1;
else {
bg = **str-'0';
(*str)++;
- if (isdigit((int) **str)) {
+ if (i_isdigit(**str)) {
bg = bg*10 + (**str-'0');
(*str)++;
}
diff --git a/src/fe-common/core/keyboard.c b/src/fe-common/core/keyboard.c
index bba8e4dd..ba41e6b2 100644
--- a/src/fe-common/core/keyboard.c
+++ b/src/fe-common/core/keyboard.c
@@ -265,7 +265,7 @@ static int expand_key(const char *key, GSList **out)
start = NULL; last_hyphen = TRUE;
for (; *key != '\0'; key++) {
if (start != NULL) {
- if (isalnum(*key) || *key == '_') {
+ if (i_isalnum(*key) || *key == '_') {
/* key combo continues */
continue;
}
@@ -291,7 +291,7 @@ static int expand_key(const char *key, GSList **out)
expand_out_char(*out, *key);
expand_out_char(*out, '-');
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 */
start = key;
last_hyphen = FALSE;
diff --git a/src/fe-common/core/themes.c b/src/fe-common/core/themes.c
index 04763612..f009f0ba 100644
--- a/src/fe-common/core/themes.c
+++ b/src/fe-common/core/themes.c
@@ -332,7 +332,7 @@ static char *theme_format_expand_abstract(THEME_REC *theme,
NULL, NULL, flags);
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
character is digit or '-' */
char digit, *tmp;
diff --git a/src/fe-common/core/translation.c b/src/fe-common/core/translation.c
index c674b9a2..d573fc17 100644
--- a/src/fe-common/core/translation.c
+++ b/src/fe-common/core/translation.c
@@ -50,7 +50,7 @@ void translate_output(char *text)
}
#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)
{
diff --git a/src/fe-common/irc/fe-events.c b/src/fe-common/irc/fe-events.c
index 03f37f0c..edb5496e 100644
--- a/src/fe-common/irc/fe-events.c
+++ b/src/fe-common/irc/fe-events.c
@@ -397,7 +397,7 @@ static void event_received(IRC_SERVER_REC *server, const char *data,
g_return_if_fail(data != NULL);
- if (!isdigit((gint) *data)) {
+ if (!i_isdigit(*data)) {
printtext(server, NULL, MSGLEVEL_CRAP, "%s", data);
return;
}
diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c
index 3ba30f90..fcaef077 100644
--- a/src/fe-text/gui-entry.c
+++ b/src/fe-text/gui-entry.c
@@ -293,9 +293,9 @@ void gui_entry_erase_word(GUI_ENTRY_REC *entry, int to_space)
while (entry->text->str[to] != ' ' && to > 0)
to--;
} else {
- while (!isalnum(entry->text->str[to]) && to > 0)
+ while (!i_isalnum(entry->text->str[to]) && to > 0)
to--;
- while (isalnum(entry->text->str[to]) && to > 0)
+ while (i_isalnum(entry->text->str[to]) && 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)
to++;
} else {
- while (!isalnum(entry->text->str[to]) && to < entry->text->len)
+ while (!i_isalnum(entry->text->str[to]) && to < entry->text->len)
to++;
- while (isalnum(entry->text->str[to]) && to < entry->text->len)
+ while (i_isalnum(entry->text->str[to]) && to < entry->text->len)
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] != ' ')
pos--;
} else {
- while (pos > 0 && !isalnum(entry->text->str[pos-1]))
+ while (pos > 0 && !i_isalnum(entry->text->str[pos-1]))
pos--;
- while (pos > 0 && isalnum(entry->text->str[pos-1]))
+ while (pos > 0 && i_isalnum(entry->text->str[pos-1]))
pos--;
}
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] != ' ')
pos++;
} else {
- while (pos < entry->text->len && !isalnum(entry->text->str[pos]))
+ while (pos < entry->text->len && !i_isalnum(entry->text->str[pos]))
pos++;
- while (pos < entry->text->len && isalnum(entry->text->str[pos]))
+ while (pos < entry->text->len && i_isalnum(entry->text->str[pos]))
pos++;
}
count--;
diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c
index b2386579..66545265 100644
--- a/src/fe-text/irssi.c
+++ b/src/fe-text/irssi.c
@@ -265,7 +265,7 @@ static void check_oldcrap(void)
str[0] = '\0';
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);
g_free(path);
}
diff --git a/src/fe-text/mainwindows.c b/src/fe-text/mainwindows.c
index 60fd3de9..50f8b93b 100644
--- a/src/fe-text/mainwindows.c
+++ b/src/fe-text/mainwindows.c
@@ -964,7 +964,7 @@ static void cmd_window_stick(const char *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 */
if (!WINDOW_GUI(win)->sticky) {
printformat_window(win, MSGLEVEL_CLIENTERROR,
diff --git a/src/fe-text/tparm.c b/src/fe-text/tparm.c
index 34a17f80..30c9cd0b 100644
--- a/src/fe-text/tparm.c
+++ b/src/fe-text/tparm.c
@@ -568,7 +568,7 @@ char *tparm(const char *str, ...) {
return OOPS;
i = 0;
sp++;
- while(isdigit(*sp))
+ while(i_isdigit(*sp))
i = 10 * i + *sp++ - '0';
if (*sp++ != '}' || pushnum(i))
return OOPS;
diff --git a/src/irc/bot/botnet-connection.c b/src/irc/bot/botnet-connection.c
index 59da48f6..7b2b3161 100644
--- a/src/irc/bot/botnet-connection.c
+++ b/src/irc/bot/botnet-connection.c
@@ -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
at the end of it */
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';
str = g_strdup_printf("%s%d", botnet->nick, num);
g_free(botnet->nick); botnet->nick = str;
diff --git a/src/irc/bot/botnet.c b/src/irc/bot/botnet.c
index 15c64b80..d1bd4141 100644
--- a/src/irc/bot/botnet.c
+++ b/src/irc/bot/botnet.c
@@ -266,7 +266,7 @@ GNode *bot_find_path(BOTNET_REC *botnet, const char *nick)
static int is_ip_mask(const char *addr)
{
while (*addr != '\0') {
- if (!isdigit(*addr) && *addr != '.' &&
+ if (!i_isdigit(*addr) && *addr != '.' &&
*addr != '*' && *addr != '?') return FALSE;
addr++;
}
diff --git a/src/irc/core/bans.c b/src/irc/core/bans.c
index 5583d63a..ea3203c9 100644
--- a/src/irc/core/bans.c
+++ b/src/irc/core/bans.c
@@ -208,13 +208,13 @@ static int parse_custom_ban(const char *type)
ban_type = 0;
list = g_strsplit(type, " ", -1);
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;
- else if (toupper(list[n][0]) == 'U')
+ else if (i_toupper(list[n][0]) == 'U')
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;
- else if (toupper(list[n][0]) == 'D')
+ else if (i_toupper(list[n][0]) == 'D')
ban_type |= IRC_MASK_DOMAIN;
}
g_strfreev(list);
@@ -228,15 +228,15 @@ static int parse_ban_type(const char *type)
g_return_val_if_fail(type != NULL, 0);
- if (toupper(type[0]) == 'N')
+ if (i_toupper(type[0]) == 'N')
return BAN_TYPE_NORMAL;
- if (toupper(type[0]) == 'U')
+ if (i_toupper(type[0]) == 'U')
return BAN_TYPE_USER;
- if (toupper(type[0]) == 'H')
+ if (i_toupper(type[0]) == 'H')
return BAN_TYPE_HOST;
- if (toupper(type[0]) == 'D')
+ if (i_toupper(type[0]) == 'D')
return BAN_TYPE_DOMAIN;
- if (toupper(type[0]) == 'C') {
+ if (i_toupper(type[0]) == 'C') {
pos = strchr(type, ' ');
if (pos != NULL)
return parse_custom_ban(pos+1);
diff --git a/src/irc/core/irc-masks.c b/src/irc/core/irc-masks.c
index 345b1b77..824a3b84 100644
--- a/src/irc/core/irc-masks.c
+++ b/src/irc/core/irc-masks.c
@@ -41,7 +41,7 @@ static char *get_domain_mask(char *host)
if (is_ipv4_address(host)) {
/* it's an IP address, change last digit to * */
ptr = strrchr(host, '.');
- if (ptr != NULL && isdigit(ptr[1]))
+ if (ptr != NULL && i_isdigit(ptr[1]))
strcpy(ptr+1, "*");
} else {
/* if more than one dot, skip the first
diff --git a/src/irc/core/irc-nicklist.c b/src/irc/core/irc-nicklist.c
index 97538487..4b661e88 100644
--- a/src/irc/core/irc-nicklist.c
+++ b/src/irc/core/irc-nicklist.c
@@ -51,7 +51,7 @@ NICK_REC *irc_nicklist_insert(IRC_CHANNEL_REC *channel, const char *nick,
}
#define isnickchar(a) \
- (isalnum((int) (a)) || (a) == '`' || (a) == '-' || (a) == '_' || \
+ (i_isalnum(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);
while (isnickchar(*nick)) {
- if (isalnum((int) *nick))
+ if (i_isalnum(*nick))
*spos++ = *nick;
nick++;
}
diff --git a/src/irc/core/irc.c b/src/irc/core/irc.c
index 7757db84..88816404 100644
--- a/src/irc/core/irc.c
+++ b/src/irc/core/irc.c
@@ -152,19 +152,19 @@ static char *split_nicks(const char *cmd, char **pre, char **nicks, char **post,
*pre = g_strdup(cmd);
*post = *nicks = NULL;
for (p = *pre; *p != '\0'; p++) {
- if (!isspace(*p))
+ if (!i_isspace(*p))
continue;
if (arg == 1) {
/* text after nicks */
*p++ = '\0';
- while (isspace(*p)) p++;
+ while (i_isspace(*p)) p++;
*post = p;
break;
}
/* find nicks */
- while (isspace(p[1])) p++;
+ while (i_isspace(p[1])) p++;
if (--arg == 1) {
*p = '\0';
*nicks = p+1;
diff --git a/src/irc/core/netsplit.c b/src/irc/core/netsplit.c
index abdfb49f..b0fcb08d 100644
--- a/src/irc/core/netsplit.c
+++ b/src/irc/core/netsplit.c
@@ -282,7 +282,7 @@ int quitmsg_is_split(const char *msg)
/* top-domain1 must be 2+ chars long and contain only alphabets */
p = host2-1;
while (p[-1] != '.') {
- if (!isalpha(p[-1]))
+ if (!i_isalpha(p[-1]))
return FALSE;
p--;
}
@@ -291,7 +291,7 @@ int quitmsg_is_split(const char *msg)
/* top-domain2 must be 2+ chars long and contain only alphabets */
p = host2+strlen(host2);
while (p[-1] != '.') {
- if (!isalpha(p[-1]))
+ if (!i_isalpha(p[-1]))
return FALSE;
p--;
}
diff --git a/src/irc/core/servers-redirect.c b/src/irc/core/servers-redirect.c
index 389c892d..1a1d159d 100644
--- a/src/irc/core/servers-redirect.c
+++ b/src/irc/core/servers-redirect.c
@@ -311,7 +311,7 @@ static int redirect_args_match(const char *event_args,
start = event_args;
while (*arg != '\0') {
while (*arg != '\0' && *arg != ' ' && *event_args != '\0') {
- if (toupper(*arg) != toupper(*event_args))
+ if (i_toupper(*arg) != i_toupper(*event_args))
break;
arg++; event_args++;
}
@@ -505,7 +505,7 @@ server_redirect_get(IRC_SERVER_REC *server, const char *event,
if (signal == NULL) {
/* unknown event - redirect to the default signal. */
if (strncmp(event, "event ", 6) == 0 &&
- isdigit(event[6])) {
+ i_isdigit(event[6])) {
signal = (*redirect)->default_signal;
if (*match == MATCH_NONE)
*match = MATCH_START;
diff --git a/src/irc/dcc/dcc-chat.c b/src/irc/dcc/dcc-chat.c
index dd9159c3..370d8ac5 100644
--- a/src/irc/dcc/dcc-chat.c
+++ b/src/irc/dcc/dcc-chat.c
@@ -456,7 +456,7 @@ static void cmd_mircdcc(const char *data, SERVER_REC *server,
dcc = item_get_dcc((WI_ITEM_REC *) item);
if (dcc == NULL) return;
- dcc->mirc_ctcp = toupper(*data) != 'N' &&
+ dcc->mirc_ctcp = i_toupper(*data) != 'N' &&
g_strncasecmp(data, "OF", 2) != 0;
}
diff --git a/src/lib-config/get.c b/src/lib-config/get.c
index 518cab40..124d7101 100644
--- a/src/lib-config/get.c
+++ b/src/lib-config/get.c
@@ -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);
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' */
@@ -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);
if (str == NULL) return def;
- return toupper(*str) == 'T' || toupper(*str) == 'Y' ||
- (toupper(*str) == 'O' && toupper(str[1]) == 'N');
+ return i_toupper(*str) == 'T' || i_toupper(*str) == 'Y' ||
+ (i_toupper(*str) == 'O' && i_toupper(str[1]) == 'N');
}
/* Get the value of keys `key' and `key_value' and put them to
diff --git a/src/lib-config/parse.c b/src/lib-config/parse.c
index a97c6b09..02eb4255 100644
--- a/src/lib-config/parse.c
+++ b/src/lib-config/parse.c
@@ -32,7 +32,7 @@ static unsigned int g_istr_hash(gconstpointer v)
unsigned int h = 0, g;
while (*s != '\0') {
- h = (h << 4) + toupper(*s);
+ h = (h << 4) + i_toupper(*s);
if ((g = h & 0xf0000000UL)) {
h = h ^ (g >> 24);
h = h ^ g;
diff --git a/src/lib-config/write.c b/src/lib-config/write.c
index 446735cd..19447827 100644
--- a/src/lib-config/write.c
+++ b/src/lib-config/write.c
@@ -77,7 +77,7 @@ static int config_has_specials(const char *text)
g_return_val_if_fail(text != NULL, FALSE);
while (*text != '\0') {
- if (!isalnum((int) *text) && *text != '_')
+ if (!i_isalnum(*text) && *text != '_')
return TRUE;
text++;
}
diff --git a/src/lib-popt/poptconfig.c b/src/lib-popt/poptconfig.c
index d064297c..835798a5 100644
--- a/src/lib-popt/poptconfig.c
+++ b/src/lib-popt/poptconfig.c
@@ -17,19 +17,19 @@ static void configLine(poptContext con, char * line) {
if (strncmp(line, con->appName, nameLength)) return;
line += nameLength;
- if (!*line || !isspace(*line)) return;
- while (*line && isspace(*line)) line++;
+ if (!*line || !i_isspace(*line)) return;
+ while (*line && i_isspace(*line)) line++;
entryType = line;
- while (!*line || !isspace(*line)) line++;
+ while (!*line || !i_isspace(*line)) line++;
*line++ = '\0';
- while (*line && isspace(*line)) line++;
+ while (*line && i_isspace(*line)) line++;
if (!*line) return;
opt = line;
- while (!*line || !isspace(*line)) line++;
+ while (!*line || !i_isspace(*line)) line++;
*line++ = '\0';
- while (*line && isspace(*line)) line++;
+ while (*line && i_isspace(*line)) line++;
if (!*line) return;
if (opt[0] == '-' && opt[1] == '-')
@@ -92,7 +92,7 @@ int poptReadConfigFile(poptContext con, char * fn) {
case '\n':
*dst = '\0';
dst = buf;
- while (*dst && isspace(*dst)) dst++;
+ while (*dst && i_isspace(*dst)) dst++;
if (*dst && *dst != '#') {
configLine(con, dst);
}
diff --git a/src/lib-popt/popthelp.c b/src/lib-popt/popthelp.c
index c1876d74..243f868e 100644
--- a/src/lib-popt/popthelp.c
+++ b/src/lib-popt/popthelp.c
@@ -94,15 +94,15 @@ static void singleOptionHelp(FILE * f, int maxLeftCol,
helpLength = strlen(help);
while (helpLength > lineLength) {
ch = help + lineLength - 1;
- while (ch > help && !isspace(*ch)) ch--;
+ while (ch > help && !i_isspace(*ch)) ch--;
if (ch == help) break; /* give up */
- while (ch > (help + 1) && isspace(*ch)) ch--;
+ while (ch > (help + 1) && i_isspace(*ch)) ch--;
ch++;
sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
fprintf(f, format, help, " ");
help = ch;
- while (isspace(*help) && *help) help++;
+ while (i_isspace(*help) && *help) help++;
helpLength = strlen(help);
}
diff --git a/src/lib-popt/poptparse.c b/src/lib-popt/poptparse.c
index eb2a6721..135ead56 100644
--- a/src/lib-popt/poptparse.c
+++ b/src/lib-popt/poptparse.c
@@ -45,7 +45,7 @@ int poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) {
if (*src != quote) *buf++ = '\\';
}
*buf++ = *src;
- } else if (isspace(*src)) {
+ } else if (isspace((int) (unsigned char) *src)) {
if (*argv[argc]) {
buf++, argc++;
if (argc == argvAlloced) {
diff --git a/src/perl/perl-core.c b/src/perl/perl-core.c
index 966c9b4f..d1063682 100644
--- a/src/perl/perl-core.c
+++ b/src/perl/perl-core.c
@@ -178,7 +178,7 @@ void script_fix_name(char *name)
if (p != NULL) *p = '\0';
while (*name != '\0') {
- if (*name != '_' && !isalnum(*name))
+ if (*name != '_' && !i_isalnum(*name))
*name = '_';
name++;
}