From 93f4245e895bd409e9cccb8f0aaac59a67d83c58 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Sun, 5 Nov 2017 10:13:24 +0100 Subject: [PATCH] ip6_addr.c: Convert several macros to private #defines The macros are functions from ctype.h, but ctype.h declares them as functions, not as #defines It makes no sense to abstract them in lwIPs portability layer, the functions are of low complexity and they are only used in this file. --- src/core/ipv6/ip6_addr.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/core/ipv6/ip6_addr.c b/src/core/ipv6/ip6_addr.c index 19c969a6..dbd6fe82 100644 --- a/src/core/ipv6/ip6_addr.c +++ b/src/core/ipv6/ip6_addr.c @@ -50,14 +50,12 @@ /* used by IP6_ADDR_ANY(6) in ip6_addr.h */ const ip_addr_t ip6_addr_any = IPADDR6_INIT(0ul, 0ul, 0ul, 0ul); -#ifndef isprint -#define in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up) -#define isprint(c) in_range(c, 0x20, 0x7f) -#define isdigit(c) in_range(c, '0', '9') -#define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F')) -#define islower(c) in_range(c, 'a', 'z') -#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v') -#endif +#define lwip_in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up) +#define lwip_isprint(c) lwip_in_range(c, 0x20, 0x7f) +#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_xchar(i) ((char)((i) < 10 ? '0' + (i) : 'A' + (i) - 10)) @@ -82,7 +80,7 @@ ip6addr_aton(const char *cp, ip6_addr_t *addr) for (s = cp; *s != 0; s++) { if (*s == ':') { zero_blocks--; - } else if (!isxdigit(*s)) { + } else if (!lwip_isxdigit(*s)) { break; } } @@ -130,11 +128,11 @@ ip6addr_aton(const char *cp, ip6_addr_t *addr) } } } - } else if (isxdigit(*s)) { + } else if (lwip_isxdigit(*s)) { /* add current digit */ current_block_value = (current_block_value << 4) + - (isdigit(*s) ? (u32_t)(*s - '0') : - (u32_t)(10 + (islower(*s) ? *s - 'a' : *s - 'A'))); + (lwip_isdigit(*s) ? (u32_t)(*s - '0') : + (u32_t)(10 + (lwip_islower(*s) ? *s - 'a' : *s - 'A'))); } else { /* unexpected digit, space? CRLF? */ break;