Skip to content

Commit a56d2b7

Browse files
author
ldn-softdev
committed
minor improvement for parsing of backslash in lexemes
1 parent 5e3c030 commit a56d2b7

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

jtc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,7 @@ void Jtc::walk_interleaved_(wlk_subscr Jtc::* subscriber) {
26462646
}
26472647
hwlk_ = move(ARY{STR{}}); // reset hwlk_ to init value
26482648
// json.ns() may hold now the latest updated namespace while wns_ might not even have been
2649-
// updated (e.g. when walk has ended as <>F, or out of iterations), thus require syncing
2649+
// updated (e.g.: when walk has ended as <>F, or out of iterations), thus require syncing
26502650
wns_[last_dwi_ptr_].sync_in(json().ns(), map_jnse::NsOpType::NsUpdate);
26512651

26522652
is_multi_walk_ = opt()[CHR(OPT_WLK)].hits() > 1 or // i.e. -w.. -w.., else (one -w..)

lib/Json.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3529,7 +3529,8 @@ std::string Json::extract_lexeme_(std::string::const_iterator &si, char closing)
35293529
std::string quoted{"\\"}; // replace quoted closing bracket
35303530
quoted += closing;
35313531
for(size_t p = lexeme.find(quoted); p != std::string::npos; p = lexeme.find(quoted, p))
3532-
lexeme.replace(p, 2, 1, closing);
3532+
if(p + quoted.size() >= lexeme.size()) break; // replace only if it's not last
3533+
else lexeme.replace(p, 2, 1, closing);
35333534
DBG(1) DOUT() << "parsed lexeme: " << lexeme << std::endl;
35343535
return lexeme;
35353536
}

0 commit comments

Comments
 (0)