mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-16 01:11:28 +00:00
LunaCON: implement 'qstrncat' command.
git-svn-id: https://svn.eduke32.com/eduke32@4795 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
7cce9c39cb
commit
973d4950bb
3 changed files with 18 additions and 5 deletions
|
@ -747,7 +747,7 @@ function _qstrcpy(qdst, qsrc)
|
|||
end
|
||||
|
||||
-- NOTE: qdst==qsrc is OK (duplicates the quote)
|
||||
function _qstrcat(qdst, qsrc)
|
||||
function _qstrcat(qdst, qsrc, n)
|
||||
local cstr_dst = bcheck.quote_idx(qdst)
|
||||
local cstr_src = bcheck.quote_idx(qsrc)
|
||||
|
||||
|
@ -759,6 +759,12 @@ function _qstrcat(qdst, qsrc)
|
|||
return strcpy(cstr_dst, cstr_src)
|
||||
end
|
||||
|
||||
if (n == nil) then
|
||||
n = 0x7fffffff
|
||||
elseif (n < 0) then
|
||||
error("invalid number of chars to concatenate: "..n, 2)
|
||||
end
|
||||
|
||||
-- From here on: destination and source quote (potentially aliased) are
|
||||
-- nonempty.
|
||||
|
||||
|
@ -775,10 +781,11 @@ function _qstrcat(qdst, qsrc)
|
|||
repeat
|
||||
-- NOTE: don't copy the first char yet, so that the qdst==qsrc case
|
||||
-- works correctly.
|
||||
n = n-1
|
||||
i = i+1
|
||||
j = j+1
|
||||
cstr_dst[i] = cstr_src[j]
|
||||
until (i >= MAXQUOTELEN-1 or cstr_src[j]==0)
|
||||
until (n == 0 or i >= MAXQUOTELEN-1 or cstr_src[j]==0)
|
||||
|
||||
-- Now copy the first char!
|
||||
cstr_dst[slen_dst] = cstr_src[0]
|
||||
|
|
|
@ -2669,8 +2669,8 @@ local Cinner = {
|
|||
/ "_con._qstrcpy(%1,%2)",
|
||||
qstrlen = cmd(W,R)
|
||||
/ "%1=_con._qstrlen(%2)",
|
||||
qstrncat = cmd(R,R)
|
||||
/ handle.NYI,
|
||||
qstrncat = cmd(R,R,R)
|
||||
/ "_con._qstrcat(%1,%2,%3)",
|
||||
qsubstr = cmd(R,R,R,R)
|
||||
/ "_con._qsubstr(%1,%2,%3,%4)",
|
||||
quote = cmd(D)
|
||||
|
|
|
@ -51,6 +51,12 @@ onevent EVENT_ENTERLEVEL
|
|||
qstrcat 115 115 // this one is redundant, but must not overflow the quote buffer
|
||||
userquote 115
|
||||
|
||||
////////// qstrncat test
|
||||
redefinequote 300 012345678|
|
||||
qstrncat 300 300 2
|
||||
userquote 300 // "012345678|01"
|
||||
//////////
|
||||
|
||||
redefinequote 117 X%s
|
||||
qsprintf 117 /*<-*/ 117 /*args:*/ 115
|
||||
userquote 117 // result: "X" .. 12 x "012345678|" .. "012345" (= total length 127 = MAXQUOTELEN-1)
|
||||
|
@ -78,7 +84,7 @@ onevent EVENT_ENTERLEVEL
|
|||
// qgetsysstr test
|
||||
qgetsysstr 401 STR_MAPNAME
|
||||
qgetsysstr 402 STR_MAPFILENAME
|
||||
qgetsysstr 403 STR_PLAYERNAME
|
||||
// qgetsysstr 403 STR_PLAYERNAME
|
||||
qgetsysstr 404 STR_VERSION
|
||||
qgetsysstr 405 STR_GAMETYPE
|
||||
qgetsysstr 406 STR_VOLUMENAME
|
||||
|
|
Loading…
Reference in a new issue