diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/skalibs/bytestr.h | 9 | ||||
-rw-r--r-- | src/sysdeps/trystrnlen.c | 4 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/include/skalibs/bytestr.h b/src/include/skalibs/bytestr.h index b241197..2340a2f 100644 --- a/src/include/skalibs/bytestr.h +++ b/src/include/skalibs/bytestr.h @@ -11,6 +11,7 @@ #ifndef SKALIBS_FLAG_REPLACE_LIBC +#include <skalibs/sysdeps.h> #include <sys/types.h> #include <string.h> #include <strings.h> @@ -20,7 +21,13 @@ #define byte_diff(a, n, b) memcmp(a, (b), n) #define byte_zero(p, n) memset(p, 0, n) #define str_len strlen -#define str_nlen strnlen + +#ifdef SKALIBS_HASSTRNLEN +# define str_nlen strnlen +#else +# define str_nlen(s, max) byte_chr(s, (max), 0) +#endif + #define str_diff strcmp #define str_diffn strncmp #define str_copy(to, from) strlen(strcpy(to, from)) diff --git a/src/sysdeps/trystrnlen.c b/src/sysdeps/trystrnlen.c new file mode 100644 index 0000000..5361cc9 --- /dev/null +++ b/src/sysdeps/trystrnlen.c @@ -0,0 +1,4 @@ +/* ISC license. */ + +#include <string.h> +int main () { return strnlen("/", 1) ; } |