diff options
author | Janak Ramakrishnan <janakr@google.com> | 2015-05-15 23:05:03 +0000 |
---|---|---|
committer | Laszlo Csomor <laszlocsomor@google.com> | 2015-05-18 09:16:54 +0000 |
commit | 0971e79a369338e9723aba47470e41051787a91a (patch) | |
tree | f9bbaf4fbb9d2d8d002b9a4f9de46c1ac45e1647 /src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java | |
parent | 0b09d289d52351b3e67d7a6b9b64e9fe24cf2893 (diff) |
Change UnixGlob#matcher to treat "**/" and "/**" as matching zero or more directories, as is specified in various places, not one or more.
--
MOS_MIGRATED_REVID=93758086
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java b/src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java index 441571ef3d..11d88cd324 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java @@ -252,7 +252,21 @@ public final class UnixGlob { char c = pattern.charAt(i); switch(c) { case '*': + int toIncrement = 0; + if (len > i + 1 && pattern.charAt(i + 1) == '*') { + // The pattern '**' is interpreted to match 0 or more directory separators, not 1 or + // more. We skip the next * and then find a trailing/leading '/' and get rid of it. + toIncrement = 1; + if (len > i + 2 && pattern.charAt(i + 2) == '/') { + // We have '**/' -- skip the '/'. + toIncrement = 2; + } else if (len == i + 2 && i > 0 && pattern.charAt(i - 1) == '/') { + // We have '/**' -- remove the '/'. + regexp.delete(regexp.length() - 1, regexp.length()); + } + } regexp.append(".*"); + i += toIncrement; break; case '?': regexp.append('.'); |