mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 09:00:27 +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('~'))
|
else if (*Src == _T('~'))
|
||||||
{
|
{
|
||||||
/* %VAR:~[start][,length]% - substring
|
/* %VAR:~[start][,length]% - Substring.
|
||||||
* Negative values are offsets from the end.
|
* Negative values are offsets from the end.
|
||||||
*/
|
*/
|
||||||
size_t Start = _tcstol(Src + 1, (PTSTR*)&Src, 0);
|
SSIZE_T Start = _tcstol(Src + 1, (PTSTR*)&Src, 0);
|
||||||
size_t End = VarLength;
|
SSIZE_T End = (SSIZE_T)VarLength;
|
||||||
if (Start < 0)
|
if (Start < 0)
|
||||||
Start += VarLength;
|
Start += VarLength;
|
||||||
Start = max(Start, 0);
|
Start = min(max(Start, 0), VarLength);
|
||||||
Start = min(Start, VarLength);
|
|
||||||
if (*Src == _T(','))
|
if (*Src == _T(','))
|
||||||
{
|
{
|
||||||
End = _tcstol(Src + 1, (PTSTR*)&Src, 0);
|
End = _tcstol(Src + 1, (PTSTR*)&Src, 0);
|
||||||
End += (End < 0) ? VarLength : Start;
|
End += (End < 0) ? VarLength : Start;
|
||||||
End = max(End, Start);
|
End = min(max(End, Start), VarLength);
|
||||||
End = min(End, VarLength);
|
|
||||||
}
|
}
|
||||||
if (*Src++ != Delim)
|
if (*Src++ != Delim)
|
||||||
goto bad_subst;
|
goto bad_subst;
|
||||||
|
|
Loading…
Reference in a new issue