diff --git a/src/Pig.cpp b/src/Pig.cpp index 6fb93942..83374c84 100644 --- a/src/Pig.cpp +++ b/src/Pig.cpp @@ -33,15 +33,15 @@ //////////////////////////////////////////////////////////////////////////////// Pig::Pig (const std::string& text) : _text (text) -, _mark (0) , _cursor (0) -, _debug (false) { } //////////////////////////////////////////////////////////////////////////////// bool Pig::skipWS () { + auto save = _cursor; + int c; auto prev = _cursor; while ((c = utf8_next_char (_text, _cursor))) @@ -54,13 +54,7 @@ bool Pig::skipWS () prev = _cursor; } - if (_cursor > _mark) - { - _mark = _cursor; - return true; - } - - return false; + return _cursor > save; } //////////////////////////////////////////////////////////////////////////////// @@ -71,26 +65,18 @@ bool Pig::getDigit (int& result) { result = c - '0'; ++_cursor; - ++_mark; return true; } return false; } -//////////////////////////////////////////////////////////////////////////////// -void Pig::debug (bool value) -{ - _debug = value; -} - //////////////////////////////////////////////////////////////////////////////// std::string Pig::dump () const { std::stringstream out; out << "≪" << _text << "≫" << " l" << _text.length () - << " m" << _mark << " c" << _cursor; return out.str (); diff --git a/src/Pig.h b/src/Pig.h index 67bf6472..d8628141 100644 --- a/src/Pig.h +++ b/src/Pig.h @@ -38,14 +38,11 @@ public: bool getDigit (int&); - void debug (bool); std::string dump () const; private: const std::string& _text; - std::string::size_type _mark; std::string::size_type _cursor; - bool _debug; }; #endif diff --git a/test/pig.t.cpp b/test/pig.t.cpp index 406c7b5f..08980885 100644 --- a/test/pig.t.cpp +++ b/test/pig.t.cpp @@ -36,11 +36,11 @@ int main (int, char**) // Pig::skipWS Pig p0 (" one"); t.ok (p0.skipWS (), "skipWS ' one' -> true"); - t.is (p0.dump (), "≪ one≫ l5 m2 c2", "dump"); + t.is (p0.dump (), "≪ one≫ l5 c2", "dump"); t.diag (p0.dump ()); t.notok (p0.skipWS (), "skipWS 'one' -> false"); - t.is (p0.dump (), "≪ one≫ l5 m2 c2", "dump"); + t.is (p0.dump (), "≪ one≫ l5 c2", "dump"); t.diag (p0.dump ()); // Pig::getDigit @@ -48,11 +48,11 @@ int main (int, char**) int n; t.notok (p1.getDigit (n), "getDigit ' 123' --> false"); t.ok (p1.skipWS (), "skipWS ' 123' --> true"); - t.is (p1.dump (), "≪ 123≫ l4 m1 c1", "dump"); + t.is (p1.dump (), "≪ 123≫ l4 c1", "dump"); t.diag (p1.dump ()); t.ok (p1.getDigit (n), "getDigit '123' --> true"); t.is (n, 1, "getDigit '123' --> '1'"); - t.is (p1.dump (), "≪ 123≫ l4 m2 c2", "dump"); + t.is (p1.dump (), "≪ 123≫ l4 c2", "dump"); t.diag (p1.dump ()); return 0;