diff --git a/src/CLI.cpp b/src/CLI.cpp
index 37864502f..1245a3237 100644
--- a/src/CLI.cpp
+++ b/src/CLI.cpp
@@ -304,6 +304,7 @@ void CLI::analyze ()
decomposeModAttributes ();
decomposeModAttributeModifiers ();
decomposeModTags ();
+ decomposeModSubstitutions ();
}
////////////////////////////////////////////////////////////////////////////////
@@ -1179,7 +1180,6 @@ void CLI::desugarUUIDs ()
////////////////////////////////////////////////////////////////////////////////
void CLI::decomposeModAttributes ()
{
- std::vector reconstructed;
std::vector ::iterator a;
for (a = _args.begin (); a != _args.end (); ++a)
{
@@ -1229,17 +1229,12 @@ void CLI::decomposeModAttributes ()
}
}
}
-
- reconstructed.push_back (*a);
}
-
- _args = reconstructed;
}
////////////////////////////////////////////////////////////////////////////////
void CLI::decomposeModAttributeModifiers ()
{
- std::vector reconstructed;
std::vector ::iterator a;
for (a = _args.begin (); a != _args.end (); ++a)
{
@@ -1309,17 +1304,12 @@ void CLI::decomposeModAttributeModifiers ()
}
}
}
-
- reconstructed.push_back (*a);
}
-
- _args = reconstructed;
}
////////////////////////////////////////////////////////////////////////////////
void CLI::decomposeModTags ()
{
- std::vector reconstructed;
std::vector ::iterator a;
for (a = _args.begin (); a != _args.end (); ++a)
{
@@ -1339,11 +1329,40 @@ void CLI::decomposeModTags ()
a->tag ("TAG");
}
}
-
- reconstructed.push_back (*a);
}
-
- _args = reconstructed;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CLI::decomposeModSubstitutions ()
+{
+ std::vector ::iterator a;
+ for (a = _args.begin (); a != _args.end (); ++a)
+ {
+ if (a->hasTag ("MODIFICATION"))
+ {
+ std::string raw = a->attribute ("raw");
+ Nibbler n (raw);
+ std::string from;
+ std::string to;
+ bool global = false;
+ if (n.getQuoted ('/', from) &&
+ n.backN () &&
+ n.getQuoted ('/', to))
+ {
+ if (n.skip ('g'))
+ global = true;
+
+ if (n.depleted () &&
+ ! Directory (raw).exists ())
+ {
+ a->tag ("SUBSTITUTION");
+ a->attribute ("from", from);
+ a->attribute ("to", to);
+ a->attribute ("global", global ? 1 : 0);
+ }
+ }
+ }
+ }
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/src/CLI.h b/src/CLI.h
index 940d9c7a8..57b55bbb8 100644
--- a/src/CLI.h
+++ b/src/CLI.h
@@ -89,6 +89,7 @@ private:
void decomposeModAttributes ();
void decomposeModAttributeModifiers ();
void decomposeModTags ();
+ void decomposeModSubstitutions ();
public:
std::multimap _entities;