degesch: introduce transform_str()

This commit is contained in:
Přemysl Eric Janouch 2015-07-08 23:14:29 +02:00
parent 24a082b5d8
commit d3b1754e14
2 changed files with 10 additions and 6 deletions

View File

@ -58,6 +58,13 @@
(link)->next = (following); \ (link)->next = (following); \
BLOCK_END BLOCK_END
static void
transform_str (char *s, int (*tolower) (int c))
{
for (; *s; s++)
*s = tolower (*s);
}
static void static void
split_str (const char *s, char delimiter, struct str_vector *out) split_str (const char *s, char delimiter, struct str_vector *out)
{ {

View File

@ -4413,12 +4413,10 @@ irc_is_highlight (struct server *s, const char *message)
// Well, this is rather crude but it should make most users happy. // Well, this is rather crude but it should make most users happy.
// Ideally we could do this at least in proper Unicode. // Ideally we could do this at least in proper Unicode.
char *copy = xstrdup (message); char *copy = xstrdup (message);
for (char *p = copy; *p; p++) transform_str (copy, s->irc_tolower);
*p = s->irc_tolower (*p);
char *nick = xstrdup (s->irc_user->nickname); char *nick = xstrdup (s->irc_user->nickname);
for (char *p = nick; *p; p++) transform_str (nick, s->irc_tolower);
*p = s->irc_tolower (*p);
// Special characters allowed in nicknames by RFC 2812: []\`_^{|} and - // Special characters allowed in nicknames by RFC 2812: []\`_^{|} and -
// Also excluded from the ASCII: common user channel prefixes: +%@&~ // Also excluded from the ASCII: common user channel prefixes: +%@&~
@ -6825,8 +6823,7 @@ handle_command_ctcp (struct handler_args *a)
return false; return false;
char *tag = cut_word (&a->arguments); char *tag = cut_word (&a->arguments);
for (char *p = tag; *p; p++) transform_str (tag, toupper_ascii);
*p = toupper_ascii (*p);
if (*a->arguments) if (*a->arguments)
irc_send (a->s, "PRIVMSG %s :\x01%s %s\x01", target, tag, a->arguments); irc_send (a->s, "PRIVMSG %s :\x01%s %s\x01", target, tag, a->arguments);