From 112a83c346a537f1a5eac6fc17ee2ce3143d625b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 18 Jun 2020 16:40:00 +0300 Subject: Fix lexer to fail on invalid UTF-8 sequences --- libbuild2/lexer.ixx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 libbuild2/lexer.ixx (limited to 'libbuild2/lexer.ixx') diff --git a/libbuild2/lexer.ixx b/libbuild2/lexer.ixx new file mode 100644 index 0000000..04899f0 --- /dev/null +++ b/libbuild2/lexer.ixx @@ -0,0 +1,33 @@ +// file : libbuild2/lexer.ixx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +namespace build2 +{ + inline auto lexer:: + get () -> xchar + { + xchar c (base::get (ebuf_)); + + if (invalid (c)) + fail_char (c); + + return c; + } + + inline void lexer:: + get (const xchar& peeked) + { + base::get (peeked); + } + + inline auto lexer:: + peek () -> xchar + { + xchar c (base::peek (ebuf_)); + + if (invalid (c)) + fail_char (c); + + return c; + } +} -- cgit v1.1