From d738c533328af401c68937fef3f62137ddbaf413 Mon Sep 17 00:00:00 2001 From: danij Date: Sat, 25 Jan 2014 10:47:53 +0000 Subject: [PATCH] libcommon|HexLex: Cleanup --- doomsday/plugins/common/src/hexlex.cpp | 44 ++++++++++++-------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/doomsday/plugins/common/src/hexlex.cpp b/doomsday/plugins/common/src/hexlex.cpp index ab46900f41..92160719e9 100644 --- a/doomsday/plugins/common/src/hexlex.cpp +++ b/doomsday/plugins/common/src/hexlex.cpp @@ -71,10 +71,10 @@ HexLex::~HexLex() void HexLex::parse(Str const *script) { - _script = script; - _readPos = 0; - _lineNumber = 1; - _alreadyGot = false; + _script = script; + _readPos = 0; + _lineNumber = 1; + _alreadyGot = false; Str_Clear(&_token); } @@ -181,19 +181,22 @@ bool HexLex::readToken() return true; } -Str const *HexLex::readString() +void HexLex::unreadToken() { - if(!readToken()) + if(_readPos == 0) { - syntaxError("Missing string"); + return; } + _alreadyGot = true; +} + +Str const *HexLex::token() +{ return &_token; } int HexLex::readNumber() { - checkOpen(); - if(!readToken()) { syntaxError("Missing integer"); @@ -210,30 +213,25 @@ int HexLex::readNumber() return number; } -Uri *HexLex::readUri(char const *defaultScheme) +Str const *HexLex::readString() { if(!readToken()) { - syntaxError("Missing uri"); + syntaxError("Missing string"); } - - Uri *uri = Uri_SetScheme(Uri_New(), defaultScheme); - Uri_SetPath(uri, Str_Text(Str_PercentEncode(AutoStr_FromTextStd(Str_Text(&_token))))); - return uri; + return &_token; } -void HexLex::unreadToken() +Uri *HexLex::readUri(char const *defaultScheme) { - if(_readPos == 0) + if(!readToken()) { - return; + syntaxError("Missing uri"); } - _alreadyGot = true; -} -Str const *HexLex::token() -{ - return &_token; + Uri *uri = Uri_SetScheme(Uri_New(), defaultScheme); + Uri_SetPath(uri, Str_Text(Str_PercentEncode(AutoStr_FromTextStd(Str_Text(&_token))))); + return uri; } int HexLex::lineNumber() const