From 3c087fa8438c0ab9421ed072e47e77df6a7519f1 Mon Sep 17 00:00:00 2001 From: bhuvan-somisetty Date: Mon, 9 Nov 2026 01:43:56 +0530 Subject: [PATCH 1/2] ci: fix C++ tryparam test path and pin Python test job to ubuntu-24.04 The comma-in-value tryparam test wrote concore.params to in/1/, but load_params reads from inpath + "1/concore.params" (in1/), so it never found the file. ubuntu-latest now resolves to 26.04, where setup-python has no 3.9 build. Pin the Python test matrix to ubuntu-24.04 so 3.9 keeps running. Signed-off-by: bhuvan-somisetty --- .github/workflows/ci.yml | 2 +- TestConcoreHpp.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb47fa0..1f01f61 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: run: ruff check . --output-format=github test: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 strategy: matrix: python-version: ['3.9', '3.10', '3.11', '3.12'] diff --git a/TestConcoreHpp.cpp b/TestConcoreHpp.cpp index 6b6ad2c..f7311af 100644 --- a/TestConcoreHpp.cpp +++ b/TestConcoreHpp.cpp @@ -333,7 +333,7 @@ static void test_load_params_semicolon_format() { static void test_tryparam_comma_in_value() { setup_dirs(); - write_file("in/1/concore.params", "{'channels': [1, 2], 'gain': '0.5'}"); + write_file("in1/concore.params", "{'channels': [1, 2], 'gain': '0.5'}"); Concore c; c.delay = 0; @@ -342,7 +342,7 @@ static void test_tryparam_comma_in_value() { check("tryparam preserves list with comma", c.tryparam("channels", "") == "[1, 2]"); check("tryparam preserves subsequent key", c.tryparam("gain", "") == "0.5"); - rm("in/1/concore.params"); + rm("in1/concore.params"); } // ------------- main ------------------------------------------------------- From e74825325f3601b4a2fc60807010b94f16f03fe7 Mon Sep 17 00:00:00 2001 From: bhuvan-somisetty Date: Sun, 15 Nov 2026 01:38:29 +0530 Subject: [PATCH 2/2] fix(cpp): keep key=value params with unquoted string values load_params turned a=1;b=x into dict text and parsedict threw on the bare word, so every param was dropped. Split on ; and = directly instead, like the python side. Signed-off-by: bhuvan-somisetty --- TestConcoreHpp.cpp | 17 +++++++++++++++++ concore_base.hpp | 25 ++++++++++++------------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/TestConcoreHpp.cpp b/TestConcoreHpp.cpp index f7311af..72084be 100644 --- a/TestConcoreHpp.cpp +++ b/TestConcoreHpp.cpp @@ -331,6 +331,22 @@ static void test_load_params_semicolon_format() { rm("in1/concore.params"); } +static void test_load_params_semicolon_bare_words() { + setup_dirs(); + write_file("in1/concore.params", "n=3;mode=fast;name=hello world;url=http://x.org/a?b=c"); + + Concore c; + c.delay = 0; + c.load_params(); + + check("bare word keeps numeric param", c.tryparam("n", "") == "3"); + check("bare word value", c.tryparam("mode", "") == "fast"); + check("bare word keeps spaces", c.tryparam("name", "") == "hello world"); + check("bare word keeps '=' in value", c.tryparam("url", "") == "http://x.org/a?b=c"); + + rm("in1/concore.params"); +} + static void test_tryparam_comma_in_value() { setup_dirs(); write_file("in1/concore.params", "{'channels': [1, 2], 'gain': '0.5'}"); @@ -382,6 +398,7 @@ int main() { test_tryparam_found(); test_tryparam_missing_key_uses_default(); test_load_params_semicolon_format(); + test_load_params_semicolon_bare_words(); test_tryparam_comma_in_value(); std::cout << "\n=== Results: " << passed << " passed, " << failed diff --git a/concore_base.hpp b/concore_base.hpp index 524d5ba..2aff0a8 100644 --- a/concore_base.hpp +++ b/concore_base.hpp @@ -365,19 +365,18 @@ inline std::map load_params(const std::string& params_ try { return parsedict(sparams); } catch (...) {} } - // Otherwise convert semicolon-separated key=value to dict format - // e.g. "a=1;b=2" -> {"a":"1","b":"2"} - std::string normalized = std::regex_replace(sparams, std::regex(";"), ","); - std::string converted = "{\"" + - std::regex_replace( - std::regex_replace( - std::regex_replace(normalized, std::regex(","), ",\""), - std::regex("="), "\":"), - std::regex(" "), "") + - "}"; - try { return parsedict(converted); } catch (...) {} - - return {}; + // Otherwise split semicolon-separated key=value, keeping bare words as strings + std::map result; + std::stringstream items(sparams); + std::string item; + while (std::getline(items, item, ';')) { + size_t eq = item.find('='); + if (eq == std::string::npos) continue; + std::string key = stripstr(item.substr(0, eq)); + if (key.empty()) continue; + result[key] = stripquotes(stripstr(item.substr(eq + 1))); + } + return result; } /**