diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-06-04 09:25:29 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-06-04 09:25:29 +0200 |
commit | b8cec4a2571596692c1e0b27cc3953ecff712178 (patch) | |
tree | 2aadf52a5f0dea3af5d45c894f0370274e6042b2 /cli | |
parent | 840f2fae3995a3e263801ad07d1285d35ddd9485 (diff) |
Add support for single quotes in option files
Diffstat (limited to 'cli')
-rw-r--r-- | cli/options.cli | 8 | ||||
-rw-r--r-- | cli/options.cxx | 5 | ||||
-rw-r--r-- | cli/runtime-source.cxx | 5 |
3 files changed, 10 insertions, 8 deletions
diff --git a/cli/options.cli b/cli/options.cli index 58f9565..ffa92df 100644 --- a/cli/options.cli +++ b/cli/options.cli @@ -214,10 +214,10 @@ class options "Read additional options from <file> with each option appearing on a separate line optionally followed by space and an option value. Empty lines and lines starting with \cb{#} are ignored. Option values can - be enclosed in double quotes (\cb{\"\"}) to preserve leading and - trailing whitespaces as well as to specify empty values. If the value - itself contains trailing or leading double quote, enclose it with an - extra pair of double quotes, for example \cb{\"\"x\"\"}. Non-leading + be enclosed in double (\cb{\"}) or single (\cb{'}) quotes to preserve + leading and trailing whitespaces as well as to specify empty values. + If the value itself contains trailing or leading double quote, enclose + it with an extra pair of quotes, for example \cb{'\"x\"'}. Non-leading and non-trailing quotes are interpreted as being part of the option value. diff --git a/cli/options.cxx b/cli/options.cxx index 3f3c1b9..1c46fd4 100644 --- a/cli/options.cxx +++ b/cli/options.cxx @@ -351,10 +351,11 @@ namespace cli // If the string is wrapped in quotes, remove them. // n = s2.size (); + char cf (s2[0]), cl (s2[n - 1]); - if (s2[0] == '"' || s2[n - 1] == '"') + if (cf == '"' || cf == '\'' || cl == '"' || cl == '\'') { - if (n == 1 || s2[0] != s2[n - 1]) + if (n == 1 || cf != cl) throw unmatched_quote (s2); s2 = string (s2, 1, n - 2); diff --git a/cli/runtime-source.cxx b/cli/runtime-source.cxx index 348d7b7..e2008ad 100644 --- a/cli/runtime-source.cxx +++ b/cli/runtime-source.cxx @@ -392,10 +392,11 @@ generate_runtime_source (context& ctx) << "// If the string is wrapped in quotes, remove them." << endl << "//" << endl << "n = s2.size ();" + << "char cf (s2[0]), cl (s2[n - 1]);" << endl - << "if (s2[0] == '\"' || s2[n - 1] == '\"')" + << "if (cf == '\"' || cf == '\\'' || cl == '\"' || cl == '\\'')" << "{" - << "if (n == 1 || s2[0] != s2[n - 1])" << endl + << "if (n == 1 || cf != cl)" << endl << "throw unmatched_quote (s2);" << endl << "s2 = string (s2, 1, n - 2);" |