mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 20:33:46 +02: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:
parent
820c9d3d82
commit
f4897860b5
35 changed files with 112 additions and 95 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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--;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue