* add function strip_txz() to strip off any .tgz, .tbz, .t[bg]z from a
given filename. * Use strip_txz() inside the FTP-wildcard-depends handling code to prevent it handing a combination of glob and dewey pattern to pmatch(), which our pattern matching code currently does not handle. Bugfix! XXX The other places that could be changed to use strip_txz() are not touched in this commit to keep the impact of this change small in the light of the approaching 1.5.1 release. I'll revisit them.
This commit is contained in:
parent
32f9842307
commit
01b66ea788
|
@ -1,8 +1,8 @@
|
|||
/* $NetBSD: ftpio.c,v 1.30 2001/04/09 08:13:37 itojun Exp $ */
|
||||
/* $NetBSD: ftpio.c,v 1.31 2001/04/28 20:55:34 hubertf Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: ftpio.c,v 1.30 2001/04/09 08:13:37 itojun Exp $");
|
||||
__RCSID("$NetBSD: ftpio.c,v 1.31 2001/04/28 20:55:34 hubertf Exp $");
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -559,8 +559,21 @@ expandURL(char *expandedurl, const char *wildcardurl)
|
|||
/* The following loop is basically the same as the readdir() loop
|
||||
* in findmatchingname() */
|
||||
while (fgets(filename, sizeof(buf), f)) {
|
||||
|
||||
/*
|
||||
* We need to stripp of any .t[bg]z etc.
|
||||
* suffix here
|
||||
*/
|
||||
|
||||
char s_filename[FILENAME_MAX];
|
||||
char s_pkg[FILENAME_MAX];
|
||||
|
||||
filename[strlen(filename)-1] = '\0';
|
||||
if (pmatch(pkg, filename)) {
|
||||
|
||||
strip_txz(s_filename, filename);
|
||||
strip_txz(s_pkg, pkg);
|
||||
|
||||
if (pmatch(s_pkg, s_filename)) {
|
||||
matches++;
|
||||
|
||||
/* compare findbestmatchingname() */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lib.h,v 1.33 2001/03/18 03:20:29 hubertf Exp $ */
|
||||
/* $NetBSD: lib.h,v 1.34 2001/04/28 20:55:34 hubertf Exp $ */
|
||||
|
||||
/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
|
||||
|
||||
|
@ -187,6 +187,7 @@ int findbestmatchingname_fn(const char *pkg, char *data); /* neither */
|
|||
char *findbestmatchingname(const char *, const char *); /* neither */
|
||||
int ispkgpattern(const char *);
|
||||
char *strnncpy(char *to, size_t tosize, char *from, size_t cc);
|
||||
void strip_txz(char *buf, char *fname);
|
||||
|
||||
/* File */
|
||||
Boolean fexists(char *);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: str.c,v 1.28 2001/03/06 10:29:11 wiz Exp $ */
|
||||
/* $NetBSD: str.c,v 1.29 2001/04/28 20:55:33 hubertf Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "Id: str.c,v 1.5 1997/10/08 07:48:21 charnier Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: str.c,v 1.28 2001/03/06 10:29:11 wiz Exp $");
|
||||
__RCSID("$NetBSD: str.c,v 1.29 2001/04/28 20:55:33 hubertf Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -511,3 +511,24 @@ strnncpy(char *to, size_t tosize, char *from, size_t cc)
|
|||
to[len] = 0;
|
||||
return to;
|
||||
}
|
||||
|
||||
/*
|
||||
* Strip off any .tgz, .tbz or .t[bg]z suffix from fname,
|
||||
* and copy into buffer "buf"
|
||||
*/
|
||||
void
|
||||
strip_txz(char *buf, char *fname)
|
||||
{
|
||||
char *s;
|
||||
|
||||
strcpy(buf, fname);
|
||||
|
||||
s = strstr(buf, ".tgz");
|
||||
if (s) { *s = '\0'; } /* strip off any ".tgz" */
|
||||
|
||||
s = strstr(buf, ".tbz");
|
||||
if (s) { *s = '\0'; } /* strip off any ".tbz" */
|
||||
|
||||
s = strstr(buf, ".t[bg]z");
|
||||
if (s) { *s = '\0'; } /* strip off any ".t[bg]z" */
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue