mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +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
|
end
|
||||||
|
|
||||||
-- NOTE: qdst==qsrc is OK (duplicates the quote)
|
-- 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_dst = bcheck.quote_idx(qdst)
|
||||||
local cstr_src = bcheck.quote_idx(qsrc)
|
local cstr_src = bcheck.quote_idx(qsrc)
|
||||||
|
|
||||||
|
@ -759,6 +759,12 @@ function _qstrcat(qdst, qsrc)
|
||||||
return strcpy(cstr_dst, cstr_src)
|
return strcpy(cstr_dst, cstr_src)
|
||||||
end
|
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
|
-- From here on: destination and source quote (potentially aliased) are
|
||||||
-- nonempty.
|
-- nonempty.
|
||||||
|
|
||||||
|
@ -775,10 +781,11 @@ function _qstrcat(qdst, qsrc)
|
||||||
repeat
|
repeat
|
||||||
-- NOTE: don't copy the first char yet, so that the qdst==qsrc case
|
-- NOTE: don't copy the first char yet, so that the qdst==qsrc case
|
||||||
-- works correctly.
|
-- works correctly.
|
||||||
|
n = n-1
|
||||||
i = i+1
|
i = i+1
|
||||||
j = j+1
|
j = j+1
|
||||||
cstr_dst[i] = cstr_src[j]
|
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!
|
-- Now copy the first char!
|
||||||
cstr_dst[slen_dst] = cstr_src[0]
|
cstr_dst[slen_dst] = cstr_src[0]
|
||||||
|
|
|
@ -2669,8 +2669,8 @@ local Cinner = {
|
||||||
/ "_con._qstrcpy(%1,%2)",
|
/ "_con._qstrcpy(%1,%2)",
|
||||||
qstrlen = cmd(W,R)
|
qstrlen = cmd(W,R)
|
||||||
/ "%1=_con._qstrlen(%2)",
|
/ "%1=_con._qstrlen(%2)",
|
||||||
qstrncat = cmd(R,R)
|
qstrncat = cmd(R,R,R)
|
||||||
/ handle.NYI,
|
/ "_con._qstrcat(%1,%2,%3)",
|
||||||
qsubstr = cmd(R,R,R,R)
|
qsubstr = cmd(R,R,R,R)
|
||||||
/ "_con._qsubstr(%1,%2,%3,%4)",
|
/ "_con._qsubstr(%1,%2,%3,%4)",
|
||||||
quote = cmd(D)
|
quote = cmd(D)
|
||||||
|
|
|
@ -51,6 +51,12 @@ onevent EVENT_ENTERLEVEL
|
||||||
qstrcat 115 115 // this one is redundant, but must not overflow the quote buffer
|
qstrcat 115 115 // this one is redundant, but must not overflow the quote buffer
|
||||||
userquote 115
|
userquote 115
|
||||||
|
|
||||||
|
////////// qstrncat test
|
||||||
|
redefinequote 300 012345678|
|
||||||
|
qstrncat 300 300 2
|
||||||
|
userquote 300 // "012345678|01"
|
||||||
|
//////////
|
||||||
|
|
||||||
redefinequote 117 X%s
|
redefinequote 117 X%s
|
||||||
qsprintf 117 /*<-*/ 117 /*args:*/ 115
|
qsprintf 117 /*<-*/ 117 /*args:*/ 115
|
||||||
userquote 117 // result: "X" .. 12 x "012345678|" .. "012345" (= total length 127 = MAXQUOTELEN-1)
|
userquote 117 // result: "X" .. 12 x "012345678|" .. "012345" (= total length 127 = MAXQUOTELEN-1)
|
||||||
|
@ -78,7 +84,7 @@ onevent EVENT_ENTERLEVEL
|
||||||
// qgetsysstr test
|
// qgetsysstr test
|
||||||
qgetsysstr 401 STR_MAPNAME
|
qgetsysstr 401 STR_MAPNAME
|
||||||
qgetsysstr 402 STR_MAPFILENAME
|
qgetsysstr 402 STR_MAPFILENAME
|
||||||
qgetsysstr 403 STR_PLAYERNAME
|
// qgetsysstr 403 STR_PLAYERNAME
|
||||||
qgetsysstr 404 STR_VERSION
|
qgetsysstr 404 STR_VERSION
|
||||||
qgetsysstr 405 STR_GAMETYPE
|
qgetsysstr 405 STR_GAMETYPE
|
||||||
qgetsysstr 406 STR_VOLUMENAME
|
qgetsysstr 406 STR_VOLUMENAME
|
||||||
|
|
Loading…
Reference in a new issue