diff options
Diffstat (limited to 'Build/source/libs/zziplib/zziplib-src/zzip/__string.h')
-rw-r--r-- | Build/source/libs/zziplib/zziplib-src/zzip/__string.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/__string.h b/Build/source/libs/zziplib/zziplib-src/zzip/__string.h new file mode 100644 index 00000000000..351b0c14162 --- /dev/null +++ b/Build/source/libs/zziplib/zziplib-src/zzip/__string.h @@ -0,0 +1,67 @@ +#ifndef __ZZIP_INTERNAL_STRING_H +#define __ZZIP_INTERNAL_STRING_H + +#ifdef __linux__ +#define _GNU_SOURCE _glibc_developers_are_idiots_to_call_strndup_gnu_specific_ +#endif + +#include <zzip/conf.h> + +#if defined ZZIP_HAVE_STRING_H +#include <string.h> +#elif defined ZZIP_HAVE_STRINGS_H +#include <strings.h> +#endif + + +#if defined ZZIP_HAVE_STRNDUP || defined strndup +#define _zzip_strndup strndup +#else + +/* if your system does not have strndup: */ +zzip__new__ static char * +_zzip_strndup(char const *p, size_t maxlen) +{ + if (p == NULL) + { + return p; + } else + { + size_t len = strnlen(p, maxlen); + char* r = malloc(len + 1); + if (r == NULL) + return NULL; /* errno = ENOMEM */ + r[len] = '\0'; + return memcpy(r, p, len); + } +} +#endif + +#if defined ZZIP_HAVE_STRCASECMP || defined strcasecmp +#define _zzip_strcasecmp strcasecmp +#else + +/* if your system does not have strcasecmp: */ +static int +_zzip_strcasecmp(char *__zzip_restrict a, char *_zzip_restrict b) +{ + if (! a) + return (b) ? 1 : 0; + if (! b) + return -1; + while (1) + { + int v = tolower(*a) - tolower(*b); + if (v) + return v; + if (! *a) + return 1; + if (! *b) + return -1; + a++; + b++; + } +} +#endif + +#endif |