From: michael Date: Sun, 14 Jun 2015 19:21:54 +0000 (+0000) Subject: - irc.c:userinfo_create(): use pointer arithmetic instead of array subscripting X-Git-Tag: 1.0.8~20 X-Git-Url: http://git.serene-ircd.net/?a=commitdiff_plain;h=a2c859fcbda6476d37c1cd5ab9a5153b6e379b65;p=hopm.git - irc.c:userinfo_create(): use pointer arithmetic instead of array subscripting git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/branches/1.0.x@6151 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; } }