diff options
-rw-r--r-- | gentoobrowse-api/service/unpackPqTextArray.ll | 31 |
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()); +} %% |