From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 746A7388A82B; Thu, 16 Jul 2020 09:30:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 746A7388A82B Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] ctype.h: Fix unused variable warnings X-Act-Checkin: newlib-cygwin X-Git-Author: Aschref Ben Thabet X-Git-Refname: refs/heads/master X-Git-Oldrev: 52ad92e1b65d640d625f67dbd87e8193c3409db5 X-Git-Newrev: 0ee972d1b095bfea89499b358646e44d60aa4a4b Message-Id: <20200716093048.746A7388A82B@sourceware.org> Date: Thu, 16 Jul 2020 09:30:48 +0000 (GMT) X-BeenThere: newlib-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib GIT logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jul 2020 09:30:48 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0ee972d1b095bfea89499b358646e44d60aa4a4b commit 0ee972d1b095bfea89499b358646e44d60aa4a4b Author: Aschref Ben Thabet Date: Thu Jul 16 10:28:49 2020 +0200 ctype.h: Fix unused variable warnings If __HAVE_LOCALE_INFO__ is not defined, then the locale in the locale-specific ctype functions is ignored. In the previous implementation this resulted in compiler warnings. For example: int main() { locale_t locale; locale = duplocale(uselocale((locale_t)0)); isspace_l('x', locale); return 0; } gcc -Wall main.c main.c: In function 'main': main.c:6:11: warning: variable 'locale' set but not used [-Wunused-but-set-variable] 6 | locale_t locale; | ^~~~~~ Diff: --- newlib/libc/include/ctype.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/newlib/libc/include/ctype.h b/newlib/libc/include/ctype.h index a0009af17..8b1013ac0 100644 --- a/newlib/libc/include/ctype.h +++ b/newlib/libc/include/ctype.h @@ -66,6 +66,9 @@ extern int toascii_l (int __c, locale_t __l); #define _X 0100 #define _B 0200 +/* For C++ backward-compatibility only. */ +extern __IMPORT const char _ctype_[]; + #ifdef __HAVE_LOCALE_INFO__ const char *__locale_ctype_ptr (void); #else @@ -108,7 +111,12 @@ const char *__locale_ctype_ptr (void); #ifdef __HAVE_LOCALE_INFO__ const char *__locale_ctype_ptr_l (locale_t); #else -#define __locale_ctype_ptr_l(l) _ctype_ +static __inline char * +__locale_ctype_ptr_l(locale_t _l) +{ + (void)_l; + return __locale_ctype_ptr(); +} #endif #define __ctype_lookup_l(__c,__l) ((__locale_ctype_ptr_l(__l)+sizeof(""[__c]))[(int)(__c)]) @@ -170,9 +178,6 @@ const char *__locale_ctype_ptr_l (locale_t); #endif /* !__cplusplus */ -/* For C++ backward-compatibility only. */ -extern __IMPORT const char _ctype_[]; - _END_STD_C #endif /* _CTYPE_H_ */