diff options
| author | Jakob Kaivo <jkk@ung.org> | 2024-06-04 13:41:06 -0400 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2024-06-04 13:41:06 -0400 |
| commit | 0a0ca17c3d6a77fc36f96189ccff9be12af66e63 (patch) | |
| tree | c0530452d5b0fb4d735ca6a2674445fefb01d093 /src/stdlib/_stdlib.h | |
| parent | 447a8463d51c98bd234d3c314696eab59ecb29f7 (diff) | |
track LC_CTYPE epoch in character conversion functions to detect a change
Diffstat (limited to 'src/stdlib/_stdlib.h')
| -rw-r--r-- | src/stdlib/_stdlib.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/stdlib/_stdlib.h b/src/stdlib/_stdlib.h index 7edb9d98..d5f89b09 100644 --- a/src/stdlib/_stdlib.h +++ b/src/stdlib/_stdlib.h @@ -3,8 +3,22 @@ #include <stdlib.h> #include <limits.h> +#include "locale/_locale.h" #include "_safety.h" +#ifndef NDEBUG +#define ASSERT_CTYPE(__s_ptr) do { \ + static unsigned int __ctype_epoch = 0; \ + if ((__s_ptr) == 0) { \ + __ctype_epoch = __get_ctype_epoch(); \ + } else if (__ctype_epoch != __get_ctype_epoch()) { \ + UNDEFINED("LC_CTYPE has changed since previous call which did not reset internal state"); \ + } \ +} while (0) +#else +#define ASSERT_CTYPE(__s_ptr) (void)(__s_ptr) +#endif + #ifdef NEED_COMPAR #ifdef NDEBUG #define SAFE_COMPAR(__comp, __p1, __p2, __sz, __fn) __comp(__p1, __p2) |
