diff options
-rw-r--r-- | src/_assert.h | 6 | ||||
-rw-r--r-- | src/ctype/isblank.c | 2 | ||||
-rw-r--r-- | src/ctype/iscntrl.c | 2 | ||||
-rw-r--r-- | src/ctype/isgraph.c | 2 | ||||
-rw-r--r-- | src/ctype/islower.c | 2 | ||||
-rw-r--r-- | src/ctype/isprint.c | 2 | ||||
-rw-r--r-- | src/ctype/ispunct.c | 2 | ||||
-rw-r--r-- | src/ctype/isspace.c | 2 | ||||
-rw-r--r-- | src/ctype/isxdigit.c | 2 | ||||
-rw-r--r-- | src/stdlib/__constraint_info.h | 1 | ||||
-rw-r--r-- | src/stdlib/abort_handler_s.c | 1 |
11 files changed, 14 insertions, 10 deletions
diff --git a/src/_assert.h b/src/_assert.h index 5e472e89..1d7b1637 100644 --- a/src/_assert.h +++ b/src/_assert.h @@ -1,8 +1,9 @@ #ifndef ___ASSERT_H__ #define ___ASSERT_H__ +#include <errno.h> +#include <stdio.h> #include "stdlib/_stdlib.h" -#include "errno/ERANGE.h" #ifndef NDEBUG #define ASSERT_NONNULL(__ptr) do { \ @@ -28,9 +29,10 @@ } while (0) #define ASSERT_REPRESENTABLE(_n, _min, _max, _type, _sentinel) do { \ - if ((_n) != _sentinel && ((_n) < _min || (_n) > _max)) { \ + if (!(((_n) == (_sentinel)) || (((_min) <= (_n)) && ((_n) <= (_max))))) { \ struct __constraint_info _ci = {0}; \ _ci.func = __func__; \ + _ci.value = _n; \ __stdlib.constraint_handler("Undefined behavior: " \ "Parameter " #_n " must be representable as a " #_type \ " or be equal to " #_sentinel, &_ci, ERANGE); \ diff --git a/src/ctype/isblank.c b/src/ctype/isblank.c index 5b5ad8b1..54b5d239 100644 --- a/src/ctype/isblank.c +++ b/src/ctype/isblank.c @@ -12,7 +12,7 @@ int isblank(int c) ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, "unsigned char", EOF); - return map[c] & CT_BLANK; + return c == EOF ? 0 : map[c] & CT_BLANK; } /*** diff --git a/src/ctype/iscntrl.c b/src/ctype/iscntrl.c index 4c733b2c..83c52e1c 100644 --- a/src/ctype/iscntrl.c +++ b/src/ctype/iscntrl.c @@ -10,7 +10,7 @@ int iscntrl(int c) ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - return map[c] & CT_CNTRL; + return c == EOF ? 0 : map[c] & CT_CNTRL; } /*** diff --git a/src/ctype/isgraph.c b/src/ctype/isgraph.c index 49de9c1f..3a8f2871 100644 --- a/src/ctype/isgraph.c +++ b/src/ctype/isgraph.c @@ -10,7 +10,7 @@ int isgraph(int c) ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - return map[c] & CT_GRAPH; + return c == EOF ? 0 : map[c] & CT_GRAPH; } /*** diff --git a/src/ctype/islower.c b/src/ctype/islower.c index 259d1149..0a928a33 100644 --- a/src/ctype/islower.c +++ b/src/ctype/islower.c @@ -10,7 +10,7 @@ int islower(int c) ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - return map[c] & CT_LOWER; + return c == EOF ? 0 : map[c] & CT_LOWER; } /*** diff --git a/src/ctype/isprint.c b/src/ctype/isprint.c index e7843442..b0aa2121 100644 --- a/src/ctype/isprint.c +++ b/src/ctype/isprint.c @@ -10,7 +10,7 @@ int isprint(int c) ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - return map[c] & CT_PRINT; + return c == EOF ? 0 : map[c] & CT_PRINT; } /*** diff --git a/src/ctype/ispunct.c b/src/ctype/ispunct.c index 7dcf3c99..f1ddf41c 100644 --- a/src/ctype/ispunct.c +++ b/src/ctype/ispunct.c @@ -10,7 +10,7 @@ int ispunct(int c) ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - return map[c] & CT_PUNCT; + return c == EOF ? 0 : map[c] & CT_PUNCT; } /*** diff --git a/src/ctype/isspace.c b/src/ctype/isspace.c index 8c0a9c18..ca39d051 100644 --- a/src/ctype/isspace.c +++ b/src/ctype/isspace.c @@ -10,7 +10,7 @@ int isspace(int c) ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - return map[c] & CT_SPACE; + return c == EOF ? 0 : map[c] & CT_SPACE; } /*** diff --git a/src/ctype/isxdigit.c b/src/ctype/isxdigit.c index a534d2f0..6c44a37e 100644 --- a/src/ctype/isxdigit.c +++ b/src/ctype/isxdigit.c @@ -10,7 +10,7 @@ int isxdigit(int c) ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - return map[c] & CT_XDIGIT; + return c == EOF ? 0 : map[c] & CT_XDIGIT; } /*** diff --git a/src/stdlib/__constraint_info.h b/src/stdlib/__constraint_info.h index f8ffb539..9e66db5b 100644 --- a/src/stdlib/__constraint_info.h +++ b/src/stdlib/__constraint_info.h @@ -1,3 +1,4 @@ struct __constraint_info { const char *func; + int value; }; diff --git a/src/stdlib/abort_handler_s.c b/src/stdlib/abort_handler_s.c index c08ebb4e..c35148a7 100644 --- a/src/stdlib/abort_handler_s.c +++ b/src/stdlib/abort_handler_s.c @@ -12,6 +12,7 @@ void abort_handler_s(const char * restrict msg, void * restrict ptr, errno_t err puts(msg); if (ci) { printf("In call to %s\n", ci->func); + printf("value %x\n", ci->value); } if (error != 0) { printf("Provided error: %s (%d)\n", strerror(error), error); |