summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-05-01 17:28:44 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2021-11-07 16:41:37 +0000
commitfc8c9a6c7bec176299915c6adab120e1bf2ea4e9 (patch)
tree837426e53f3ec0cd06a6b7c9244c57a7c4229953 /lib
parentFix the fact I've been spelling persistence wrong this whole time (diff)
downloadilt-fc8c9a6c7bec176299915c6adab120e1bf2ea4e9.tar.bz2
ilt-fc8c9a6c7bec176299915c6adab120e1bf2ea4e9.tar.xz
ilt-fc8c9a6c7bec176299915c6adab120e1bf2ea4e9.zip
Lots of test cases, few minor fixes
Diffstat (limited to 'lib')
-rw-r--r--lib/jsonParse.impl.cpp5
-rw-r--r--lib/jsonParse.ll8
-rw-r--r--lib/persistence.cpp2
3 files changed, 10 insertions, 5 deletions
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
}