aboutsummaryrefslogtreecommitdiff
path: root/build2/lexer.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-07-23 16:09:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-07-25 08:05:43 +0200
commitad7d4bd0722aa70ba634900cebf93a1b1814fed9 (patch)
treefbfa28c4602dea0be178e63d1e6a1b2667e85190 /build2/lexer.cxx
parenta8bef4ff20100c518816c641ae1ff9783306c167 (diff)
Only do "effective escaping" (['"\$(]) on the command line
This will make things more convenient on Windows provided we use "sane" paths (no spaces, no (), etc).
Diffstat (limited to 'build2/lexer.cxx')
-rw-r--r--build2/lexer.cxx34
1 files changed, 19 insertions, 15 deletions
diff --git a/build2/lexer.cxx b/build2/lexer.cxx
index 773cd88..84e972e 100644
--- a/build2/lexer.cxx
+++ b/build2/lexer.cxx
@@ -4,6 +4,8 @@
#include <build2/lexer>
+#include <cstring> // strchr()
+
using namespace std;
namespace build2
@@ -309,10 +311,23 @@ namespace build2
if (c == '\\')
{
get ();
- c = escape ();
- if (c != '\n') // Ignore.
- lexeme += c;
- continue;
+ xchar e (peek ());
+
+ if (escapes_ == nullptr ||
+ (!eos (e) && strchr (escapes_, e) != nullptr))
+ {
+ get ();
+
+ if (eos (e))
+ fail (e) << "unterminated escape sequence";
+
+ if (e != '\n') // Ignore.
+ lexeme += e;
+
+ continue;
+ }
+ else
+ unget (c); // Treat as a normal character.
}
// If we are quoted, these are ordinary characters.
@@ -484,17 +499,6 @@ namespace build2
return r;
}
- lexer::xchar lexer::
- escape ()
- {
- xchar c (get ());
-
- if (eos (c))
- fail (c) << "unterminated escape sequence";
-
- return c;
- }
-
location_prologue lexer::fail_mark_base::
operator() (const xchar& c) const
{