diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-08-27 14:59:13 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-08-27 15:01:41 -0700 |
commit | f2712fcddff9c7ff571b19ace30d0d3a195ebde8 (patch) | |
tree | 50104729a765f0828345955af8eca76354a6716a /src/ifdef.c | |
parent | 34823e7e6770042ec5d7349218efdb34307349e9 (diff) | |
download | diffutils-f2712fcddff9c7ff571b19ace30d0d3a195ebde8.tar.gz |
diff: port line numbers to mingw64
Problem reported by Peter Rosin (Bug#24311).
* src/system.h (printint, pI): New typedef and macro.
All uses of 'long int' and "%l" in printf format replaced by
'printint' and "%"pI respectively.
* src/ifdef.c (do_printf_spec): Don't assume pI is length 1.
Diffstat (limited to 'src/ifdef.c')
-rw-r--r-- | src/ifdef.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/ifdef.c b/src/ifdef.c index b8b084f..d67eb5b 100644 --- a/src/ifdef.c +++ b/src/ifdef.c @@ -357,21 +357,22 @@ do_printf_spec (FILE *out, char const *spec, if (out) { - /* For example, if the spec is "%3xn", use the printf + /* For example, if the spec is "%3xn" and pI is "l", use the printf format spec "%3lx". Here the spec prefix is "%3". */ - long int long_value = value; + printint print_value = value; size_t spec_prefix_len = f - spec - 2; + size_t pI_len = sizeof pI - 1; #if HAVE_C_VARARRAYS - char format[spec_prefix_len + 3]; + char format[spec_prefix_len + pI_len + 2]; #else - char *format = xmalloc (spec_prefix_len + 3); + char *format = xmalloc (spec_prefix_len + pI_len + 2); #endif - char *p = format + spec_prefix_len; + char *p = format + spec_prefix_len + pI_len; memcpy (format, spec, spec_prefix_len); - *p++ = 'l'; + memcpy (format + spec_prefix_len, pI, pI_len); *p++ = c; *p = '\0'; - fprintf (out, format, long_value); + fprintf (out, format, print_value); #if ! HAVE_C_VARARRAYS free (format); #endif |