Bug: Standard C still requires declarations to precede statements. <sigh>
Portability: Eliminate an accidental __unused, accomodate systems with non-POSIX strerror_r
This commit is contained in:
parent
ad452e6553
commit
e5b478f765
@ -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
|
||||
|
||||
/*
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user