diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 07:33:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 07:33:58 +0000 |
commit | 77d6698bdfbc3fb878cb4490061f50e24a2cabec (patch) | |
tree | 33b9119b2179ed4aa93cea8c29fc1615ee8db9a7 /src/kash | |
parent | Adding upstream version 1:0.1.9998svn3589+dfsg. (diff) | |
download | kbuild-77d6698bdfbc3fb878cb4490061f50e24a2cabec.tar.xz kbuild-77d6698bdfbc3fb878cb4490061f50e24a2cabec.zip |
Adding upstream version 1:0.1.9998svn3604+dfsg.upstream/1%0.1.9998svn3604+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/kash/expand.c | 15 |
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); |