[c5c522c] | 1 | diff -Nur pax-3.3-doc/src/ar_io.c pax-3.3-gcc/src/ar_io.c |
---|
| 2 | --- pax-3.3-doc/src/ar_io.c 2003-02-03 19:06:42.000000000 +1000 |
---|
| 3 | +++ pax-3.3-gcc/src/ar_io.c 2003-04-22 15:15:50.000000000 +1000 |
---|
| 4 | @@ -388,11 +388,7 @@ |
---|
| 5 | * could have written anything yet. |
---|
| 6 | */ |
---|
| 7 | if (frmt == NULL) { |
---|
| 8 | -# ifdef LONG_OFF_T |
---|
| 9 | - (void)fprintf(listf, "%s: unknown format, %lu bytes skipped.\n", |
---|
| 10 | -# else |
---|
| 11 | - (void)fprintf(listf, "%s: unknown format, %qu bytes skipped.\n", |
---|
| 12 | -# endif |
---|
| 13 | + (void)fprintf(listf, "%s: unknown format, %" FMT_OFF "u bytes skipped.\n", |
---|
| 14 | argv0, rdcnt); |
---|
| 15 | (void)fflush(listf); |
---|
| 16 | flcnt = 0; |
---|
| 17 | @@ -400,14 +396,10 @@ |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | if (strcmp(NM_CPIO, argv0) == 0) |
---|
| 21 | - (void)fprintf(listf, "%qu blocks\n", (rdcnt ? rdcnt : wrcnt) / 5120); |
---|
| 22 | + (void)fprintf(listf, "%" FMT_OFF "u blocks\n", (rdcnt ? rdcnt : wrcnt) / 5120); |
---|
| 23 | else if (strcmp(NM_TAR, argv0) != 0) |
---|
| 24 | (void)fprintf(listf, |
---|
| 25 | -# ifdef LONG_OFF_T |
---|
| 26 | - "%s: %s vol %d, %lu files, %lu bytes read, %lu bytes written.\n", |
---|
| 27 | -# else |
---|
| 28 | - "%s: %s vol %d, %lu files, %qu bytes read, %qu bytes written.\n", |
---|
| 29 | -# endif |
---|
| 30 | + "%s: %s vol %d, %lu files, %" FMT_OFF "u bytes read, %" FMT_OFF "u bytes written.\n", |
---|
| 31 | argv0, frmt->name, arvol-1, flcnt, rdcnt, wrcnt); |
---|
| 32 | (void)fflush(listf); |
---|
| 33 | flcnt = 0; |
---|
| 34 | diff -Nur pax-3.3-doc/src/ar_subs.c pax-3.3-gcc/src/ar_subs.c |
---|
| 35 | --- pax-3.3-doc/src/ar_subs.c 2003-02-03 19:06:43.000000000 +1000 |
---|
| 36 | +++ pax-3.3-gcc/src/ar_subs.c 2003-04-22 15:15:50.000000000 +1000 |
---|
| 37 | @@ -57,6 +57,7 @@ |
---|
| 38 | #include <errno.h> |
---|
| 39 | #include <unistd.h> |
---|
| 40 | #include <stdlib.h> |
---|
| 41 | +#include <time.h> |
---|
| 42 | #include "pax.h" |
---|
| 43 | #include "extern.h" |
---|
| 44 | |
---|
| 45 | diff -Nur pax-3.3-doc/src/cpio.c pax-3.3-gcc/src/cpio.c |
---|
| 46 | --- pax-3.3-doc/src/cpio.c 2003-02-03 19:06:43.000000000 +1000 |
---|
| 47 | +++ pax-3.3-gcc/src/cpio.c 2003-04-22 15:15:50.000000000 +1000 |
---|
| 48 | @@ -223,13 +223,8 @@ |
---|
| 49 | */ |
---|
| 50 | if ((arcn->sb.st_size == 0) || |
---|
| 51 | (arcn->sb.st_size >= sizeof(arcn->ln_name))) { |
---|
| 52 | -# ifdef LONG_OFF_T |
---|
| 53 | - paxwarn(1, "Cpio link name length is invalid: %lu", |
---|
| 54 | - arcn->sb.st_size); |
---|
| 55 | -# else |
---|
| 56 | - paxwarn(1, "Cpio link name length is invalid: %qu", |
---|
| 57 | + paxwarn(1, "Cpio link name length is invalid: %" FMT_OFF "u", |
---|
| 58 | arcn->sb.st_size); |
---|
| 59 | -# endif |
---|
| 60 | return(-1); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | diff -Nur pax-3.3-doc/src/extern.h pax-3.3-gcc/src/extern.h |
---|
| 64 | --- pax-3.3-doc/src/extern.h 2002-10-19 01:38:11.000000000 +1000 |
---|
| 65 | +++ pax-3.3-gcc/src/extern.h 2003-04-22 15:15:50.000000000 +1000 |
---|
| 66 | @@ -302,3 +302,12 @@ |
---|
| 67 | int tty_read(char *, int); |
---|
| 68 | void paxwarn(int, const char *, ...); |
---|
| 69 | void syswarn(int, int, const char *, ...); |
---|
| 70 | + |
---|
| 71 | +/* |
---|
| 72 | + * Handle printing of offsets. |
---|
| 73 | + */ |
---|
| 74 | +#ifdef LONG_OFF_T |
---|
| 75 | +#define FMT_OFF "l" |
---|
| 76 | +#else |
---|
| 77 | +#define FMT_OFF "q" |
---|
| 78 | +#endif |
---|
| 79 | diff -Nur pax-3.3-doc/src/gen_subs.c pax-3.3-gcc/src/gen_subs.c |
---|
| 80 | --- pax-3.3-doc/src/gen_subs.c 2002-10-17 05:20:02.000000000 +1000 |
---|
| 81 | +++ pax-3.3-gcc/src/gen_subs.c 2003-04-22 15:15:50.000000000 +1000 |
---|
| 82 | @@ -56,6 +56,7 @@ |
---|
| 83 | #include <unistd.h> |
---|
| 84 | #include <stdlib.h> |
---|
| 85 | #include <string.h> |
---|
| 86 | +#include <time.h> |
---|
| 87 | #include <vis.h> |
---|
| 88 | #include "pax.h" |
---|
| 89 | #include "extern.h" |
---|
| 90 | @@ -128,19 +129,11 @@ |
---|
| 91 | * print device id's for devices, or sizes for other nodes |
---|
| 92 | */ |
---|
| 93 | if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK)) |
---|
| 94 | -# ifdef LONG_OFF_T |
---|
| 95 | - (void)fprintf(fp, "%4u,%4u ", MAJOR(sbp->st_rdev), |
---|
| 96 | -# else |
---|
| 97 | - (void)fprintf(fp, "%4lu,%4lu ", (unsigned long)MAJOR(sbp->st_rdev), |
---|
| 98 | -# endif |
---|
| 99 | + (void)fprintf(fp, "%4lu,%4lu ", |
---|
| 100 | + (unsigned long)MAJOR(sbp->st_rdev), |
---|
| 101 | (unsigned long)MINOR(sbp->st_rdev)); |
---|
| 102 | - else { |
---|
| 103 | -# ifdef LONG_OFF_T |
---|
| 104 | - (void)fprintf(fp, "%9lu ", sbp->st_size); |
---|
| 105 | -# else |
---|
| 106 | - (void)fprintf(fp, "%9qu ", sbp->st_size); |
---|
| 107 | -# endif |
---|
| 108 | - } |
---|
| 109 | + else |
---|
| 110 | + (void)fprintf(fp, "%9" FMT_OFF "u ", sbp->st_size); |
---|
| 111 | |
---|
| 112 | /* |
---|
| 113 | * print name and link info for hard and soft links |
---|
| 114 | diff -Nur pax-3.3-doc/src/options.c pax-3.3-gcc/src/options.c |
---|
| 115 | --- pax-3.3-doc/src/options.c 2003-02-03 19:06:43.000000000 +1000 |
---|
| 116 | +++ pax-3.3-gcc/src/options.c 2003-04-22 15:15:50.000000000 +1000 |
---|
| 117 | @@ -76,7 +76,7 @@ |
---|
| 118 | static void printflg(unsigned int); |
---|
| 119 | static int c_frmt(const void *, const void *); |
---|
| 120 | static off_t str_offt(char *); |
---|
| 121 | -static char *getline(FILE *fp); |
---|
| 122 | +static char *getln(FILE *fp); |
---|
| 123 | static void pax_options(int, char **); |
---|
| 124 | static void pax_usage(void); |
---|
| 125 | static void tar_options(int, char **); |
---|
| 126 | @@ -87,7 +87,7 @@ |
---|
| 127 | /* errors from getline */ |
---|
| 128 | #define GETLINE_FILE_CORRUPT 1 |
---|
| 129 | #define GETLINE_OUT_OF_MEM 2 |
---|
| 130 | -static int getline_error; |
---|
| 131 | +static int getln_error; |
---|
| 132 | |
---|
| 133 | |
---|
| 134 | #define GZIP_CMD "gzip" /* command to run as gzip */ |
---|
| 135 | @@ -520,6 +520,7 @@ |
---|
| 136 | * or list. check that we have not been given a bogus set of flags |
---|
| 137 | * for the operation mode. |
---|
| 138 | */ |
---|
| 139 | + listf = stderr; |
---|
| 140 | if (ISLIST(flg)) { |
---|
| 141 | act = LIST; |
---|
| 142 | listf = stdout; |
---|
| 143 | @@ -870,14 +871,14 @@ |
---|
| 144 | paxwarn(1, "Unable to open file '%s' for read", file); |
---|
| 145 | tar_usage(); |
---|
| 146 | } |
---|
| 147 | - while ((str = getline(fp)) != NULL) { |
---|
| 148 | + while ((str = getln(fp)) != NULL) { |
---|
| 149 | if (pat_add(str, dir) < 0) |
---|
| 150 | tar_usage(); |
---|
| 151 | sawpat = 1; |
---|
| 152 | } |
---|
| 153 | if (strcmp(file, "-") != 0) |
---|
| 154 | fclose(fp); |
---|
| 155 | - if (getline_error) { |
---|
| 156 | + if (getln_error) { |
---|
| 157 | paxwarn(1, "Problem with file '%s'", file); |
---|
| 158 | tar_usage(); |
---|
| 159 | } |
---|
| 160 | @@ -943,13 +944,13 @@ |
---|
| 161 | paxwarn(1, "Unable to open file '%s' for read", file); |
---|
| 162 | tar_usage(); |
---|
| 163 | } |
---|
| 164 | - while ((str = getline(fp)) != NULL) { |
---|
| 165 | + while ((str = getln(fp)) != NULL) { |
---|
| 166 | if (ftree_add(str, 0) < 0) |
---|
| 167 | tar_usage(); |
---|
| 168 | } |
---|
| 169 | if (strcmp(file, "-") != 0) |
---|
| 170 | fclose(fp); |
---|
| 171 | - if (getline_error) { |
---|
| 172 | + if (getln_error) { |
---|
| 173 | paxwarn(1, "Problem with file '%s'", |
---|
| 174 | file); |
---|
| 175 | tar_usage(); |
---|
| 176 | @@ -1030,6 +1031,7 @@ |
---|
| 177 | dflag = 1; |
---|
| 178 | act = -1; |
---|
| 179 | nodirs = 1; |
---|
| 180 | + listf = stderr; |
---|
| 181 | while ((c=getopt(argc,argv,"abcdfiklmoprstuvzABC:E:F:H:I:LO:SZ6")) != -1) |
---|
| 182 | switch (c) { |
---|
| 183 | case 'a': |
---|
| 184 | @@ -1156,11 +1158,11 @@ |
---|
| 185 | paxwarn(1, "Unable to open file '%s' for read", optarg); |
---|
| 186 | cpio_usage(); |
---|
| 187 | } |
---|
| 188 | - while ((str = getline(fp)) != NULL) { |
---|
| 189 | + while ((str = getln(fp)) != NULL) { |
---|
| 190 | pat_add(str, NULL); |
---|
| 191 | } |
---|
| 192 | fclose(fp); |
---|
| 193 | - if (getline_error) { |
---|
| 194 | + if (getln_error) { |
---|
| 195 | paxwarn(1, "Problem with file '%s'", optarg); |
---|
| 196 | cpio_usage(); |
---|
| 197 | } |
---|
| 198 | @@ -1255,10 +1257,10 @@ |
---|
| 199 | * no read errors allowed on updates/append operation! |
---|
| 200 | */ |
---|
| 201 | maxflt = 0; |
---|
| 202 | - while ((str = getline(stdin)) != NULL) { |
---|
| 203 | + while ((str = getln(stdin)) != NULL) { |
---|
| 204 | ftree_add(str, NULL); |
---|
| 205 | } |
---|
| 206 | - if (getline_error) { |
---|
| 207 | + if (getln_error) { |
---|
| 208 | paxwarn(1, "Problem while reading stdin"); |
---|
| 209 | cpio_usage(); |
---|
| 210 | } |
---|
| 211 | @@ -1483,29 +1485,40 @@ |
---|
| 212 | return(num); |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | +/* |
---|
| 216 | + * getln() |
---|
| 217 | + * read a line and return it in a malloc'ed buffer. |
---|
| 218 | + * |
---|
| 219 | + * In pax 3.0 this was called my_getline(). somewhere |
---|
| 220 | + * between 3.0 and 3.3 it was replaced with a function |
---|
| 221 | + * called getline() that did the same thing as my_getline() |
---|
| 222 | + * but used fgetln(). fgetln() is not a GNU function - its |
---|
| 223 | + * only available on BSD, and that made life difficult. |
---|
| 224 | + * Very difficult in fact, as the easiy way to emulate |
---|
| 225 | + * fgetln() is to use the GNU getline() function, buts its |
---|
| 226 | + * name clashed with the one defined here. This third |
---|
| 227 | + * re-write is shorter and faster than the previous two, |
---|
| 228 | + * and is compatible with GNU libc. |
---|
| 229 | + */ |
---|
| 230 | char * |
---|
| 231 | -getline(FILE *f) |
---|
| 232 | +getln(FILE * f) |
---|
| 233 | { |
---|
| 234 | - char *name, *temp; |
---|
| 235 | + char *name = 0; |
---|
| 236 | + size_t buflen = 0; |
---|
| 237 | size_t len; |
---|
| 238 | |
---|
| 239 | - name = fgetln(f, &len); |
---|
| 240 | - if (!name) { |
---|
| 241 | - getline_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0; |
---|
| 242 | + len = getline(&name, &buflen, f); |
---|
| 243 | + if (len == (size_t)-1) { |
---|
| 244 | + if (name) |
---|
| 245 | + free(name); |
---|
| 246 | + getln_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0; |
---|
| 247 | return(0); |
---|
| 248 | } |
---|
| 249 | - if (name[len-1] != '\n') |
---|
| 250 | - len++; |
---|
| 251 | - temp = malloc(len); |
---|
| 252 | - if (!temp) { |
---|
| 253 | - getline_error = GETLINE_OUT_OF_MEM; |
---|
| 254 | - return(0); |
---|
| 255 | - } |
---|
| 256 | - memcpy(temp, name, len-1); |
---|
| 257 | - temp[len-1] = 0; |
---|
| 258 | - return(temp); |
---|
| 259 | + if (name[len - 1] == '\n') |
---|
| 260 | + name[len - 1] = '\0'; |
---|
| 261 | + return name; |
---|
| 262 | } |
---|
| 263 | - |
---|
| 264 | + |
---|
| 265 | /* |
---|
| 266 | * no_op() |
---|
| 267 | * for those option functions where the archive format has nothing to do. |
---|
| 268 | diff -Nur pax-3.3-doc/src/pax.c pax-3.3-gcc/src/pax.c |
---|
| 269 | --- pax-3.3-doc/src/pax.c 2002-10-17 05:20:02.000000000 +1000 |
---|
| 270 | +++ pax-3.3-gcc/src/pax.c 2003-04-22 15:15:50.000000000 +1000 |
---|
| 271 | @@ -108,7 +108,7 @@ |
---|
| 272 | char *ltmfrmt; /* -v locale time format (if any) */ |
---|
| 273 | char *argv0; /* root of argv[0] */ |
---|
| 274 | sigset_t s_mask; /* signal mask for cleanup critical sect */ |
---|
| 275 | -FILE *listf = stderr; /* file pointer to print file list to */ |
---|
| 276 | +FILE *listf; /* file pointer to print file list to */ |
---|
| 277 | char *tempfile; /* tempfile to use for mkstemp(3) */ |
---|
| 278 | char *tempbase; /* basename of tempfile to use for mkstemp(3) */ |
---|
| 279 | |
---|
| 280 | diff -Nur pax-3.3-doc/src/sel_subs.c pax-3.3-gcc/src/sel_subs.c |
---|
| 281 | --- pax-3.3-doc/src/sel_subs.c 2002-10-17 05:20:02.000000000 +1000 |
---|
| 282 | +++ pax-3.3-gcc/src/sel_subs.c 2003-04-22 15:15:50.000000000 +1000 |
---|
| 283 | @@ -56,6 +56,7 @@ |
---|
| 284 | #include <stdio.h> |
---|
| 285 | #include <stdlib.h> |
---|
| 286 | #include <string.h> |
---|
| 287 | +#include <time.h> |
---|
| 288 | #include <tzfile.h> |
---|
| 289 | #include <unistd.h> |
---|
| 290 | #include "pax.h" |
---|