summaryrefslogtreecommitdiff
path: root/cli/runtime-source.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-06-02 18:48:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-06-02 18:48:40 +0200
commit51dc9396d8bd8f0971a59f4e3aa11e8315c394cd (patch)
treed24a2258506584644e0b74468ac22bbdad9af8ab /cli/runtime-source.cxx
parented60746355044dd39acd82b8f42c4d9886914567 (diff)
Add support for quoting in option file scanner
Diffstat (limited to 'cli/runtime-source.cxx')
-rw-r--r--cli/runtime-source.cxx36
1 files changed, 34 insertions, 2 deletions
diff --git a/cli/runtime-source.cxx b/cli/runtime-source.cxx
index fea0347..348d7b7 100644
--- a/cli/runtime-source.cxx
+++ b/cli/runtime-source.cxx
@@ -129,10 +129,10 @@ generate_runtime_source (context& ctx)
<< "return \"end of argument stream reached\";"
<< "}";
- // file_io_failure
- //
if (ctx.options.generate_file_scanner ())
{
+ // file_io_failure
+ //
os << "// file_io_failure" << endl
<< "//" << endl
<< "file_io_failure::" << endl
@@ -151,6 +151,27 @@ generate_runtime_source (context& ctx)
<< "{"
<< "return \"unable to open file or read failure\";"
<< "}";
+
+ // unmatched_argument
+ //
+ os << "// unmatched_quote" << endl
+ << "//" << endl
+ << "unmatched_quote::" << endl
+ << "~unmatched_quote () throw ()"
+ << "{"
+ << "}"
+
+ << "void unmatched_quote::" << endl
+ << "print (std::ostream& os) const"
+ << "{"
+ << "os << \"unmatched quote in argument '\" << argument () << \"'\";"
+ << "}"
+
+ << "const char* unmatched_quote::" << endl
+ << "what () const throw ()"
+ << "{"
+ << "return \"unmatched quote\";"
+ << "}";
}
// scanner
@@ -368,6 +389,17 @@ generate_runtime_source (context& ctx)
<< "}"
<< "string s2 (line, p);"
<< endl
+ << "// If the string is wrapped in quotes, remove them." << endl
+ << "//" << endl
+ << "n = s2.size ();"
+ << endl
+ << "if (s2[0] == '\"' || s2[n - 1] == '\"')"
+ << "{"
+ << "if (n == 1 || s2[0] != s2[n - 1])" << endl
+ << "throw unmatched_quote (s2);"
+ << endl
+ << "s2 = string (s2, 1, n - 2);"
+ << "}"
<< "if (" << (sep ? "!skip_ && " : "") << "s1 == option_)" << endl
<< "load (s2.c_str ());"
<< "else"