Allow shifting macro arguments by a negative amount

Fixes #733
This commit is contained in:
Rangi
2021-02-12 23:09:06 -05:00
committed by Eldred Habert
parent 96bce05be2
commit 8f20620c16
5 changed files with 18 additions and 5 deletions

View File

@@ -168,12 +168,12 @@ void macro_ShiftCurrentArgs(int32_t count)
{
if (!macroArgs) {
error("Cannot shift macro arguments outside of a macro\n");
} else if (count < 0) {
error("Cannot shift arguments by negative amount %" PRId32 "\n", count);
} else if (macroArgs->shift < macroArgs->nbArgs) {
macroArgs->shift += count;
if (macroArgs->shift > macroArgs->nbArgs)
macroArgs->shift = macroArgs->nbArgs;
else if (macroArgs->shift < 0)
macroArgs->shift = 0;
}
}