From 92f3cb47aebf576987c97744028f1775c5518cf0 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 28 Aug 2016 16:46:34 -0700 Subject: [PATCH] diff: don't assume ptrdiff_t <= long long int * src/system.h (printint, pI): Port to (theoretical) platforms where ptrdiff_t is wider than long long int (Bug#24311). --- src/system.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/system.h b/src/system.h index 481d3a0..028113e 100644 --- a/src/system.h +++ b/src/system.h @@ -134,17 +134,19 @@ typedef ptrdiff_t lin; #define LIN_MAX PTRDIFF_MAX /* The signed integer type for printing line numbers, and its printf - length modifier. Prefer 'long int' if it suffices, to cater to C - implementations that lack support for "ll". The natural - C99-or-later implementation with ptrdiff_t and "t" is less portable - in practice. */ + length modifier. This is not simply ptrdiff_t, to cater to older + and/or nonstandard C libraries where "l" works but "ll" and "t" do + not, or where 'long' is too narrow and "ll" works but "t" does not. */ #if LIN_MAX <= LONG_MAX typedef long int printint; # define pI "l" -#else +#elif LIN_MAX <= LLONG_MAX typedef long long int printint; # define pI "ll" +#else +typedef ptrdiff_t printint; +# define pI "t" #endif verify (TYPE_SIGNED (lin)); -- 2.7.4