From 2e404c623d57fb66197a07af2b4d5bbc74af0644 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Thu, 15 Oct 2026 23:32:13 +0300 Subject: [PATCH] dead code elim --- config.cpp | 13 +++++++++++-- main.cpp | 10 ---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/config.cpp b/config.cpp index 391703c..bb35b58 100644 --- a/config.cpp +++ b/config.cpp @@ -134,6 +134,15 @@ Cfg get_cfg(std::string_view path) { } int set_cfg(std::string_view path, std::string_view key, std::string_view val) { + /* Strip a single pair of surrounding quotes so a value containing spaces can + * be passed as e.g. "a b" without the quote characters becoming part of the + * stored value. */ + std::string vstr(val); + if (vstr.size() >= 2 && + ((vstr.front() == '"' && vstr.back() == '"') || + (vstr.front() == '\'' && vstr.back() == '\''))) { + vstr = vstr.substr(1, vstr.size() - 2); + } std::vector lines; { std::string content; @@ -157,7 +166,7 @@ int set_cfg(std::string_view path, std::string_view key, std::string_view val) { std::string_view keyPart = sv.substr(k, eq - k); while (!keyPart.empty() && std::isspace((unsigned char)keyPart.back())) keyPart.remove_suffix(1); if (keyPart == key) { - line = sfmt("%s=%s\n", std::string(key).c_str(), std::string(val).c_str()); + line = sfmt("%s=%s\n", std::string(key).c_str(), vstr.c_str()); found = true; } } @@ -166,7 +175,7 @@ int set_cfg(std::string_view path, std::string_view key, std::string_view val) { std::string &last = lines.back(); if (!last.empty() && last.back() != '\n') last += '\n'; } - lines.push_back(sfmt("%s=%s\n", std::string(key).c_str(), std::string(val).c_str())); + lines.push_back(sfmt("%s=%s\n", std::string(key).c_str(), vstr.c_str())); } std::string out_buf; for (auto &line : lines) out_buf += line; diff --git a/main.cpp b/main.cpp index 049a9f5..c0186a4 100644 --- a/main.cpp +++ b/main.cpp @@ -118,10 +118,6 @@ static bool trim_is_empty(std::string_view s) { while (i < s.size() && (s[i] == ' ' || s[i] == '\n' || s[i] == '\r' || s[i] == '\t')) i++; return i == s.size(); } -static std::string last_role(Messages &msgs) { - if (msgs.items.empty()) return ""; - return msgs.items.back().role; -} /* ----------------------------- AL loop -------------------------------- */ static int AL(Cfg &cfg, Messages &msgs, Usage &out, volatile int *interrupted, std::string *err) { @@ -280,12 +276,6 @@ static int run_turn(Cfg &cfg, Messages &msgs, Usage &usage, std::string *err, vo *interrupted = 0; usage = Usage{}; int rc = AL(cfg, msgs, usage, interrupted, err); - if (last_role(msgs) == "tool") { - Message cont; cont.role = "user"; cont.content = "continue"; - msgs.items.push_back(cont); - cprint("[auto continue: last message was a tool result]\n", std::array{33}); - rc = AL(cfg, msgs, usage, interrupted, err); - } if (rc != 0) { if (*interrupted) { cprint("\n[interrupted]\n", std::array{33}); } else { cprint("\n[error: ", std::array{31}); cprint((!err || err->empty()) ? "error" : *err, std::array{31}); cprint("]\n", std::array{31}); }