From 5f652529e4e62e9b98ccded179e773c5ae2fac55 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 17 Sep 2021 17:57:40 +0100 Subject: ash: avoid problems with non-zero DEBUG When DEBUG had a non-zero value the preprocessor complained that 'close' was being redefined. In a WIN32 build it's set to 'mingw_close'. Since this isn't necessary in ash it can be undefined without ill effects. DEBUG can be set to 1 or 2. In a WIN32 build this value was being used to calculate indices for optlist[], giving incorrect results. Using (DEBUG != 0) instead fixes this. --- shell/ash.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 8e43acdb0..f91cd7e1f 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -591,12 +591,12 @@ struct globals_misc { # define debug optlist[17 + BASH_PIPEFAIL] #endif #if ENABLE_PLATFORM_MINGW32 -# define winxp optlist[16 + BASH_PIPEFAIL + 2*DEBUG] +# define winxp optlist[16 + BASH_PIPEFAIL + 2*(DEBUG != 0)] # if ENABLE_ASH_NOCONSOLE -# define noconsole optlist[17 + BASH_PIPEFAIL + 2*DEBUG] +# define noconsole optlist[17 + BASH_PIPEFAIL + 2*(DEBUG != 0)] # endif # if ENABLE_ASH_NOCASEGLOB -# define nocaseglob optlist[17 + BASH_PIPEFAIL + 2*DEBUG+ENABLE_ASH_NOCONSOLE] +# define nocaseglob optlist[17 + BASH_PIPEFAIL + 2*(DEBUG != 0) + ENABLE_ASH_NOCONSOLE] # endif #endif @@ -698,6 +698,9 @@ static void trace_printf(const char *fmt, ...); static void trace_vprintf(const char *fmt, va_list va); # define TRACE(param) trace_printf param # define TRACEV(param) trace_vprintf param +# if ENABLE_PLATFORM_MINGW32 && defined(close) +# undef close +# endif # define close(fd) do { \ int dfd = (fd); \ if (close(dfd) < 0) \ -- cgit v1.2.3-55-g6feb