From 908bb5b39f71fc3f209bc05750b6f61245792169 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Wed, 12 Mar 2014 07:32:22 +0100 Subject: [PATCH] fixes to build by Open Watcom toolchain --- libarchive/archive_windows.h | 8 +++++++- libarchive/archive_write_set_format_zip.c | 6 +++--- libarchive/test/main.c | 2 +- libarchive/test/test_write_format_zip_large.c | 6 +++--- tar/bsdtar_windows.h | 4 ++++ tar/test/main.c | 2 +- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/libarchive/archive_windows.h b/libarchive/archive_windows.h index 6e9277e97..63947c8c4 100644 --- a/libarchive/archive_windows.h +++ b/libarchive/archive_windows.h @@ -109,13 +109,14 @@ #define lstat __la_stat #define open __la_open #define read __la_read -#if !defined(__BORLANDC__) +#if !defined(__BORLANDC__) && !defined(__WATCOMC__) #define setmode _setmode #endif #ifdef stat #undef stat #endif #define stat(path,stref) __la_stat(path,stref) +#if !defined(__WATCOMC__) #if !defined(__BORLANDC__) #define strdup _strdup #endif @@ -123,9 +124,12 @@ #if !defined(__BORLANDC__) #define umask _umask #endif +#endif #define waitpid __la_waitpid #define write __la_write +#if !defined(__WATCOMC__) + #ifndef O_RDONLY #define O_RDONLY _O_RDONLY #define O_WRONLY _O_WRONLY @@ -223,6 +227,8 @@ #define S_IWOTH _S_IWOTH #define S_IROTH _S_IROTH +#endif + #define F_DUPFD 0 /* Duplicate file descriptor. */ #define F_GETFD 1 /* Get file descriptor flags. */ #define F_SETFD 2 /* Set file descriptor flags. */ diff --git a/libarchive/archive_write_set_format_zip.c b/libarchive/archive_write_set_format_zip.c index 3fcd558f6..ccd50ea90 100644 --- a/libarchive/archive_write_set_format_zip.c +++ b/libarchive/archive_write_set_format_zip.c @@ -622,9 +622,9 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) /* Following Info-Zip, store mode in the "external attributes" field. */ archive_le32enc(zip->file_header + 38, archive_entry_mode(zip->entry) << 16); - unsigned char *fn = cd_alloc(zip, filename_length); - /* If (fn == NULL) XXXX */ - copy_path(zip->entry, fn); + e = cd_alloc(zip, filename_length); + /* If (e == NULL) XXXX */ + copy_path(zip->entry, e); /* Format extra data. */ memset(local_extra, 0, sizeof(local_extra)); diff --git a/libarchive/test/main.c b/libarchive/test/main.c index aa64dfb74..f3567d982 100644 --- a/libarchive/test/main.c +++ b/libarchive/test/main.c @@ -2557,7 +2557,7 @@ main(int argc, char **argv) while (pwd[strlen(pwd) - 1] == '\n') pwd[strlen(pwd) - 1] = '\0'; -#if defined(HAVE__CrtSetReportMode) +#if defined(HAVE__CrtSetReportMode) && !defined(__WATCOMC__) /* To stop to run the default invalid parameter handler. */ _set_invalid_parameter_handler(invalid_parameter_handler); /* Disable annoying assertion message box. */ diff --git a/libarchive/test/test_write_format_zip_large.c b/libarchive/test/test_write_format_zip_large.c index d302e5e8a..e8a8b0ea3 100644 --- a/libarchive/test/test_write_format_zip_large.c +++ b/libarchive/test/test_write_format_zip_large.c @@ -121,8 +121,8 @@ memory_read(struct archive *a, void *_private, const void **buff) /* If there's real data, return that. */ if (private->buff != NULL) { *buff = private->buff; - size = (private->current->buff + private->current->size) - - private->buff; + size = ((char *)private->current->buff + private->current->size) + - (char *)private->buff; private->buff = NULL; private->fileposition += size; return (size); @@ -199,7 +199,7 @@ memory_read_seek(struct archive *a, void *_private, int64_t offset, int whence) while (private->current != NULL) { if (offset + private->current->size > private->fileposition) { /* Position is in this block. */ - private->buff = private->current->buff + private->buff = (char *)private->current->buff + private->fileposition - offset; private->gap_remaining = private->current->gap_size; return private->fileposition; diff --git a/tar/bsdtar_windows.h b/tar/bsdtar_windows.h index f0611d79a..f025d056f 100644 --- a/tar/bsdtar_windows.h +++ b/tar/bsdtar_windows.h @@ -35,6 +35,8 @@ #endif #define geteuid() 0 +#ifndef __WATCOMC__ + #ifndef S_IFIFO #define S_IFIFO 0010000 /* pipe */ #endif @@ -57,4 +59,6 @@ int __tar_chdir(const char *); #define S_ISBLK(a) (0) #endif +#endif + #endif /* BSDTAR_WINDOWS_H */ diff --git a/tar/test/main.c b/tar/test/main.c index f2dcaf4ae..face5ca36 100644 --- a/tar/test/main.c +++ b/tar/test/main.c @@ -2516,7 +2516,7 @@ main(int argc, char **argv) while (pwd[strlen(pwd) - 1] == '\n') pwd[strlen(pwd) - 1] = '\0'; -#if defined(HAVE__CrtSetReportMode) +#if defined(HAVE__CrtSetReportMode) && !defined(__WATCOMC__) /* To stop to run the default invalid parameter handler. */ _set_invalid_parameter_handler(invalid_parameter_handler); /* Disable annoying assertion message box. */ -- 2.47.2