Fix bug #52611: Incorrect use of ctype macros?

by applying a modified version of Axel Lin's patch including Mike Kleshov's comments.
This commit is contained in:
Dirk Ziegelmeier 2017-12-07 12:01:09 +01:00
parent ec9f227eae
commit 60063b98e1

View File

@ -213,17 +213,17 @@ typedef int ssize_t;
#endif
#if LWIP_NO_CTYPE_H
#define lwip_in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up)
#define lwip_isdigit(c) lwip_in_range(c, '0', '9')
#define lwip_isxdigit(c) (lwip_isdigit(c) || lwip_in_range(c, 'a', 'f') || lwip_in_range(c, 'A', 'F'))
#define lwip_islower(c) lwip_in_range(c, 'a', 'z')
#define lwip_isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
#define lwip_in_range(c, lo, up) ((u8_t)(c) >= (lo) && (u8_t)(c) <= (up))
#define lwip_isdigit(c) lwip_in_range((c), '0', '9')
#define lwip_isxdigit(c) (lwip_isdigit(c) || lwip_in_range((c), 'a', 'f') || lwip_in_range((c), 'A', 'F'))
#define lwip_islower(c) lwip_in_range((c), 'a', 'z')
#define lwip_isspace(c) ((c) == ' ' || (c) == '\f' || (c) == '\n' || (c) == '\r' || (c) == '\t' || (c) == '\v')
#else
#include <ctype.h>
#define lwip_isdigit(c) isdigit((int)c)
#define lwip_isxdigit(c) isxdigit((int)c)
#define lwip_islower(c) islower((int)c)
#define lwip_isspace(c) isspace((int)c)
#define lwip_isdigit(c) isdigit((unsigned char)(c))
#define lwip_isxdigit(c) isxdigit((unsigned char)(c))
#define lwip_islower(c) islower((unsigned char)(c))
#define lwip_isspace(c) isspace((unsigned char)(c))
#endif
/** C++ const_cast<target_type>(val) equivalent to remove constness from a value (GCC -Wcast-qual) */