From: michael Date: Sun, 14 Jun 2015 19:21:37 +0000 (+0000) Subject: - irc.c:userinfo_create(): use pointer arithmetic instead of array subscripting X-Git-Tag: 1.1.0beta1~27 X-Git-Url: http://git.serene-ircd.net/?a=commitdiff_plain;h=a11219c12953589f1ed5cc21672e490119eb0cf2;p=hopm.git - irc.c:userinfo_create(): use pointer arithmetic instead of array subscripting git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/trunk@6150 82007160-df01-0410-b94d-b575c5fd34c7 --- diff --git a/src/irc.c b/src/irc.c index 702e859..4c5ff8a 100644 --- a/src/irc.c +++ b/src/irc.c @@ -590,27 +590,27 @@ static struct UserInfo * userinfo_create(const char *source) { struct UserInfo *ret; - char *nick = NULL; + char tmp[MSGLENMAX]; + char *nick = tmp; char *username = NULL; char *hostname = NULL; - char tmp[MSGLENMAX]; - size_t len; - len = strlcpy(tmp, source, sizeof(tmp)); - nick = tmp; + strlcpy(tmp, source, sizeof(tmp)); - for (size_t i = 0; i < len; ++i) + for (char *p = tmp; *p; ++p) { - if (tmp[i] == '!') + if (*p == '!') { - tmp[i] = '\0'; - username = tmp + i + 1; + *p = '\0'; + username = p + 1; + continue; } - if (tmp[i] == '@') + if (*p == '@') { - tmp[i] = '\0'; - hostname = tmp + i + 1; + *p = '\0'; + hostname = p + 1; + continue; } }