summaryrefslogtreecommitdiffstats
path: root/lib/libarchive
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2004-03-20 22:35:33 +0000
committerkientzle <kientzle@FreeBSD.org>2004-03-20 22:35:33 +0000
commitbbabca3fda32c4fe375a96dd6a484df6c4ee27da (patch)
tree515bcd93ff68d5ca69c220a9a522bbf98501a663 /lib/libarchive
parentb4abefb315f13813640f3ee4738e718eece44e45 (diff)
downloadFreeBSD-src-bbabca3fda32c4fe375a96dd6a484df6c4ee27da.zip
FreeBSD-src-bbabca3fda32c4fe375a96dd6a484df6c4ee27da.tar.gz
Bug: Standard C still requires declarations to precede statements. <sigh>
Portability: Eliminate an accidental __unused, accomodate systems with non-POSIX strerror_r
Diffstat (limited to 'lib/libarchive')
-rw-r--r--lib/libarchive/archive_platform.h2
-rw-r--r--lib/libarchive/archive_read_support_format_tar.c12
-rw-r--r--lib/libarchive/archive_util.c11
3 files changed, 17 insertions, 8 deletions
diff --git a/lib/libarchive/archive_platform.h b/lib/libarchive/archive_platform.h
index ee6c08e..0f651e8 100644
--- a/lib/libarchive/archive_platform.h
+++ b/lib/libarchive/archive_platform.h
@@ -49,6 +49,7 @@
#define HAVE_CHFLAGS 1
#define HAVE_LUTIMES 1
#define HAVE_LCHMOD 1
+#define HAVE_POSIX_STRERROR_R 1
#define ARCHIVE_ERRNO_FILE_FORMAT EFTYPE
#define ARCHIVE_ERRNO_PROGRAMMER EINVAL
#define ARCHIVE_ERRNO_MISC (-1)
@@ -85,6 +86,7 @@
#define st_atimespec st_atim
#define st_mtimespec st_mtim
#define st_ctimespec st_ctim
+#define HAVE_GLIBC_STRERROR_R 1
#endif
/*
diff --git a/lib/libarchive/archive_read_support_format_tar.c b/lib/libarchive/archive_read_support_format_tar.c
index 24c7f42..47bfc55 100644
--- a/lib/libarchive/archive_read_support_format_tar.c
+++ b/lib/libarchive/archive_read_support_format_tar.c
@@ -81,9 +81,7 @@ struct tar {
int header_recursion_depth;
};
-static size_t UTF8_mbrtowc(wchar_t * __restrict pwc,
- const char * __restrict s, size_t n,
- mbstate_t * __restrict ps __unused);
+static size_t UTF8_mbrtowc(wchar_t *pwc, const char *s, size_t n);
static int archive_block_is_null(const unsigned char *p);
static int header_Solaris_ACL(struct archive *, struct tar *,
struct archive_entry *, struct stat *, const void *);
@@ -640,9 +638,10 @@ static int
header_pax_extensions(struct archive *a, struct tar *tar,
struct archive_entry *entry, struct stat *st, const void *h)
{
- read_body_to_string(a, &(tar->pax_header), h);
int err, err2;
+ read_body_to_string(a, &(tar->pax_header), h);
+
/* Parse the next header. */
err = tar_read_header(a, tar, entry, st);
@@ -1085,7 +1084,7 @@ utf8_decode(wchar_t *dest, const char *src, size_t length)
err = 0;
while(length > 0) {
- n = UTF8_mbrtowc(dest, src, length, NULL);
+ n = UTF8_mbrtowc(dest, src, length);
if (n == 0)
break;
if (n > 8) {
@@ -1106,8 +1105,7 @@ utf8_decode(wchar_t *dest, const char *src, size_t length)
* Copied from FreeBSD libc/locale.
*/
static size_t
-UTF8_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n,
- mbstate_t * __restrict ps __unused)
+UTF8_mbrtowc(wchar_t *pwc, const char *s, size_t n)
{
int ch, i, len, mask;
wchar_t lbound, wch;
diff --git a/lib/libarchive/archive_util.c b/lib/libarchive/archive_util.c
index 587e8af..11d151a 100644
--- a/lib/libarchive/archive_util.c
+++ b/lib/libarchive/archive_util.c
@@ -84,6 +84,7 @@ archive_set_error(struct archive *a, int error_number, const char *fmt, ...)
{
va_list ap;
char errbuff[512];
+ char *errp;
a->archive_error_number = error_number;
if (fmt == NULL) {
@@ -95,8 +96,16 @@ archive_set_error(struct archive *a, int error_number, const char *fmt, ...)
archive_string_vsprintf(&(a->error_string), fmt, ap);
if(error_number > 0) {
archive_strcat(&(a->error_string), ": ");
+#if defined(HAVE_GLIBC_STRERROR_R)
+ errp = strerror_r(error_number, errbuff, sizeof(errbuff));
+#elif defined(HAVE_POSIX_STRERROR_R)
strerror_r(error_number, errbuff, sizeof(errbuff));
- archive_strcat(&(a->error_string), errbuff);
+ errp = errbuff;
+#else
+ /* Note: this is not threadsafe! */
+ errp = strerror(error_number);
+#endif
+ archive_strcat(&(a->error_string), errp);
}
a->error = a->error_string.s;
va_end(ap);
OpenPOWER on IntegriCloud