Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/historical/nawk/dist - make decimal conversions use...



details:   https://anonhg.NetBSD.org/src/rev/a3236d9effcd
branches:  trunk
changeset: 771484:a3236d9effcd
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Nov 22 22:30:22 2011 +0000

description:
- make decimal conversions use the maximum width integers available on the
  architecture.
- make signed and unsigned code consistent.

diffstat:

 external/historical/nawk/dist/run.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (39 lines):

diff -r 863a222fe60b -r a3236d9effcd external/historical/nawk/dist/run.c
--- a/external/historical/nawk/dist/run.c       Tue Nov 22 21:25:05 2011 +0000
+++ b/external/historical/nawk/dist/run.c       Tue Nov 22 22:30:22 2011 +0000
@@ -37,6 +37,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <time.h>
+#include <stdint.h>
 #include "awk.h"
 #include "awkgram.h"
 
@@ -882,12 +883,15 @@
                case 'd': case 'i':
                        flag = 'd';
                        if(*(s-1) == 'l') break;
-                       *(t-1) = 'l';
+                       *(t-1) = 'j';
                        *t = 'd';
                        *++t = '\0';
                        break;
                case 'o': case 'x': case 'X': case 'u':
                        flag = *(s-1) == 'l' ? 'd' : 'u';
+                       *(t-1) = 'j';
+                       *t = *s;
+                       *++t = '\0';
                        break;
                case 's':
                        flag = 's';
@@ -920,8 +924,8 @@
                        snprintf(p, BUFSZ(p), "%s", t);
                        break;
                case 'f':       snprintf(p, BUFSZ(p), fmt, getfval(x)); break;
-               case 'd':       snprintf(p, BUFSZ(p), fmt, (long) getfval(x)); break;
-               case 'u':       snprintf(p, BUFSZ(p), fmt, (int) getfval(x)); break;
+               case 'd':       snprintf(p, BUFSZ(p), fmt, (intmax_t) getfval(x)); break;
+               case 'u':       snprintf(p, BUFSZ(p), fmt, (uintmax_t) getfval(x)); break;
                case 's':
                        t = getsval(x);
                        n = strlen(t);



Home | Main Index | Thread Index | Old Index