Author: jilles
Date: Sun Aug 22 21:18:21 2010
New Revision: 211646
URL: http://svn.freebsd.org/changeset/base/211646

Log:
  sh: Remove remnants of '!!' to negate pattern.
  
  This Almquist extension was disabled long ago.
  
  In pathname generation, components starting with '!!' were treated as
  containing wildcards, causing unnecessary readdir (which could fail, causing
  pathname generation to fail while it should not).

Added:
  head/tools/regression/bin/sh/expansion/pathname4.0   (contents, props changed)
Modified:
  head/bin/sh/expand.c

Modified: head/bin/sh/expand.c
==============================================================================
--- head/bin/sh/expand.c        Sun Aug 22 21:06:18 2010        (r211645)
+++ head/bin/sh/expand.c        Sun Aug 22 21:18:21 2010        (r211646)
@@ -109,7 +109,6 @@ STATIC void expmeta(char *, char *);
 STATIC void addfname(char *);
 STATIC struct strlist *expsort(struct strlist *);
 STATIC struct strlist *msort(struct strlist *, int);
-STATIC int pmatch(const char *, const char *, int);
 STATIC char *cvtnum(int, char *);
 STATIC int collate_range_cmp(int, int);
 
@@ -1101,7 +1100,7 @@ expandmeta(struct strlist *str, int flag
                for (;;) {                      /* fast check for meta chars */
                        if ((c = *p++) == '\0')
                                goto nometa;
-                       if (c == '*' || c == '?' || c == '[' || c == '!')
+                       if (c == '*' || c == '?' || c == '[')
                                break;
                }
                savelastp = exparg.lastp;
@@ -1168,8 +1167,6 @@ expmeta(char *enddir, char *name)
                                        break;
                                }
                        }
-               } else if (*p == '!' && p[1] == '!'     && (p == name || p[-1] 
== '/')) {
-                       metaflag = 1;
                } else if (*p == '\0')
                        break;
                else if (*p == CTLQUOTEMARK)
@@ -1353,18 +1350,6 @@ msort(struct strlist *list, int len)
 int
 patmatch(const char *pattern, const char *string, int squoted)
 {
-#ifdef notdef
-       if (pattern[0] == '!' && pattern[1] == '!')
-               return 1 - pmatch(pattern + 2, string);
-       else
-#endif
-               return pmatch(pattern, string, squoted);
-}
-
-
-STATIC int
-pmatch(const char *pattern, const char *string, int squoted)
-{
        const char *p, *q;
        char c;
 
@@ -1406,7 +1391,7 @@ pmatch(const char *pattern, const char *
                                }
                        }
                        do {
-                               if (pmatch(p, q, squoted))
+                               if (patmatch(p, q, squoted))
                                        return 1;
                                if (squoted && *q == CTLESC)
                                        q++;

Added: head/tools/regression/bin/sh/expansion/pathname4.0
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/expansion/pathname4.0  Sun Aug 22 21:18:21 
2010        (r211646)
@@ -0,0 +1,28 @@
+# $FreeBSD$
+
+failures=0
+
+check() {
+       testcase=$1
+       expect=$2
+       eval "set -- $testcase"
+       actual="$*"
+       if [ "$actual" != "$expect" ]; then
+               failures=$((failures+1))
+               printf '%s\n' "For $testcase, expected $expect actual $actual"
+       fi
+}
+
+set -e
+T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX)
+trap 'rm -rf $T' 0
+cd -P $T
+
+mkdir !!a
+touch !!a/fff
+
+chmod u-r .
+check '!!a/ff*' '!!a/fff'
+chmod u+r .
+
+exit $((failures != 0))
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to