summaryrefslogtreecommitdiff
path: root/indra/llvfs/lldiriterator.cpp
diff options
context:
space:
mode:
authorSquire <squire@lindenlab.com>2011-06-20 11:18:26 -0700
committerSquire <squire@lindenlab.com>2011-06-20 11:18:26 -0700
commitaa15185bc858c14d2cdc402b0ed74293c2c3e693 (patch)
tree67624b059d45c9f5870abc6761c0fd5247a43cc6 /indra/llvfs/lldiriterator.cpp
parent7f6d49df43c660b9f5632ffb8a30f90ee718cac0 (diff)
parent306759835d8aed3a041a59dafaa20a8c708e2dd4 (diff)
Chop-662 - fixes to deal with cleanly moving between the glob and regex world
Diffstat (limited to 'indra/llvfs/lldiriterator.cpp')
-rw-r--r--indra/llvfs/lldiriterator.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/indra/llvfs/lldiriterator.cpp b/indra/llvfs/lldiriterator.cpp
index 041436ed92..3b132862ad 100644
--- a/indra/llvfs/lldiriterator.cpp
+++ b/indra/llvfs/lldiriterator.cpp
@@ -121,6 +121,14 @@ bool LLDirIterator::Impl::next(std::string &fname)
return found;
}
+/*
+converts the incoming glob into a regex. This involves
+converting incoming glob expressions to regex equivilents and
+at the same time, escaping any regex meaningful characters which
+do not have glob meaning, i.e.
+ .()+|^$
+in the input
+*/
std::string glob_to_regex(const std::string& glob)
{
std::string regex;
@@ -135,9 +143,6 @@ std::string glob_to_regex(const std::string& glob)
switch (c)
{
- case '.':
- regex+="\\.";
- break;
case '*':
if (glob.begin() == i)
{
@@ -170,7 +175,15 @@ std::string glob_to_regex(const std::string& glob)
case '!':
regex+= square_brace_open ? '^' : c;
break;
- default:
+ case '.': // This collection have different regex meaning
+ case '^': // And so need escaping
+ case '(':
+ case ')':
+ case '+':
+ case '|':
+ case '$':
+ regex+='\\';
+ default:
regex+=c;
break;
}