From 645c31e5f7370e4a715ce2c86b21a466eb158641 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Sun, 6 Jan 2013 13:53:44 +0200 Subject: [PATCH] ctype: always activate macros autoconf check is pointless, because compiler can still complain about wrong usage. So activate wrappers always, also remove arg, so they are also used where function pointers are needed. --- m4/usual.m4 | 37 ------------------------------------- usual/ctype.h | 35 ++++++++++++++++------------------- 2 files changed, 16 insertions(+), 56 deletions(-) diff --git a/m4/usual.m4 b/m4/usual.m4 index 35ad396..9e33462 100644 --- a/m4/usual.m4 +++ b/m4/usual.m4 @@ -182,43 +182,6 @@ AC_CHECK_HEADERS([ucred.h sys/ucred.h], [], [], [ #endif ]) -AC_MSG_CHECKING([whether works on char values]) -_good_ctype=no -AC_RUN_IFELSE([AC_LANG_SOURCE([ -#include -#define W(c) ((signed char)(c)) -int main(void) -{ - int c; - - /* if char is unsigned, all is ok */ - if ((int)(char)255 == (int)255) - return 0; - - for (c = 128; c < 256; c++) { - if (isalpha(c) != isalpha(W(c))) return 1; - if (isalnum(c) != isalnum(W(c))) return 1; - if (isascii(c) != isascii(W(c))) return 1; - if (isblank(c) != isblank(W(c))) return 1; - if (iscntrl(c) != iscntrl(W(c))) return 1; - if (isdigit(c) != isdigit(W(c))) return 1; - if (islower(c) != islower(W(c))) return 1; - if (isprint(c) != isprint(W(c))) return 1; - if (ispunct(c) != ispunct(W(c))) return 1; - if (isspace(c) != isspace(W(c))) return 1; - if (isupper(c) != isupper(W(c))) return 1; - if (isxdigit(c) != isxdigit(W(c))) return 1; - } - return 0; -} -])], [_good_ctype=yes], [_good_ctype=no], [_good_ctype=no]) -AC_MSG_RESULT([$_good_ctype]) -if test $_good_ctype = yes; then - AC_DEFINE(HAVE_CTYPE_ON_CHAR, [1], [Define if macros work on char.]) -fi - -]) - dnl dnl AC_USUAL_FUNCTION_CHECK: Basic functions diff --git a/usual/ctype.h b/usual/ctype.h index 0a0f2be..81a8ac0 100644 --- a/usual/ctype.h +++ b/usual/ctype.h @@ -43,8 +43,7 @@ static inline int isblank(int c) { return (c == ' ') || (c == '\t'); } #endif -#ifndef HAVE_CTYPE_ON_CHAR - +/* keep right signature, cast to uchar internally */ #define _WRAP_CTYPE_FN(name) \ static inline int safe_ ## name (int c) { \ return name((unsigned char)(c)); \ @@ -53,81 +52,79 @@ static inline int isblank(int c) { return (c == ' ') || (c == '\t'); } _WRAP_CTYPE_FN(isalnum) #undef isalnum /** Safe isalnum */ -#define isalnum(c) safe_isalnum(c) +#define isalnum safe_isalnum _WRAP_CTYPE_FN(isalpha) #undef isalpha /** Safe isalpha */ -#define isalpha(c) safe_isalpha(c) +#define isalpha safe_isalpha _WRAP_CTYPE_FN(isascii) #undef isascii /** Safe isascii */ -#define isascii(c) safe_isascii(c) +#define isascii safe_isascii _WRAP_CTYPE_FN(isblank) #undef isblank /** Safe isblank */ -#define isblank(c) safe_isblank(c) +#define isblank safe_isblank _WRAP_CTYPE_FN(iscntrl) #undef iscntrl /** Safe iscntrl */ -#define iscntrl(c) safe_iscntrl(c) +#define iscntrl safe_iscntrl _WRAP_CTYPE_FN(isdigit) #undef isdigit /** Safe isdigit */ -#define isdigit(c) safe_isdigit(c) +#define isdigit safe_isdigit _WRAP_CTYPE_FN(isgraph) #undef isgraph /** Safe isgraph */ -#define isgraph(c) safe_isgraph(c) +#define isgraph safe_isgraph _WRAP_CTYPE_FN(islower) #undef islower /** Safe islower */ -#define islower(c) safe_islower(c) +#define islower safe_islower _WRAP_CTYPE_FN(isprint) #undef isprint /** Safe isprint */ -#define isprint(c) safe_isprint(c) +#define isprint safe_isprint _WRAP_CTYPE_FN(ispunct) #undef ispunct /** Safe ispunct */ -#define ispunct(c) safe_ispunct(c) +#define ispunct safe_ispunct _WRAP_CTYPE_FN(isspace) #undef isspace /** Safe isspace */ -#define isspace(c) safe_isspace(c) +#define isspace safe_isspace _WRAP_CTYPE_FN(isupper) #undef isupper /** Safe isupper */ -#define isupper(c) safe_isupper(c) +#define isupper safe_isupper _WRAP_CTYPE_FN(isxdigit) #undef isxdigit /** Safe isxdigit */ -#define isxdigit(c) safe_isxdigit(c) +#define isxdigit safe_isxdigit _WRAP_CTYPE_FN(tolower) #undef tolower /** Safe tolower */ -#define tolower(c) safe_tolower(c) +#define tolower safe_tolower _WRAP_CTYPE_FN(toupper) #undef toupper /** Safe toupper */ -#define toupper(c) safe_toupper(c) +#define toupper safe_toupper #undef _WRAP_CTYPE_FN -#endif /* HAVE_BROKEN_CTYPE */ - #endif /* _USUAL_CTYPE_H_ */ -- 2.39.5