diff options
author | kientzle <kientzle@FreeBSD.org> | 2005-09-10 22:58:06 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2005-09-10 22:58:06 +0000 |
commit | 9d88c7f7b7004dffafb8e7e5d1d098ed506b015a (patch) | |
tree | 2f58e10266a64d70146a7581d052bf09013f4457 /lib/libarchive/archive_entry.c | |
parent | 70f9da67193dd6865f9791384929a04b50f95003 (diff) | |
download | FreeBSD-src-9d88c7f7b7004dffafb8e7e5d1d098ed506b015a.zip FreeBSD-src-9d88c7f7b7004dffafb8e7e5d1d098ed506b015a.tar.gz |
Style issue: Don't include <wchar.h> where it is not actually needed.
(wchar_t is defined in stddef.h, and only two files need more than that.)
Portability: Since the wchar requirements are really quite modest,
it's easy to define basic replacements for wcslen, wcscmp, wcscpy,
etc, for use on systems that lack <wchar.h>. In particular, this allows
libarchive to be used on older OpenBSD systems.
Diffstat (limited to 'lib/libarchive/archive_entry.c')
-rw-r--r-- | lib/libarchive/archive_entry.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/libarchive/archive_entry.c b/lib/libarchive/archive_entry.c index a3919e5..742a232 100644 --- a/lib/libarchive/archive_entry.c +++ b/lib/libarchive/archive_entry.c @@ -33,11 +33,33 @@ __FBSDID("$FreeBSD$"); #include <ext2fs/ext2_fs.h> /* for Linux file flags */ #endif #include <limits.h> +#include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <wchar.h> +/* Obtain suitable wide-character manipulation functions. */ +#ifdef HAVE_WCHAR_H +#include <wchar.h> +#else +static size_t wcslen(const wchar_t *s) +{ + const wchar_t *p = s; + while (*p != L'\0') + ++p; + return p - s; +} +static wchar_t * wcscpy(wchar_t *s1, const wchar_t *s2) +{ + wchar_t *dest = s1; + while((*s1 = *s2) != L'\0') + ++s1, ++s2; + return dest; +} +#define wmemcpy(a,b,i) (wchar_t *)memcpy((a),(b),(i)*sizeof(wchar_t)) +/* Good enough for simple equality testing, but not for sorting. */ +#define wmemcmp(a,b,i) memcmp((a),(b),(i)*sizeof(wchar_t)) +#endif #include "archive.h" #include "archive_entry.h" |