diff options
author | Christopher Faylor <me@cgf.cx> | 2005-01-31 19:52:03 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2005-01-31 19:52:03 +0000 |
commit | 01d13d44fbcded450990acff20b386c348bf3243 (patch) | |
tree | 4366047b5fb27546bfe89efc163768668231aadd /winsup | |
parent | ad1d82b8519898e0a41be6dda97607f665d806a4 (diff) | |
download | newlib-01d13d44fbcded450990acff20b386c348bf3243.zip newlib-01d13d44fbcded450990acff20b386c348bf3243.tar.gz newlib-01d13d44fbcded450990acff20b386c348bf3243.tar.bz2 |
* smallprint.c (rnarg): New macro.
(rnargLL): Ditto.
(__rn): Rename from 'rn', add a mask argument, and use the mask argument to
control how many significant digits to care about.
(__small_vsprintf): Use __rn, rnarg, rnargLL, as appropriate.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 8 | ||||
-rw-r--r-- | winsup/cygwin/smallprint.c | 34 |
2 files changed, 28 insertions, 14 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index dc23ecf..7427b11 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,13 @@ 2005-01-31 Christopher Faylor <cgf@timesys.com> + * smallprint.c (rnarg): New macro. + (rnargLL): Ditto. + (__rn): Rename from 'rn', add a mask argument, and use the mask + argument to control how many significant digits to care about. + (__small_vsprintf): Use __rn, rnarg, rnargLL, as appropriate. + +2005-01-31 Christopher Faylor <cgf@timesys.com> + * pinfo.cc (pinfo::exit): Only return low-order 16 bits when exiting. 2005-01-31 Corinna Vinschen <corinna@vinschen.de> diff --git a/winsup/cygwin/smallprint.c b/winsup/cygwin/smallprint.c index 6e7bf48d..2528eec 100644 --- a/winsup/cygwin/smallprint.c +++ b/winsup/cygwin/smallprint.c @@ -18,11 +18,17 @@ details. */ int __small_sprintf (char *dst, const char *fmt, ...); int __small_vsprintf (char *dst, const char *fmt, va_list ap); +#define LLMASK (0xffffffffffffffffULL) +#define LMASK (0xffffffff) + +#define rnarg(dst, base, dosign, len, pad) __rn ((dst), (base), (dosign), va_arg (ap, unsigned), len, pad, LMASK) +#define rnargLL(dst, base, dosign, len, pad) __rn ((dst), (base), (dosign), va_arg (ap, unsigned long long), len, pad, LLMASK) + static char * -rn (char *dst, int base, int dosign, long long val, int len, int pad) +__rn (char *dst, int base, int dosign, long long val, int len, int pad, unsigned long long mask) { /* longest number is ULLONG_MAX, 18446744073709551615, 20 digits */ - unsigned long long uval; + unsigned long long uval = 0; char res[20]; static const char str[16] = "0123456789ABCDEF"; int l = 0; @@ -38,9 +44,9 @@ rn (char *dst, int base, int dosign, long long val, int len, int pad) uval = val; } else - { - uval = val; - } + uval = val; + + uval &= mask; do { @@ -115,38 +121,38 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap) { *dst++ = '0'; *dst++ = 'x'; - dst = rn (dst, 16, 0, c, len, pad); + dst = __rn (dst, 16, 0, c, len, pad, LMASK); } } break; case 'E': strcpy (dst, "Win32 error "); - dst = rn (dst + sizeof ("Win32 error"), 10, 0, GetLastError (), len, pad); + dst = __rn (dst + sizeof ("Win32 error"), 10, 0, GetLastError (), len, pad, LMASK); break; case 'd': - dst = rn (dst, 10, addsign, va_arg (ap, int), len, pad); + dst = rnarg (dst, 10, addsign, len, pad); break; case 'D': - dst = rn (dst, 10, addsign, va_arg (ap, long long), len, pad); + dst = rnargLL (dst, 10, addsign, len, pad); break; case 'u': - dst = rn (dst, 10, 0, va_arg (ap, int), len, pad); + dst = rnarg (dst, 10, 0, len, pad); break; case 'U': - dst = rn (dst, 10, 0, va_arg (ap, long long), len, pad); + dst = rnargLL (dst, 10, 0, len, pad); break; case 'o': - dst = rn (dst, 8, 0, va_arg (ap, unsigned), len, pad); + dst = rnarg (dst, 8, 0, len, pad); break; case 'p': *dst++ = '0'; *dst++ = 'x'; /* fall through */ case 'x': - dst = rn (dst, 16, 0, va_arg (ap, int), len, pad); + dst = rnarg (dst, 16, 0, len, pad); break; case 'X': - dst = rn (dst, 16, 0, va_arg (ap, long long), len, pad); + dst = rnargLL (dst, 16, 0, len, pad); break; case 'P': if (!GetModuleFileName (NULL, tmp, CYG_MAX_PATH)) |