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_read_support_format_tar.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_read_support_format_tar.c')
-rw-r--r-- | lib/libarchive/archive_read_support_format_tar.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/libarchive/archive_read_support_format_tar.c b/lib/libarchive/archive_read_support_format_tar.c index 882d2df..b79140d 100644 --- a/lib/libarchive/archive_read_support_format_tar.c +++ b/lib/libarchive/archive_read_support_format_tar.c @@ -29,11 +29,31 @@ __FBSDID("$FreeBSD$"); #include <sys/stat.h> #include <errno.h> +#include <stddef.h> /* #include <stdint.h> */ /* See archive_platform.h */ #include <stdlib.h> #include <string.h> #include <unistd.h> + +/* Obtain suitable wide-character manipulation functions. */ +#ifdef HAVE_WCHAR_H #include <wchar.h> +#else +static int wcscmp(const wchar_t *s1, const wchar_t *s2) +{ + int diff = *s1 - *s2; + while(*s1 && diff == 0) + diff = (int)*++s1 - (int)*++s2; + return diff; +} +static size_t wcslen(const wchar_t *s) +{ + const wchar_t *p = s; + while (*p) + p++; + return p - s; +} +#endif #include "archive.h" #include "archive_entry.h" @@ -1079,11 +1099,12 @@ pax_header(struct archive *a, struct tar *tar, struct archive_entry *entry, } /* Null-terminate 'key' value. */ - key = tar->pax_entry; + wp = key = tar->pax_entry; if (key[0] == L'=') return (-1); - wp = wcschr(key, L'='); - if (wp == NULL) { + while (*wp && *wp != L'=') + ++wp; + if (*wp == L'\0' || wp == NULL) { archive_set_error(a, ARCHIVE_ERRNO_MISC, "Invalid pax extended attributes"); return (ARCHIVE_WARN); |