Update misc code to POSIX fnmatch() call.
authorJ.T. Conklin <jtc@winsey.com>
Fri, 25 Jun 1993 19:29:55 +0000 (19:29 +0000)
committerJ.T. Conklin <jtc@winsey.com>
Fri, 25 Jun 1993 19:29:55 +0000 (19:29 +0000)
usr.bin/find/function.c
usr.bin/locate/locate/locate.c

index 510a0d1..f7eb8fd 100644 (file)
@@ -51,6 +51,7 @@ static char sccsid[] = "@(#)function.c        5.17 (Berkeley) 5/24/91";
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <fnmatch.h>
 #include "find.h"
 
 #define        FIND_EQUAL      0
 #include "find.h"
 
 #define        FIND_EQUAL      0
@@ -320,8 +321,7 @@ f_fstype(plan, entry)
 {
        static dev_t curdev;    /* need a guaranteed illegal dev value */
        static int first = 1;
 {
        static dev_t curdev;    /* need a guaranteed illegal dev value */
        static int first = 1;
-       struct statfs sb;
-       static short val;
+       static struct statfs sb;
        char *p, save[2];
 
        /* only check when we cross mount point */
        char *p, save[2];
 
        /* only check when we cross mount point */
@@ -355,10 +355,9 @@ f_fstype(plan, entry)
                }
 
                first = 0;
                }
 
                first = 0;
-               val = plan->flags == MOUNT_NONE ? sb.f_flags : sb.f_type;
        }
        return(plan->flags == MOUNT_NONE ?
        }
        return(plan->flags == MOUNT_NONE ?
-           val & MNT_LOCAL : val == plan->flags);
+           sb.f_flags & plan->m_flags : sb.f_type == plan->flags);
 }
  
 PLAN *
 }
  
 PLAN *
@@ -371,15 +370,36 @@ c_fstype(arg)
     
        new = palloc(N_FSTYPE, f_fstype);
        switch(*arg) {
     
        new = palloc(N_FSTYPE, f_fstype);
        switch(*arg) {
+       case 'f':
+               if (!strcmp(arg, "fdesc")) {
+#ifdef MOUNT_FDESC
+                       new->flags = MOUNT_FDESC;
+                       return(new);
+#else
+                       err("unknown file type %s", arg);
+#endif
+               }
+               break;
        case 'i':
                if (!strcmp(arg, "isofs")) {
                        new->flags = MOUNT_ISOFS;
                        return(new);
                }
                break;
        case 'i':
                if (!strcmp(arg, "isofs")) {
                        new->flags = MOUNT_ISOFS;
                        return(new);
                }
                break;
+       case 'k':
+               if (!strcmp(arg, "kernfs")) {
+#ifdef MOUNT_KERNFS
+                       new->flags = MOUNT_KERNFS;
+                       return(new);
+#else
+                       err("unknown file type %s", arg);
+#endif
+               }
+               break;
        case 'l':
                if (!strcmp(arg, "local")) {
                        new->flags = MOUNT_NONE;
        case 'l':
                if (!strcmp(arg, "local")) {
                        new->flags = MOUNT_NONE;
+                       new->m_flags = MNT_LOCAL;
                        return(new);
                }
                break;
                        return(new);
                }
                break;
@@ -399,6 +419,13 @@ c_fstype(arg)
                        return(new);
                }
                break;
                        return(new);
                }
                break;
+       case 'r':
+               if (!strcmp(arg, "rdonly")) {
+                       new->flags = MOUNT_NONE;
+                       new->m_flags = MNT_RDONLY;
+                       return(new);
+               }
+               break;
        case 'u':
                if (!strcmp(arg, "ufs")) {
                        new->flags = MOUNT_UFS;
        case 'u':
                if (!strcmp(arg, "ufs")) {
                        new->flags = MOUNT_UFS;
@@ -530,7 +557,7 @@ f_name(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
        PLAN *plan;
        FTSENT *entry;
 {
-       return(fnmatch(plan->c_data, entry->fts_name, FNM_QUOTE));
+       return(!fnmatch(plan->c_data, entry->fts_name, 0));
 }
  
 PLAN *
 }
  
 PLAN *
index 440aadb..d97f32f 100644 (file)
@@ -74,6 +74,8 @@ static char sccsid[] = "@(#)locate.c  5.2 (Berkeley) 6/1/90";
 #include <sys/param.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/param.h>
 #include <unistd.h>
 #include <stdio.h>
+#include <string.h>
+#include <fnmatch.h>
 #include "locate.h"
 #include "pathnames.h"
 
 #include "locate.h"
 #include "pathnames.h"
 
@@ -103,7 +105,7 @@ fastfind(pathpart)
        register char *p, *s;
        register int c;
        int count, found, globflag;
        register char *p, *s;
        register int c;
        int count, found, globflag;
-       char *cutoff, *patend, *q, *index(), *patprep();
+       char *cutoff, *patend, *q, *patprep();
        char bigram1[NBG], bigram2[NBG], path[MAXPATHLEN];
 
        for (c = 0, p = bigram1, s = bigram2; c < NBG; c++)
        char bigram1[NBG], bigram2[NBG], path[MAXPATHLEN];
 
        for (c = 0, p = bigram1, s = bigram2; c < NBG; c++)
@@ -135,7 +137,7 @@ fastfind(pathpart)
                                if (*p == NULL) {       /* fast match success */
                                        found = 1;
                                        if (!globflag ||
                                if (*p == NULL) {       /* fast match success */
                                        found = 1;
                                        if (!globflag ||
-                                           fnmatch(pathpart, path, FNM_QUOTE))
+                                           !fnmatch(pathpart, path, 0))
                                                (void)printf("%s\n", path);
                                        break;
                                }
                                                (void)printf("%s\n", path);
                                        break;
                                }