From 2ff19a17ae7072fab4a33073108be637bb6e3e2f Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Fri, 11 Feb 2022 19:12:36 +0100 Subject: [PATCH] FIX the parser when choping integers --- src/Lib/Script/FrontEnd/StrV.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Lib/Script/FrontEnd/StrV.cc b/src/Lib/Script/FrontEnd/StrV.cc index 60bfa036..19c6961f 100644 --- a/src/Lib/Script/FrontEnd/StrV.cc +++ b/src/Lib/Script/FrontEnd/StrV.cc @@ -412,7 +412,8 @@ StrV::tryChopInteger(int *ret, int *amount) noexcept char c = sv.data[0]; if (c < '0' || c > '9') break; - total = (total * 10) + (c - '0'); + total *= 10; + total += (c - '0'); sv.chopLeft(1); *amount += 1; } @@ -420,7 +421,7 @@ StrV::tryChopInteger(int *ret, int *amount) noexcept if ((negative && *amount <= 1) || (*amount == 0)) return false; - *ret = (negative * (-1 * total)) + (negative * total); + *ret = negative ? (-1 * total) : total; *this = sv; return true; } -- GitLab