]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2009-11-18 Robert Millan <rmh.grub@aybabtu.com>
authorRobert Millan <rmh@aybabtu.com>
Wed, 18 Nov 2009 22:49:59 +0000 (22:49 +0000)
committerRobert Millan <rmh@aybabtu.com>
Wed, 18 Nov 2009 22:49:59 +0000 (22:49 +0000)
        * util/mkisofs/match.c: Rewrite from scratch, using a linked list
        instead of static allocation.
        * util/mkisofs/match.h: Likewise.

ChangeLog
util/mkisofs/match.c
util/mkisofs/match.h

index 84779479aba639456307223f383f80181b3e02a5..a66631f066aee447c76bba9d86886ec4539b53dc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-11-18  Robert Millan  <rmh.grub@aybabtu.com>
+
+       * 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  <rmh.grub@aybabtu.com>
 
        * po/POTFILES-shell: New file.  List `util/grub.d/10_kfreebsd.in'
index 8590be470e9fe35edf514e6129aa98074f22fb9c..0072b504e37837cb399ea3c4e2e89f5e9d467a41 100644 (file)
 /*
- * 27-Mar-96: Jan-Piet Mens <jpm@mens.de>
- * 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 <http://www.gnu.org/licenses/>.
  */
 
-static char rcsid[] ="$Id: match.c,v 1.3 1999/03/02 03:41:25 eric Exp $";
-
 #include "config.h"
-#include <prototyp.h>
-#include <stdio.h>
-#ifndef VMS
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#else
+
 #include <stdlib.h>
-#endif
-#endif
 #include <string.h>
-#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<MAXMATCH; i++);
-  if (i == MAXMATCH) {
-    fprintf(stderr,"Can't exclude RE '%s' - too many entries in table\n",fn);
-    return;
-  }
-
-  mat[i] = (char *) malloc(strlen(fn)+1);
-  if (! mat[i]) {
-    fprintf(stderr,"Can't allocate memory for excluded filename\n");
-    return;
-  }
-
-  strcpy(mat[i],fn);
-}
-
-int matches(fn)
-char * fn;
-{
-  /* very dumb search method ... */
-  register int i;
-
-  for (i=0; mat[i] && i<MAXMATCH; i++) {
-    if (fnmatch(mat[i], fn, FNM_FILE_NAME) != FNM_NOMATCH) {
-      return 1; /* found -> 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<MAXMATCH; i++);
-  if (i == MAXMATCH) {
-    fprintf(stderr,"Can't exclude RE '%s' - too many entries in table\n",fn);
-    return;
-  }
-
-  i_mat[i] = (char *) malloc(strlen(fn)+1);
-  if (! i_mat[i]) {
-    fprintf(stderr,"Can't allocate memory for excluded filename\n");
-    return;
-  }
-
-  strcpy(i_mat[i],fn);
-}
+#include "match.h"
 
-int i_matches(fn)
-char * fn;
+struct pattern
 {
-  /* very dumb search method ... */
-  register int i;
-
-  for (i=0; i_mat[i] && i<MAXMATCH; i++) {
-    if (fnmatch(i_mat[i], fn, FNM_FILE_NAME) != FNM_NOMATCH) {
-      return 1; /* found -> 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<MAXMATCH; i++);
-  if (i == MAXMATCH) {
-    fprintf(stderr,"Can't exclude RE '%s' - too many entries in table\n",fn);
-    return;
-  }
-
-  j_mat[i] = (char *) malloc(strlen(fn)+1);
-  if (! j_mat[i]) {
-    fprintf(stderr,"Can't allocate memory for excluded filename\n");
-    return;
-  }
-
-  strcpy(j_mat[i],fn);
+  return (i_patlist != NULL);
 }
 
-int j_matches(fn)
-char * fn;
-{
-  /* very dumb search method ... */
-  register int i;
-
-  for (i=0; j_mat[i] && i<MAXMATCH; i++) {
-    if (fnmatch(j_mat[i], fn, FNM_FILE_NAME) != FNM_NOMATCH) {
-      return 1; /* found -> excluded filenmae */
-    }
-  }
-  return 0; /* not found -> not excluded */
-}
 
 int j_ishidden()
 {
-  return (j_mat[0] != NULL);
+  return (j_patlist != NULL);
 }
-
index 7367dd211f724240caa4d79a081786497605b73a..ee346a24c63d50b5abb06502cb73cdb216f349f8 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
  */
 
-/*
- *     $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 ();