From: havoc Date: Tue, 8 Jul 2003 09:51:12 +0000 (+0000) Subject: redesigned much of PF_VarString to clean it up (shorter, faster, etc) X-Git-Tag: xonotic-v0.1.0preview~6560 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9912a20422cea9a76f89ad056033368c5c97c687;p=xonotic%2Fdarkplaces.git redesigned much of PF_VarString to clean it up (shorter, faster, etc) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3185 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/pr_cmds.c b/pr_cmds.c index 8acdec77..b432657b 100644 --- a/pr_cmds.c +++ b/pr_cmds.c @@ -41,26 +41,21 @@ char pr_varstring_temp[MAX_VARSTRING]; */ -char *PF_VarString (int first) +char *PF_VarString (int first) { - int i, j, end; - char *s; + int i; + const char *s; + char *out, *outend; - end = 0; - for (i = first;i < pr_argc;i++) + out = pr_varstring_temp; + outend = pr_varstring_temp + sizeof(pr_varstring_temp) - 1; + for (i = first;i < pr_argc && out < outend;i++) { - // LordHavoc: FIXME: this is just a strlcat inlined s = G_STRING((OFS_PARM0+i*3)); - j = strlen(s); - if (j > MAX_VARSTRING - 1 - end) - j = MAX_VARSTRING - 1 - end; - if (j > 0) - { - memcpy(pr_varstring_temp + end, s, j); - end += j; - } + while (out < outend && *s) + *out++ = *s++; } - pr_varstring_temp[end] = 0; + *out++ = 0; return pr_varstring_temp; }