X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Ftar.c;h=7f27988481f79039bc0e1a8a47e2420dd3e6ea11;hb=c72ef8c1738769feb53b0ebaaf4fccfe755c2610;hp=c439df5ee304363e36ba8b889c501cdeab79e7e3;hpb=ccba255632849ba378f36d46df79adeb8ae7920b;p=chaz%2Ftar diff --git a/src/tar.c b/src/tar.c index c439df5..7f27988 100644 --- a/src/tar.c +++ b/src/tar.c @@ -27,6 +27,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include /* Needed for typedefs in tar.h */ #include "getopt.h" #include "regex.h" +#include "fnmatch.h" /* * The following causes "tar.h" to produce definitions of all the @@ -103,7 +104,6 @@ void name_add(); void name_init(); void options(); char *un_quote_string(); -int wildmat(); #ifndef S_ISLNK #define lstat stat @@ -280,7 +280,7 @@ main(argc, argv) break; case CMD_NONE: msg("you must specify exactly one of the r, c, t, x, or d options\n"); - fprintf(stderr,"For more information, type ``%s +help''.\n",tar); + fprintf(stderr,"For more information, type ``%s --help''.\n",tar); exit(EX_ARGSBAD); } if (f_volno_file) @@ -303,7 +303,7 @@ options(argc, argv) /* Set default option values */ blocking = DEFBLOCKING; /* From Makefile */ - ar_files = malloc (sizeof (char *) * 10); + ar_files = (char **) malloc (sizeof (char *) * 10); ar_files_len = 10; n_ar_files = 0; cur_ar_file = 0; @@ -401,8 +401,9 @@ options(argc, argv) #endif if (n_ar_files == ar_files_len) ar_files - = (sizeof (char *) - * (ar_files_len *= 2)); + = (char **) + ck_malloc (sizeof (char *) + * (ar_files_len *= 2)); ar_files[n_ar_files++]=buf; } break; @@ -445,8 +446,8 @@ options(argc, argv) case 'f': /* Use ar_file for the archive */ if (n_ar_files == ar_files_len) ar_files - = (sizeof (char *) - * (ar_files_len *= 2)); + = (char **) ck_malloc (sizeof (char *) + * (ar_files_len *= 2)); ar_files[n_ar_files++] = optarg; break; @@ -615,7 +616,7 @@ options(argc, argv) case '?': badopt: - msg("Unknown option. Use '%s +help' for a complete list of options.", tar); + msg("Unknown option. Use '%s --help' for a complete list of options.", tar); exit(EX_ARGSBAD); } @@ -972,9 +973,10 @@ addname(name) if(chdir_name[0]!='/') { char *path = ck_malloc(PATH_MAX); #if defined(__MSDOS__) || defined(USG) || defined(_POSIX_VERSION) - if(!getcwd(path,PATH_MAX)) + if(!getcwd(path,PATH_MAX)) { msg("Couldn't get current directory."); exit(EX_SYSTEM); + } #else char *getwd(); @@ -1061,7 +1063,7 @@ again: /* Regular expressions (shell globbing, actually). */ if (nlp->regexp) { - if (wildmat(p, nlp->name)) { + if (fnmatch(nlp->name, p, FNM_TARPATH) == 0) { nlp->found = 1; /* Remember it matched */ if(f_startfile) { free((void *)namelist); @@ -1171,7 +1173,7 @@ again: /* Regular expressions */ if (nlp->regexp) { - if (wildmat(p, nlp->name)) + if (fnmatch(nlp->name, p, FNM_TARPATH) == 0) return nlp; /* We got a match */ continue; } @@ -1339,7 +1341,6 @@ char *file; { FILE *fp; char buf[1024]; - extern char *rindex(); if(strcmp(file, "-")) fp=fopen(file,"r"); @@ -1383,7 +1384,7 @@ char *name; extern char *strstr(); for(n=0;n