Properly implement DO_NOT_MODIFY_CACHE

This fixes node_to_string() by making sure the node is really not modified.
This commit is contained in:
Gunter Labes 2024-07-19 17:58:18 +02:00
parent 0aa93bf94c
commit 6bc7a80b5d
No known key found for this signature in database
GPG key ID: C0C7B971CC910216

View file

@ -756,12 +756,16 @@ void node::output(char*& buf, CACHE_STATUS cache_status)
for(std::vector<attribute>::iterator i = attr_.begin(); i != attr_.end(); ++i) {
memcpy(buf, i->key.begin(), i->key.size());
i->key = string_span(buf, i->key.size());
if(cache_status == REFRESH_CACHE) {
i->key = string_span(buf, i->key.size());
}
buf += i->key.size();
*buf++ = '=';
*buf++ = '"';
memcpy(buf, i->value.begin(), i->value.size());
i->value = string_span(buf, i->value.size());
if(cache_status == REFRESH_CACHE) {
i->value = string_span(buf, i->value.size());
}
buf += i->value.size();
*buf++ = '"';
*buf++ = '\n';
@ -774,7 +778,9 @@ void node::output(char*& buf, CACHE_STATUS cache_status)
string_span& attr = children_[i->child_map_index].first;
*buf++ = '[';
memcpy(buf, attr.begin(), attr.size());
attr = string_span(buf, attr.size());
if(cache_status == REFRESH_CACHE) {
attr = string_span(buf, attr.size());
}
buf += attr.size();
*buf++ = ']';
*buf++ = '\n';