summaryrefslogtreecommitdiff
path: root/src/core
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 /src/core
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
Diffstat (limited to 'src/core')
-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
5 files changed, 28 insertions, 28 deletions
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++;
}