From a2c859fcbda6476d37c1cd5ab9a5153b6e379b65 Mon Sep 17 00:00:00 2001 From: michael Date: Sun, 14 Jun 2015 19:21:54 +0000 Subject: [PATCH] - 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 --- src/irc.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) 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; } } -- 2.30.2