From: Doni Pracner Date: Fri, 25 Jul 2014 21:11:26 +0000 (+0200) Subject: substr should not be called with a negative length - so we prevent this with a MIN... X-Git-Tag: v0.1.8~1^2~7 X-Git-Url: http://svarog.pmf.uns.ac.rs/gitweb/?p=mjc2wsl.git;a=commitdiff_plain;h=9b6d7980406a8e809520c5756ba283d6347b3893;hp=877ef369343b37d3d8ac7d60339ac922407c63fc substr should not be called with a negative length - so we prevent this with a MIN function --- 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);");