From 9b6d7980406a8e809520c5756ba283d6347b3893 Mon Sep 17 00:00:00 2001 From: Doni Pracner Date: Fri, 25 Jul 2014 23:11:26 +0200 Subject: [PATCH] substr should not be called with a negative length - so we prevent this with a MIN function --- src/mjc2wsl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mjc2wsl.java b/src/mjc2wsl.java index d52dcfe..108094b 100644 --- a/src/mjc2wsl.java +++ b/src/mjc2wsl.java @@ -694,7 +694,7 @@ public class mjc2wsl{ prl(createTopTwoEStack()); if (genInlinePrint){ prl(createComment("print spacing and transformation",C_SPEC)); - prl("PRINFLUSH(SUBSTR(\" \", 0, MIN(10, tempa - 1)), @List_To_String(< tempb >));"); + prl("PRINFLUSH(SUBSTR(\" \", 0, MIN(10, MAX(0,tempa-1))), @List_To_String(< tempb >));"); } else prl("Print_MJ_CHAR(tempb,tempa);"); prl(createEndVar()); @@ -707,7 +707,7 @@ public class mjc2wsl{ prl(createTopTwoEStack()); if (genInlinePrint){ prl(createComment("print spacing",C_SPEC)); - prl("PRINFLUSH(SUBSTR(\" \", 0, MIN(10, tempa - 1)), tempb);"); + prl("PRINFLUSH(SUBSTR(\" \", 0, MIN(10, MAX(0, tempa-1))), tempb);"); } else prl("Print_MJ(tempb,tempa);"); -- 2.17.1