From: Robert Millan Date: Wed, 18 Nov 2009 22:49:59 +0000 (+0000) Subject: 2009-11-18 Robert Millan X-Git-Tag: 1.98~405 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1dabbc77cfe7c82f49811aca046a9e3c6649c883;p=thirdparty%2Fgrub.git 2009-11-18 Robert Millan * util/mkisofs/match.c: Rewrite from scratch, using a linked list instead of static allocation. * util/mkisofs/match.h: Likewise. --- diff --git a/ChangeLog b/ChangeLog index 84779479a..a66631f06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-11-18 Robert Millan + + * util/mkisofs/match.c: Rewrite from scratch, using a linked list + instead of static allocation. + * util/mkisofs/match.h: Likewise. + 2009-11-18 Robert Millan * po/POTFILES-shell: New file. List `util/grub.d/10_kfreebsd.in' diff --git a/util/mkisofs/match.c b/util/mkisofs/match.c index 8590be470..0072b504e 100644 --- a/util/mkisofs/match.c +++ b/util/mkisofs/match.c @@ -1,147 +1,76 @@ /* - * 27-Mar-96: Jan-Piet Mens - * added 'match' option (-m) to specify regular expressions NOT to be included - * in the CD image. + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -static char rcsid[] ="$Id: match.c,v 1.3 1999/03/02 03:41:25 eric Exp $"; - #include "config.h" -#include -#include -#ifndef VMS -#ifdef HAVE_MALLOC_H -#include -#else + #include -#endif -#endif #include -#include "match.h" - -#define MAXMATCH 1000 -static char *mat[MAXMATCH]; - -void add_match(fn) -char * fn; -{ - register int i; - - for (i=0; mat[i] && i excluded filenmae */ - } - } - return 0; /* not found -> not excluded */ -} - -/* ISO9660/RR hide */ - -static char *i_mat[MAXMATCH]; +#include "fnmatch.h" -void i_add_match(fn) -char * fn; -{ - register int i; - - for (i=0; i_mat[i] && i excluded filenmae */ - } - } - return 0; /* not found -> not excluded */ + char *str; + struct pattern *next; +}; + +static struct pattern *patlist = NULL; +static struct pattern *i_patlist = NULL; /* ISO9660/RR */ +static struct pattern *j_patlist = NULL; /* Joliet */ + +#define DECL_ADD_MATCH(function, list) \ +void \ +function (char *pattern) \ +{ \ + struct pattern *new; \ + new = malloc (sizeof (*new)); \ + new->str = strdup (pattern); \ + new->next = list; \ + list = new; \ } -int i_ishidden() -{ - return (i_mat[0] != NULL); +DECL_ADD_MATCH (add_match, patlist) +DECL_ADD_MATCH (i_add_match, i_patlist) +DECL_ADD_MATCH (j_add_match, j_patlist) + +#define DECL_MATCHES(function, list) \ +int \ +function (char *str) \ +{ \ + struct pattern *i; \ + for (i = list; i != NULL; i = i->next) \ + if (fnmatch (i->str, str, FNM_FILE_NAME) != FNM_NOMATCH) \ + return 1; \ + return 0; \ } -/* Joliet hide */ +DECL_MATCHES (matches, patlist) +DECL_MATCHES (i_matches, i_patlist) +DECL_MATCHES (j_matches, j_patlist) -static char *j_mat[MAXMATCH]; - -void j_add_match(fn) -char * fn; +int +i_ishidden() { - register int i; - - for (i=0; j_mat[i] && i excluded filenmae */ - } - } - return 0; /* not found -> not excluded */ -} int j_ishidden() { - return (j_mat[0] != NULL); + return (j_patlist != NULL); } - diff --git a/util/mkisofs/match.h b/util/mkisofs/match.h index 7367dd211..ee346a24c 100644 --- a/util/mkisofs/match.h +++ b/util/mkisofs/match.h @@ -1,22 +1,29 @@ /* - * 27th March 1996. Added by Jan-Piet Mens for matching regular expressions - * in paths. - * + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -/* - * $Id: match.h,v 1.2 1999/03/02 03:41:25 eric Exp $ - */ - -#include "fnmatch.h" +#include "config.h" -void add_match __PR((char *fn)); -int matches __PR((char *fn)); +extern void add_match (char *); +extern void i_add_match (char *); +extern void j_add_match (char *); -void i_add_match __PR((char *fn)); -int i_matches __PR((char *fn)); -int i_ishidden __PR((void)); +extern int matches (char *); +extern int i_matches (char *); +extern int j_matches (char *); -void j_add_match __PR((char *fn)); -int j_matches __PR((char *fn)); -int j_ishidden __PR((void)); +extern int i_ishidden (); +extern int j_ishidden ();