summaryrefslogtreecommitdiffstats
path: root/src/kash
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 07:34:16 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 07:34:29 +0000
commitb40c8769f2e4fb589de2263b7d8088d0c69ae6e3 (patch)
tree22c6eacfdac15bf24efde50cee4af7d9af38698b /src/kash
parentReleasing progress-linux version 1:0.1.9998svn3589+dfsg-1~progress7.99u1. (diff)
downloadkbuild-b40c8769f2e4fb589de2263b7d8088d0c69ae6e3.tar.xz
kbuild-b40c8769f2e4fb589de2263b7d8088d0c69ae6e3.zip
Merging upstream version 1:0.1.9998svn3604+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/kash')
-rw-r--r--src/kash/expand.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/kash/expand.c b/src/kash/expand.c
index ff30455..1131865 100644
--- a/src/kash/expand.c
+++ b/src/kash/expand.c
@@ -1555,15 +1555,15 @@ STATIC char *
cvtnum(shinstance *psh, int num, char *buf)
{
char temp[32];
+ char *p = &temp[sizeof(temp) - 1];
int neg = num < 0;
- char *p = temp + 31;
-
- temp[31] = '\0';
+ if (neg)
+ num = -num;
+ *p = '\0';
do {
*--p = num % 10 + '0';
} while ((num /= 10) != 0);
-
if (neg)
*--p = '-';
@@ -1576,11 +1576,12 @@ STATIC char *
cvtnum64(shinstance *psh, KI64 num, char *buf)
{
char temp[32];
+ char *p = &temp[sizeof(temp) - 1];
int neg = num < 0;
- char *p = temp + 31;
-
- temp[31] = '\0';
+ if (neg)
+ num = -num;
+ *p = '\0';
do {
*--p = num % 10 + '0';
} while ((num /= 10) != 0);