#include <sys/types.h> /* 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
void name_init();
void options();
char *un_quote_string();
-int wildmat();
#ifndef S_ISLNK
#define lstat stat
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)
/* 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;
#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;
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;
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);
}
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();
/* 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);
/* 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;
}
{
FILE *fp;
char buf[1024];
- extern char *rindex();
if(strcmp(file, "-"))
fp=fopen(file,"r");
extern char *strstr();
for(n=0;n<size_re_exclude;n++) {
- if(wildmat(name,re_exclude[n]))
+ if(fnmatch(re_exclude[n], name, FNM_TARPATH) == 0)
return 1;
}
for(n=0;n<size_exclude;n++) {