diff --git a/Changes b/Changes index 0e51e6157..bec55c41c 100644 --- a/Changes +++ b/Changes @@ -101,3 +101,4 @@ - Made /mode (umode change) only send 1 unknown mode msg, forgot who suggested this one - Made /rehash -motd/rules use tld {} - Heavily recoded /rehash (removed a ton of coding) +- Updated match() to have some optimizations from bahamut diff --git a/src/match.c b/src/match.c index f257b015f..51c9bbd7a 100644 --- a/src/match.c +++ b/src/match.c @@ -41,7 +41,7 @@ u_char touppertab[], tolowertab[]; * match() * written by binary */ -int match(mask, name) +static inline match2(mask, name) char *mask, *name; { u_char *m; /* why didn't the old one use registers ?!??!?!?! */ @@ -393,3 +393,31 @@ u_char char_atribs[] = { /* e0-ef */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* f0-ff */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +/* Old match() */ +int _match(char *mask, char *name) { + return match2(mask,name); +} + + +/* Old match() plus some optimizations from bahamut */ +int match(char *mask, char *name) { + if (mask[0] == '*' && mask[1] == '!') { + mask += 2; + while (*name != '!' && *name) + name++; + if (!*name) + return 1; + name++; + } + + if (mask[0] == '*' && mask[1] == '@') { + mask += 2; + while (*name != '@' && *name) + name++; + if (!*name) + return 1; + name++; + } + return match2(mask,name); +} diff --git a/src/s_conf.c b/src/s_conf.c index c7fca24d5..f228e1870 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -380,13 +380,13 @@ int find_nline(aClient *cptr) for (aconf = conf; aconf; aconf = aconf->next) { if (aconf->status & CONF_NLINE - && (match(aconf->host, cptr->info) == 0)) { + && (_match(aconf->host, cptr->info) == 0)) { for (aconf2 = conf; aconf2; aconf2 = aconf2->next) if ((aconf2->status == CONF_EXCEPT) && aconf2->host && aconf2->name - && (match(aconf2->host, cptr->sockhost) == 0) + && (_match(aconf2->host, cptr->sockhost) == 0) && (!cptr->user->username - || match(aconf2->name, cptr->user->username) == 0)) + || _match(aconf2->name, cptr->user->username) == 0)) return 0; break; } diff --git a/src/s_serv.c b/src/s_serv.c index 2c94d72c5..651b23cb0 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -3735,7 +3735,7 @@ else { cr_rehash(); return 0; } - if (!match("-o*motd", parv[1])) + if (!_match("-o*motd", parv[1])) { if (!IsAdmin(sptr)) return 0; @@ -3745,7 +3745,7 @@ else { opermotd = (aMotd *) read_opermotd(OPATH); return 0; } - if (!match("-b*motd", parv[1])) + if (!_match("-b*motd", parv[1])) { if (!IsAdmin(sptr)) return 0;