From fc8c9a6c7bec176299915c6adab120e1bf2ea4e9 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 1 May 2021 17:28:44 +0100 Subject: Lots of test cases, few minor fixes --- lib/jsonParse.impl.cpp | 5 ++++- lib/jsonParse.ll | 8 ++++---- lib/persistence.cpp | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/jsonParse.impl.cpp b/lib/jsonParse.impl.cpp index 3ed8e62..4d13eae 100644 --- a/lib/jsonParse.impl.cpp +++ b/lib/jsonParse.impl.cpp @@ -12,7 +12,7 @@ json::jsonParser::LexerError(const char * msg) void json::jsonParser::appendEscape(const char * cphs, std::string & str) { - appendEscape(std::strtoul(cphs, nullptr, 16), str); + appendEscape(std::strtoul(cphs + 1, nullptr, 16), str); } void @@ -39,4 +39,7 @@ json::jsonParser::appendEscape(unsigned long cp, std::string & str) str += char(((cp >> 6) & 63) + 128); str += char((cp & 63) + 128); } + else { + throw std::range_error("Invalid UTF-8 sequence"); + } } diff --git a/lib/jsonParse.ll b/lib/jsonParse.ll index 52ad89f..c9c708c 100644 --- a/lib/jsonParse.ll +++ b/lib/jsonParse.ll @@ -17,6 +17,7 @@ class jsonBaseFlexLexer; #ifdef __clang__ #pragma clang diagnostic ignored "-Wnull-conversion" #endif +[[maybe_unused]]static constexpr auto x=getpid; %} beginobj "{" @@ -152,7 +153,6 @@ text [^\\\"]* <*>[ \t\r\n\f] { } -%% - -// Make iwyu think unistd.h is required -[[maybe_unused]]static auto x=getpid; +<*>. { + LexerError("Unexpected input"); +} diff --git a/lib/persistence.cpp b/lib/persistence.cpp index 5744cd7..15391ad 100644 --- a/lib/persistence.cpp +++ b/lib/persistence.cpp @@ -62,6 +62,7 @@ namespace Persistence { throw std::runtime_error("Unexpected object"); } + /// LCOV_EXCL_START Don't think we can trigger these from something lexer will parse void Selection::beforeValue(Stack &) { @@ -78,4 +79,5 @@ namespace Persistence { Selection::endObject(Stack &) { } + /// LCOV_EXCL_STOP } -- cgit v1.2.3