source: npl/overig/archivetools/pax/pax-3.3-gcc.patch @ 5747ef0

Last change on this file since 5747ef0 was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 8.6 KB
  • src/ar_io.c

    diff -Nur pax-3.3-doc/src/ar_io.c pax-3.3-gcc/src/ar_io.c
    old new  
    388388         * could have written anything yet.
    389389         */
    390390        if (frmt == NULL) {
    391 #       ifdef LONG_OFF_T
    392                 (void)fprintf(listf, "%s: unknown format, %lu bytes skipped.\n",
    393 #       else
    394                 (void)fprintf(listf, "%s: unknown format, %qu bytes skipped.\n",
    395 #       endif
     391                (void)fprintf(listf, "%s: unknown format, %" FMT_OFF "u bytes skipped.\n",
    396392                    argv0, rdcnt);
    397393                (void)fflush(listf);
    398394                flcnt = 0;
     
    400396        }
    401397
    402398        if (strcmp(NM_CPIO, argv0) == 0)
    403                 (void)fprintf(listf, "%qu blocks\n", (rdcnt ? rdcnt : wrcnt) / 5120);
     399                (void)fprintf(listf, "%" FMT_OFF "u blocks\n", (rdcnt ? rdcnt : wrcnt) / 5120);
    404400        else if (strcmp(NM_TAR, argv0) != 0)
    405401                (void)fprintf(listf,
    406 #       ifdef LONG_OFF_T
    407                     "%s: %s vol %d, %lu files, %lu bytes read, %lu bytes written.\n",
    408 #       else
    409                     "%s: %s vol %d, %lu files, %qu bytes read, %qu bytes written.\n",
    410 #       endif
     402                    "%s: %s vol %d, %lu files, %" FMT_OFF "u bytes read, %" FMT_OFF "u bytes written.\n",
    411403                    argv0, frmt->name, arvol-1, flcnt, rdcnt, wrcnt);
    412404        (void)fflush(listf);
    413405        flcnt = 0;
  • src/ar_subs.c

    diff -Nur pax-3.3-doc/src/ar_subs.c pax-3.3-gcc/src/ar_subs.c
    old new  
    5757#include <errno.h>
    5858#include <unistd.h>
    5959#include <stdlib.h>
     60#include <time.h>
    6061#include "pax.h"
    6162#include "extern.h"
    6263
  • src/cpio.c

    diff -Nur pax-3.3-doc/src/cpio.c pax-3.3-gcc/src/cpio.c
    old new  
    223223         */
    224224        if ((arcn->sb.st_size == 0) ||
    225225            (arcn->sb.st_size >= sizeof(arcn->ln_name))) {
    226 #               ifdef LONG_OFF_T
    227                 paxwarn(1, "Cpio link name length is invalid: %lu",
    228                     arcn->sb.st_size);
    229 #               else
    230                 paxwarn(1, "Cpio link name length is invalid: %qu",
     226                paxwarn(1, "Cpio link name length is invalid: %" FMT_OFF "u",
    231227                    arcn->sb.st_size);
    232 #               endif
    233228                return(-1);
    234229        }
    235230
  • src/extern.h

    diff -Nur pax-3.3-doc/src/extern.h pax-3.3-gcc/src/extern.h
    old new  
    302302int tty_read(char *, int);
    303303void paxwarn(int, const char *, ...);
    304304void syswarn(int, int, const char *, ...);
     305
     306/*
     307 * Handle printing of offsets.
     308 */
     309#ifdef  LONG_OFF_T
     310#define FMT_OFF "l"
     311#else
     312#define FMT_OFF "q"
     313#endif
  • src/gen_subs.c

    diff -Nur pax-3.3-doc/src/gen_subs.c pax-3.3-gcc/src/gen_subs.c
    old new  
    5656#include <unistd.h>
    5757#include <stdlib.h>
    5858#include <string.h>
     59#include <time.h>
    5960#include <vis.h>
    6061#include "pax.h"
    6162#include "extern.h"
     
    128129         * print device id's for devices, or sizes for other nodes
    129130         */
    130131        if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK))
    131 #               ifdef LONG_OFF_T
    132                 (void)fprintf(fp, "%4u,%4u ", MAJOR(sbp->st_rdev),
    133 #               else
    134                 (void)fprintf(fp, "%4lu,%4lu ", (unsigned long)MAJOR(sbp->st_rdev),
    135 #               endif
     132                (void)fprintf(fp, "%4lu,%4lu ",
     133                    (unsigned long)MAJOR(sbp->st_rdev),
    136134                    (unsigned long)MINOR(sbp->st_rdev));
    137         else {
    138 #               ifdef LONG_OFF_T
    139                 (void)fprintf(fp, "%9lu ", sbp->st_size);
    140 #               else
    141                 (void)fprintf(fp, "%9qu ", sbp->st_size);
    142 #               endif
    143         }
     135        else
     136                (void)fprintf(fp, "%9" FMT_OFF "u ", sbp->st_size);
    144137
    145138        /*
    146139         * print name and link info for hard and soft links
  • src/options.c

    diff -Nur pax-3.3-doc/src/options.c pax-3.3-gcc/src/options.c
    old new  
    7676static void printflg(unsigned int);
    7777static int c_frmt(const void *, const void *);
    7878static off_t str_offt(char *);
    79 static char *getline(FILE *fp);
     79static char *getln(FILE *fp);
    8080static void pax_options(int, char **);
    8181static void pax_usage(void);
    8282static void tar_options(int, char **);
     
    8787/* errors from getline */
    8888#define GETLINE_FILE_CORRUPT 1
    8989#define GETLINE_OUT_OF_MEM 2
    90 static int getline_error;
     90static int getln_error;
    9191
    9292
    9393#define GZIP_CMD        "gzip"          /* command to run as gzip */
     
    520520         * or list. check that we have not been given a bogus set of flags
    521521         * for the operation mode.
    522522         */
     523        listf = stderr;
    523524        if (ISLIST(flg)) {
    524525                act = LIST;
    525526                listf = stdout;
     
    870871                                                paxwarn(1, "Unable to open file '%s' for read", file);
    871872                                                tar_usage();
    872873                                        }
    873                                         while ((str = getline(fp)) != NULL) {
     874                                        while ((str = getln(fp)) != NULL) {
    874875                                                if (pat_add(str, dir) < 0)
    875876                                                        tar_usage();
    876877                                                sawpat = 1;
    877878                                        }
    878879                                        if (strcmp(file, "-") != 0)
    879880                                                fclose(fp);
    880                                         if (getline_error) {
     881                                        if (getln_error) {
    881882                                                paxwarn(1, "Problem with file '%s'", file);
    882883                                                tar_usage();
    883884                                        }
     
    943944                                        paxwarn(1, "Unable to open file '%s' for read", file);
    944945                                        tar_usage();
    945946                                }
    946                                 while ((str = getline(fp)) != NULL) {
     947                                while ((str = getln(fp)) != NULL) {
    947948                                        if (ftree_add(str, 0) < 0)
    948949                                                tar_usage();
    949950                                }
    950951                                if (strcmp(file, "-") != 0)
    951952                                        fclose(fp);
    952                                 if (getline_error) {
     953                                if (getln_error) {
    953954                                        paxwarn(1, "Problem with file '%s'",
    954955                                            file);
    955956                                        tar_usage();
     
    10301031        dflag = 1;
    10311032        act = -1;
    10321033        nodirs = 1;
     1034        listf = stderr;
    10331035        while ((c=getopt(argc,argv,"abcdfiklmoprstuvzABC:E:F:H:I:LO:SZ6")) != -1)
    10341036                switch (c) {
    10351037                        case 'a':
     
    11561158                                        paxwarn(1, "Unable to open file '%s' for read", optarg);
    11571159                                        cpio_usage();
    11581160                                }
    1159                                 while ((str = getline(fp)) != NULL) {
     1161                                while ((str = getln(fp)) != NULL) {
    11601162                                        pat_add(str, NULL);
    11611163                                }
    11621164                                fclose(fp);
    1163                                 if (getline_error) {
     1165                                if (getln_error) {
    11641166                                        paxwarn(1, "Problem with file '%s'", optarg);
    11651167                                        cpio_usage();
    11661168                                }
     
    12551257                         * no read errors allowed on updates/append operation!
    12561258                         */
    12571259                        maxflt = 0;
    1258                         while ((str = getline(stdin)) != NULL) {
     1260                        while ((str = getln(stdin)) != NULL) {
    12591261                                ftree_add(str, NULL);
    12601262                        }
    1261                         if (getline_error) {
     1263                        if (getln_error) {
    12621264                                paxwarn(1, "Problem while reading stdin");
    12631265                                cpio_usage();
    12641266                        }
     
    14831485        return(num);
    14841486}
    14851487
     1488/*
     1489 * getln()
     1490 *      read a line and return it in a malloc'ed buffer.
     1491 *
     1492 *      In pax 3.0 this was called my_getline().  somewhere
     1493 *      between 3.0 and 3.3 it was replaced with a function
     1494 *      called getline() that did the same thing as my_getline()
     1495 *      but used fgetln().  fgetln() is not a GNU function - its
     1496 *      only available on BSD, and that made life difficult.
     1497 *      Very difficult in fact, as the easiy way to emulate
     1498 *      fgetln() is to use the GNU getline() function, buts its
     1499 *      name clashed with the one defined here.  This third
     1500 *      re-write is shorter and faster than the previous two,
     1501 *      and is compatible with GNU libc.
     1502 */
    14861503char *
    1487 getline(FILE *f)
     1504getln(FILE * f)
    14881505{
    1489         char *name, *temp;
     1506        char *name = 0;
     1507        size_t buflen = 0;
    14901508        size_t len;
    14911509
    1492         name = fgetln(f, &len);
    1493         if (!name) {
    1494                 getline_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0;
     1510        len = getline(&name, &buflen, f);
     1511        if (len == (size_t)-1) {
     1512                if (name)
     1513                        free(name);
     1514                getln_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0;
    14951515                return(0);
    14961516        }
    1497         if (name[len-1] != '\n')
    1498                 len++;
    1499         temp = malloc(len);
    1500         if (!temp) {
    1501                 getline_error = GETLINE_OUT_OF_MEM;
    1502                 return(0);
    1503         }
    1504         memcpy(temp, name, len-1);
    1505         temp[len-1] = 0;
    1506         return(temp);
     1517        if (name[len - 1] == '\n')
     1518                name[len - 1] = '\0';
     1519        return name;
    15071520}
    1508                        
     1521
    15091522/*
    15101523 * no_op()
    15111524 *      for those option functions where the archive format has nothing to do.
  • src/pax.c

    diff -Nur pax-3.3-doc/src/pax.c pax-3.3-gcc/src/pax.c
    old new  
    108108char    *ltmfrmt;               /* -v locale time format (if any) */
    109109char    *argv0;                 /* root of argv[0] */
    110110sigset_t s_mask;                /* signal mask for cleanup critical sect */
    111 FILE    *listf = stderr;        /* file pointer to print file list to */
     111FILE    *listf;                 /* file pointer to print file list to */
    112112char    *tempfile;              /* tempfile to use for mkstemp(3) */
    113113char    *tempbase;              /* basename of tempfile to use for mkstemp(3) */
    114114
  • src/sel_subs.c

    diff -Nur pax-3.3-doc/src/sel_subs.c pax-3.3-gcc/src/sel_subs.c
    old new  
    5656#include <stdio.h>
    5757#include <stdlib.h>
    5858#include <string.h>
     59#include <time.h>
    5960#include <tzfile.h>
    6061#include <unistd.h>
    6162#include "pax.h"
Note: See TracBrowser for help on using the repository browser.