From 7e86457022db4bf293eac9d72f157e74a1d9add1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Wed, 3 Mar 2021 03:47:32 -0500 Subject: [PATCH] Fix pretty_int() commas for negative values. --- xtrn/lord2/l2lib.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xtrn/lord2/l2lib.js b/xtrn/lord2/l2lib.js index 423f53c275..d5c4409332 100644 --- a/xtrn/lord2/l2lib.js +++ b/xtrn/lord2/l2lib.js @@ -1064,7 +1064,7 @@ function space_pad(str, len) function pretty_int(int, rpad) { - var ret = parseInt(int, 10).toString(); + var ret = parseInt(Math.abs(int), 10).toString(); var i; if (rpad === undefined) rpad = 0; @@ -1072,6 +1072,8 @@ function pretty_int(int, rpad) for (i = ret.length - 3; i > 0; i-= 3) { ret = ret.substr(0, i)+','+ret.substr(i); } + if (int < 0) + ret = '-' + ret; ret = space_pad(ret, rpad); return ret; } -- GitLab