summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-12-21 04:48:44 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-12-21 04:48:44 +0000
commitfdf50d475ee45cf58bfdee0d3aeb329ec148fb8b (patch)
tree14638ab3ca112c29a5c18ae3ac2cb00a09cd8157
parentUse fixture test suite to reduce repetition (diff)
downloadgentoobrowse-api-fdf50d475ee45cf58bfdee0d3aeb329ec148fb8b.tar.bz2
gentoobrowse-api-fdf50d475ee45cf58bfdee0d3aeb329ec148fb8b.tar.xz
gentoobrowse-api-fdf50d475ee45cf58bfdee0d3aeb329ec148fb8b.zip
Add support for escaped string content in unpack of PQ arrays
-rw-r--r--gentoobrowse-api/service/unpackPqTextArray.ll31
1 files changed, 26 insertions, 5 deletions
diff --git a/gentoobrowse-api/service/unpackPqTextArray.ll b/gentoobrowse-api/service/unpackPqTextArray.ll
index 6281063..9c53157 100644
--- a/gentoobrowse-api/service/unpackPqTextArray.ll
+++ b/gentoobrowse-api/service/unpackPqTextArray.ll
@@ -17,11 +17,14 @@ begin "{"
end "}"
comma ,
unquoted [^,\"}]+
-quoted (\"[^\"]+\")
+quote \"
+esc \\.
+char [^"]
%x FIRST
%x AFTER
%x NEXT
+%x QUOTED
%%
@@ -35,14 +38,32 @@ quoted (\"[^\"]+\")
list.push_back(YYText());
BEGIN(AFTER);
}
-<FIRST,NEXT>{quoted} {
- list.push_back(YYText());
- boost::algorithm::trim_if(list.back(), [](auto c){ return c == '"'; });
- BEGIN(AFTER);
+<FIRST,NEXT>{quote} {
+ list.push_back(std::string());
+ BEGIN(QUOTED);
}
<AFTER>{comma} {
BEGIN(NEXT);
}
+<QUOTED>{quote} {
+ BEGIN(AFTER);
+}
+<QUOTED>{esc} {
+ switch (*(YYText() + 1)) {
+ case '"':
+ list.back().push_back('"');
+ break;
+ case '\\':
+ list.back().push_back('\\');
+ break;
+ case 'n':
+ list.back().push_back('\n');
+ break;
+ }
+}
+<QUOTED>{char} {
+ list.back().append(YYText());
+}
%%