Skip to content

Commit

Permalink
qiuckfix for an issue instroduced with the latest commit: first auto-…
Browse files Browse the repository at this point in the history
…token must point to the first element in the iterable
  • Loading branch information
ldn-softdev committed May 28, 2020
1 parent d3c193e commit bde89ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion jtc.cpp
Expand Up @@ -1771,7 +1771,7 @@ bool Jtc::advance_to_next_src(Json::iterator &jit, signed_size_t i) {
{ cerr << "fail: template argument failed interpolation" << endl; exit(RC_ARG_FAIL); }
wns_[&jit].sync_out(jtmp.ns(), map_jnse::NsOpType::NsReferAll);
}
jits_ = srcj.walk(jsrt_ == Src_optarg? "": jsrc_[idx()].str());
jits_ = srcj.walk(jsrt_ == Src_optarg? "": jsrc_[idx()].str(), Json::CacheState::Keep_cache);

if(jits_.is_valid()) { // jits_ resolved
DBG(4) DOUT() << "next selected source idx: " << idx() << endl;
Expand Down
9 changes: 7 additions & 2 deletions lib/Json.hpp
Expand Up @@ -2114,7 +2114,7 @@ class Json {
Json::ParseTrailing::Dont_parse);
auto restr = user_json.val(); // copy is required here
rexp = std::regex(restr, jsn.parse_RE_flags_(restr));
if(user_json.val() == stripped.front())
if(user_json.val() == stripped.front())
{ user_json.type(Jnode::Jtype::Neither); break; }
// user_json will not be set to Neither => dont intp. next time
else return true;
Expand Down Expand Up @@ -5053,8 +5053,9 @@ void Json::generate_auto_tokens_(Stringover &tmp, Json::iterator &jit, map_jne &
{ uct.insert( (*it)[2] ); sst.insert( to_lower((*it)[2]) ); }
}

Json &w = jit.json(); // needed for walk()
Json w; // needed for walk()
DBG(w, 4) { // debug print all found tokens
w.DBG().severity(NDBG);
DOUT(w) << "found tokens: ";
std::string dlm;
for(const auto &t: sst) {
Expand All @@ -5064,6 +5065,10 @@ void Json::generate_auto_tokens_(Stringover &tmp, Json::iterator &jit, map_jne &
DOUT(w) << std::endl;
}

auto move2json = [&w, &jit](void) { w.root() = std::move(*jit); return true; };
auto reinstate = [&w, &jit](bool unused) { *jit = std::move(w.root()); };
GUARD(move2json, reinstate);

auto wi = w.walk(sst.empty()?"":"><w:", Json::CacheState::Keep_cache);// walk only if there tokens
signed_size_t last_idx{0};
for(const auto &t: sst) { // interpolate found tokens into ns
Expand Down

0 comments on commit bde89ef

Please sign in to comment.