From 41570a186dfb7c0c42e2a152668f1af74c284c49 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 10 Mar 2024 12:11:35 -0700 Subject: [PATCH 2/4] Coalesce multiple PRIdMAX definitions PRIdMAX is useful in multiple places, and as inttypes.h defines it, move its definition to the include file that includes inttypes.h, as it's logical to fix PRIdMAX just after it's possibly incorrectly defined. * bashtypes.h (PRIdMAX): Move definition here ... * builtins/printf.def, examples/loadables/getconf.h: * examples/loadables/seq.c: ... from these multiple locations. --- bashtypes.h | 11 +++++++++++ builtins/printf.def | 12 ------------ examples/loadables/getconf.h | 8 -------- examples/loadables/seq.c | 12 ------------ 4 files changed, 11 insertions(+), 32 deletions(-) diff --git a/bashtypes.h b/bashtypes.h index 01afef4b..ceb08e59 100644 --- a/bashtypes.h +++ b/bashtypes.h @@ -35,6 +35,17 @@ # include #endif +#ifdef PRI_MACROS_BROKEN +# undef PRIdMAX +#endif +#ifndef PRIdMAX +# if HAVE_LONG_LONG +# define PRIdMAX "lld" +# else +# define PRIdMAX "ld" +# endif +#endif + #if HAVE_STDINT_H # include #endif diff --git a/builtins/printf.def b/builtins/printf.def index f7f4de34..f711ed38 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -89,18 +89,6 @@ $END #include "bashgetopt.h" #include "common.h" -#if defined (PRI_MACROS_BROKEN) -# undef PRIdMAX -#endif - -#if !defined (PRIdMAX) -# if HAVE_LONG_LONG -# define PRIdMAX "lld" -# else -# define PRIdMAX "ld" -# endif -#endif - #if !defined (errno) extern int errno; #endif diff --git a/examples/loadables/getconf.h b/examples/loadables/getconf.h index b8b9f102..98cc05e6 100644 --- a/examples/loadables/getconf.h +++ b/examples/loadables/getconf.h @@ -125,12 +125,4 @@ # define WORD_BIT (sizeof (int) * CHAR_BIT) #endif -#if !defined (PRIdMAX) -# if HAVE_LONG_LONG -# define PRIdMAX "lld" -# else -# define PRIdMAX "ld" -# endif -#endif - #endif /* _GETCONF_H */ diff --git a/examples/loadables/seq.c b/examples/loadables/seq.c index 2a2be827..13834b8d 100644 --- a/examples/loadables/seq.c +++ b/examples/loadables/seq.c @@ -35,18 +35,6 @@ extern int errno; #endif -#if defined (PRI_MACROS_BROKEN) -# undef PRIdMAX -#endif - -#if !defined (PRIdMAX) -# if HAVE_LONG_LONG -# define PRIdMAX "lld" -# else -# define PRIdMAX "ld" -# endif -#endif - #if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD && !defined(STRTOLD_BROKEN) typedef long double floatmax_t; # define FLOATMAX_CONV "L" -- 2.44.0