diff options
| -rw-r--r-- | include/al/lib.h | 7 | ||||
| -rw-r--r-- | include/al/types.h | 6 | ||||
| -rw-r--r-- | include/al/wstr.h | 8 |
3 files changed, 12 insertions, 9 deletions
diff --git a/include/al/lib.h b/include/al/lib.h index 71a6f7d..9aff075 100644 --- a/include/al/lib.h +++ b/include/al/lib.h @@ -43,7 +43,6 @@ #ifdef AL_USE_STDLIB #include <stdlib.h> #include <string.h> -#include <wchar.h> #include <stdio.h> #include <stdarg.h> @@ -135,12 +134,6 @@ static inline char *al_strndup(const char *s, size_t n) return ret; } -static inline size_t al_wcsnlen(const wchar_t *w, size_t n) -{ - const wchar_t *p = (const wchar_t *)wmemchr(w, L'\0', n); - return p ? (size_t)(p - w) : n; -} - static inline s32 al_printf(const char *fmt, ...) { #ifdef AL_FORCE_DISABLE_OUTPUT diff --git a/include/al/types.h b/include/al/types.h index 2e2ebfe..5b7a3cf 100644 --- a/include/al/types.h +++ b/include/al/types.h @@ -2,6 +2,8 @@ #define _AL_TYPES_H // https://www.gnu.org/software/c-intro-and-ref/manual/html_node/Integer-Const-Type.html +// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html +// https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170 #ifdef _POSIX_C_SOURCE #if _POSIX_C_SOURCE < 200112L @@ -25,12 +27,12 @@ typedef SSIZE_T ssize_t; #endif -#include <stddef.h> #include <stdbool.h> #include <stdint.h> +#include <stddef.h> #include <float.h> #include <limits.h> -#include <sys/types.h> +#include <sys/types.h> // off_t typedef int8_t s8; typedef uint8_t u8; diff --git a/include/al/wstr.h b/include/al/wstr.h index 599d126..8af16be 100644 --- a/include/al/wstr.h +++ b/include/al/wstr.h @@ -4,6 +4,8 @@ #include "lib.h" #include "str.h" +#include <wchar.h> + typedef struct { u32 length; u32 alloc; @@ -27,6 +29,12 @@ typedef struct { #define al_wstr_x(w) (w)->data // e(x)pand +static inline size_t al_wcsnlen(const wchar_t *w, size_t n) +{ + const wchar_t *p = (const wchar_t *)wmemchr(w, L'\0', n); + return p ? (size_t)(p - w) : n; +} + static inline s32 al_wchar_width(wchar_t wc) { #ifdef AL_HAVE_WIDE_STRING_WIDTH |