1diff -up ./tailor.h ../zip.Apple/tailor.h 2--- ./tailor.h 2008-05-06 21:38:12.000000000 -0700 3+++ ../zip.Apple/tailor.h 2008-09-22 17:24:13.000000000 -0700 4@@ -707,7 +707,11 @@ typedef struct ztimbuf { 5 # define zstat stat 6 # define zfstat fstat 7 # define zlstat lstat 8+#ifdef __APPLE__ 9+# define zfseeko fseeko 10+#else 11 # define zfseeko fseek 12+#endif 13 # define zftello ftell 14 # define zfopen fopen 15 # define zfdopen fdopen 16diff -up ./zip.c ../zip.Apple/zip.c 17--- ./zip.c 2008-07-05 12:34:06.000000000 -0700 18+++ ../zip.Apple/zip.c 2008-09-22 17:24:13.000000000 -0700 19@@ -15,6 +15,7 @@ 20 21 #include "zip.h" 22 #include <time.h> /* for tzset() declaration */ 23+#include <spawn.h> /* posix_spawnp */ 24 #if defined(WIN32) || defined(WINDLL) 25 # define WIN32_LEAN_AND_MEAN 26 # include <windows.h> 27@@ -924,7 +925,7 @@ local void help_extended() 28 " -TT cmd use command cmd instead of 'unzip -tqq' to test archive", 29 " On Unix, to use unzip in current directory, could use:", 30 " zip archive file1 file2 -T -TT \"./unzip -tqq\"", 31-" In cmd, {} replaced by temp archive path, else temp appended.", 32+/*" In cmd, {} replaced by temp archive path, else temp appended.",*/ 33 " The return code is checked for success (0 on Unix)", 34 "", 35 "Fixing archives:", 36@@ -1028,8 +1029,7 @@ local void help_extended() 37 38 for (i = 0; i < sizeof(text)/sizeof(char *); i++) 39 { 40- printf(text[i]); 41- putchar('\n'); 42+ puts(text[i]); 43 } 44 #ifdef DOS 45 check_for_windows("Zip"); 46@@ -1225,8 +1225,7 @@ local void version_info() 47 CR_MAJORVER, CR_MINORVER, CR_BETA_VER, CR_VERSION_DATE); 48 for (i = 0; i < sizeof(cryptnote)/sizeof(char *); i++) 49 { 50- printf(cryptnote[i]); 51- putchar('\n'); 52+ puts(cryptnote[i]); 53 } 54 ++i; /* crypt support means there IS at least one compilation option */ 55 #endif /* CRYPT */ 56@@ -1423,83 +1422,78 @@ local void check_zipfile(zipname, zippat 57 if (status != 0) { 58 59 #else /* (MSDOS && !__GO32__) || __human68k__ */ 60- char *cmd; 61 int result; 62 63 /* Tell picky compilers to shut up about unused variables */ 64 zippath = zippath; 65 66 if (unzip_path) { 67+ char *argv[3]; 68+ int argc = 0; 69+ int rc; 70+ pid_t pid; 71 /* user gave us a path to some unzip (may not be UnZip) */ 72- char *here; 73- int len; 74 75- /* Replace first {} with archive name. If no {} append name to string. */ 76- here = strstr(unzip_path, "{}"); 77- 78- if ((cmd = malloc(strlen(unzip_path) + strlen(zipname) + 3)) == NULL) { 79- ziperr(ZE_MEM, "building command string for testing archive"); 80+ if (strstr(unzip_path, "{}")) { 81+ ziperr(ZE_PARMS, "{} in -TT not supported"); 82 } 83+ argv[argc] = unzip_path; 84+ argc++; 85+ argv[argc] = zipname; 86+ argc++; 87+ argv[argc] = NULL; 88 89- if (here) { 90- /* have {} so replace with temp name */ 91- len = here - unzip_path; 92- strcpy(cmd, unzip_path); 93- cmd[len] = '\0'; 94- strcat(cmd, " "); 95-# ifdef UNIX 96- strcat(cmd, "'"); /* accept space or $ in name */ 97- strcat(cmd, zipname); 98- strcat(cmd, "'"); 99-# else 100- strcat(cmd, zipname); 101-# endif 102- strcat(cmd, " "); 103- strcat(cmd, here + 2); 104- } else { 105- /* No {} so append temp name to end */ 106- strcpy(cmd, unzip_path); 107- strcat(cmd, " "); 108-# ifdef UNIX 109- strcat(cmd, "'"); /* accept space or $ in name */ 110- strcat(cmd, zipname); 111- strcat(cmd, "'"); 112-# else 113- strcat(cmd, zipname); 114-# endif 115- } 116+ rc = posix_spawnp(&pid, argv[0], NULL, NULL, argv, NULL); 117 free(unzip_path); 118 unzip_path = NULL; 119- 120+ if (rc == 0) { 121+ int status; 122+ waitpid(pid, &status, 0); 123+ if (WIFEXITED(status)) 124+ result = WEXITSTATUS(status); 125+ else 126+ result = 1; 127+ } else 128+ result = 1; 129 } else { 130- if ((cmd = malloc(20 + strlen(zipname))) == NULL) { 131- ziperr(ZE_MEM, "building command string for testing archive"); 132- } 133- 134- strcpy(cmd, "unzip -t "); 135+ char *argv[10]; 136+ int argc = 0; 137+ pid_t pid; 138+ int rc; 139+ 140+ argv[argc] = "unzip"; 141+ argc++; 142+ argv[argc] = "-t"; 143+ argc++; 144 # ifdef QDOS 145- strcat(cmd, "-Q4 "); 146+ argv[argc] = "-Q4"; 147+ argc++; 148 # endif 149- if (!verbose) strcat(cmd, "-qq "); 150+ if (!verbose) { 151+ argv[argc] = "-qq"; 152+ argc++; 153+ } 154 if (check_unzip_version("unzip") == 0) 155 ZIPERR(ZE_TEST, zipfile); 156- 157-# ifdef UNIX 158- strcat(cmd, "'"); /* accept space or $ in name */ 159- strcat(cmd, zipname); 160- strcat(cmd, "'"); 161-# else 162- strcat(cmd, zipname); 163-# endif 164+ argv[argc] = zipname; 165+ argc++; 166+ argv[argc] = NULL; 167+ rc = posix_spawnp(&pid, argv[0], NULL, NULL, argv, NULL); 168+ if (rc == 0) { 169+ int status; 170+ waitpid(pid, &status, 0); 171+ if (WIFEXITED(status)) 172+ result = WEXITSTATUS(status); 173+ else 174+ result = 1; 175+ } else 176+ result = 1; 177 } 178 179- result = system(cmd); 180 # ifdef VMS 181 /* Convert success severity to 0, others to non-zero. */ 182 result = ((result & STS$M_SEVERITY) != STS$M_SUCCESS); 183 # endif /* def VMS */ 184- free(cmd); 185- cmd = NULL; 186 if (result) { 187 #endif /* ?((MSDOS && !__GO32__) || __human68k__) */ 188 189@@ -4373,7 +4367,7 @@ char **argv; /* command line 190 z->trash ? "up to date" : "missing or early"); 191 } 192 else if (diff_mode && tf == z->tim && 193- ((isdirname && (zoff_t)usize == -1) || (usize == z->len))) { 194+ ((isdirname && usize == (uzoff_t)~0) || (usize == (uzoff_t)z->len))) { 195 /* if in diff mode only include if file time or size changed */ 196 /* usize is -1 for directories */ 197 z->mark = 0; 198@@ -4381,7 +4375,7 @@ char **argv; /* command line 199 else { 200 /* usize is -1 for directories and -2 for devices */ 201 if (tf == z->tim && 202- ((z->len == 0 && (zoff_t)usize == -1) 203+ ((z->len == 0 && usize == (uzoff_t)~0) 204 || usize == z->len)) { 205 /* FileSync uses the current flag */ 206 /* Consider an entry current if file time is the same 207@@ -4993,7 +4987,7 @@ char **argv; /* command line 208 if (z->mark == 1) 209 { 210 uzoff_t len; 211- if ((zoff_t)z->len == -1) 212+ if (z->len == (uzoff_t)~0) 213 /* device */ 214 len = 0; 215 else 216 217