aboutsummaryrefslogtreecommitdiff
path: root/butl/char-scanner.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-05-01 16:08:43 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-05-01 16:59:24 +0300
commit61377c582e0f2675baa5f5e6e30a35d1a4164b33 (patch)
tree11cdca992834d7f7f197f72856712fbcb3020e3d /butl/char-scanner.cxx
parent442c1a6790e52baa0c081f310d4d9e9b6f1ff638 (diff)
Add hxx extension for headers and lib prefix for library dir
Diffstat (limited to 'butl/char-scanner.cxx')
-rw-r--r--butl/char-scanner.cxx91
1 files changed, 0 insertions, 91 deletions
diff --git a/butl/char-scanner.cxx b/butl/char-scanner.cxx
deleted file mode 100644
index 8be7520..0000000
--- a/butl/char-scanner.cxx
+++ /dev/null
@@ -1,91 +0,0 @@
-// file : butl/char-scanner.cxx -*- C++ -*-
-// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
-// license : MIT; see accompanying LICENSE file
-
-#include <butl/char-scanner>
-
-#include <istream>
-
-using namespace std;
-
-namespace butl
-{
- auto char_scanner::
- peek () -> xchar
- {
- if (unget_)
- return buf_;
- else
- {
- if (eos_)
- return xchar (xchar::traits_type::eof (), line, column);
- else
- {
- xchar::int_type v (is_.peek ());
-
- if (v == xchar::traits_type::eof ())
- eos_ = true;
- else if (crlf_ && v == 0x0D)
- {
- is_.get ();
- xchar::int_type v1 (is_.peek ());
-
- if (v1 != '\n')
- {
- unget_ = true;
- buf_ = '\n';
- }
-
- v = '\n';
- }
-
- return xchar (v, line, column);
- }
- }
- }
-
- auto char_scanner::
- get () -> xchar
- {
- if (unget_)
- {
- unget_ = false;
- return buf_;
- }
- else
- {
- // When is_.get () returns eof, the failbit is also set (stupid,
- // isn't?) which may trigger an exception. To work around this
- // we will call peek() first and only call get() if it is not
- // eof. But we can only call peek() on eof once; any subsequent
- // calls will spoil the failbit (even more stupid).
- //
- xchar c (peek ());
-
- if (!eos (c))
- {
- is_.get ();
-
- if (c == '\n')
- {
- line++;
- column = 1;
- }
- else
- column++;
- }
-
- return c;
- }
- }
-
- void char_scanner::
- unget (const xchar& c)
- {
- // Because iostream::unget cannot work once eos is reached,
- // we have to provide our own implementation.
- //
- buf_ = c;
- unget_ = true;
- }
-}