mirror of
https://github.com/reactos/reactos.git
synced 2024-11-18 21:13:52 +00:00
[CMD] Fix substring-substitute regression from commit cdc8e45b
(use signed offsets).
This commit is contained in:
parent
f2e3e8a1eb
commit
f5ba9de2ee
1 changed files with 5 additions and 7 deletions
|
@ -1421,21 +1421,19 @@ do { \
|
|||
}
|
||||
else if (*Src == _T('~'))
|
||||
{
|
||||
/* %VAR:~[start][,length]% - substring
|
||||
/* %VAR:~[start][,length]% - Substring.
|
||||
* Negative values are offsets from the end.
|
||||
*/
|
||||
size_t Start = _tcstol(Src + 1, (PTSTR*)&Src, 0);
|
||||
size_t End = VarLength;
|
||||
SSIZE_T Start = _tcstol(Src + 1, (PTSTR*)&Src, 0);
|
||||
SSIZE_T End = (SSIZE_T)VarLength;
|
||||
if (Start < 0)
|
||||
Start += VarLength;
|
||||
Start = max(Start, 0);
|
||||
Start = min(Start, VarLength);
|
||||
Start = min(max(Start, 0), VarLength);
|
||||
if (*Src == _T(','))
|
||||
{
|
||||
End = _tcstol(Src + 1, (PTSTR*)&Src, 0);
|
||||
End += (End < 0) ? VarLength : Start;
|
||||
End = max(End, Start);
|
||||
End = min(End, VarLength);
|
||||
End = min(max(End, Start), VarLength);
|
||||
}
|
||||
if (*Src++ != Delim)
|
||||
goto bad_subst;
|
||||
|
|
Loading…
Reference in a new issue