aboutsummaryrefslogtreecommitdiffstats
path: root/pathexp.c
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>2008-11-18 13:15:12 +0000
committerJari Aalto <jari.aalto@cante.net>2009-09-12 16:46:59 +0000
commitf1be666c7d78939ad775078d290bec2758fa29a2 (patch)
tree4f4b8ed6eb250653e0bb44685eb5ffa9d3805e91 /pathexp.c
parent0628567a28f3510f506ae46cb9b24b73a6d2dc5d (diff)
downloadandroid_external_bash-f1be666c7d78939ad775078d290bec2758fa29a2.tar.gz
android_external_bash-f1be666c7d78939ad775078d290bec2758fa29a2.tar.bz2
android_external_bash-f1be666c7d78939ad775078d290bec2758fa29a2.zip
Imported from ../bash-3.2.48.tar.gz.
Diffstat (limited to 'pathexp.c')
-rw-r--r--pathexp.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/pathexp.c b/pathexp.c
index a498672..69966ac 100644
--- a/pathexp.c
+++ b/pathexp.c
@@ -1,6 +1,6 @@
/* pathexp.c -- The shell interface to the globbing library. */
-/* Copyright (C) 1995-2002 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2007 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -110,6 +110,33 @@ unquoted_glob_pattern_p (string)
return (0);
}
+/* Return 1 if C is a character that is `special' in a POSIX ERE and needs to
+ be quoted to match itself. */
+static inline int
+ere_char (c)
+ int c;
+{
+ switch (c)
+ {
+ case '.':
+ case '[':
+ case '\\':
+ case '(':
+ case ')':
+ case '*':
+ case '+':
+ case '?':
+ case '{':
+ case '|':
+ case '^':
+ case '$':
+ return 1;
+ default:
+ return 0;
+ }
+ return (0);
+}
+
/* PATHNAME can contain characters prefixed by CTLESC; this indicates
that the character is to be quoted. We quote it here in the style
that the glob library recognizes. If flags includes QGLOB_CVTNULL,
@@ -142,6 +169,8 @@ quote_string_for_globbing (pathname, qflags)
{
if ((qflags & QGLOB_FILENAME) && pathname[i+1] == '/')
continue;
+ if ((qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0)
+ continue;
temp[j++] = '\\';
i++;
if (pathname[i] == '\0')