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:16 +0000
commit5dcc47be540f3a6de2744025e47f33ecf4f27f12 (patch)
tree5783baf72619d0374141e9fd0a6de32db7d1ac13 /src/kash
parentAdding debian version 1:0.1.9998svn3589+dfsg-1. (diff)
downloadkbuild-5dcc47be540f3a6de2744025e47f33ecf4f27f12.tar.xz
kbuild-5dcc47be540f3a6de2744025e47f33ecf4f27f12.zip
Merging upstream version 1:0.1.9998svn3604+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-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);