From ba36f59f44b979f547caeb79f3e6818fa646ec01 Mon Sep 17 00:00:00 2001 From: Dan Green Date: Sun, 29 Dec 2024 16:30:42 -0800 Subject: [PATCH] Trim spaces from autoload plugin names --- firmware/src/dynload/autoload_plugins.hh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/firmware/src/dynload/autoload_plugins.hh b/firmware/src/dynload/autoload_plugins.hh index bcb7a6297..f01f998b9 100644 --- a/firmware/src/dynload/autoload_plugins.hh +++ b/firmware/src/dynload/autoload_plugins.hh @@ -12,7 +12,7 @@ struct AutoLoader { std::string message; }; - AutoLoader(PluginManager &plugins, PluginAutoloadSettings const &plugin_settings) + AutoLoader(PluginManager &plugins, PluginAutoloadSettings &plugin_settings) : plugin_settings{plugin_settings} , plugins{plugins} { } @@ -57,7 +57,10 @@ private: } auto &s = plugin_settings.slug[slug_idx]; - pr_trace("Autoload: Looking for plugin: %s\n", s.c_str()); + // trim leading and trailing whitespace on plugin name: + s = s.substr(0, s.find_last_not_of(" \t\n") + 1); + s = s.substr(s.find_first_not_of(" \t\n")); + pr_trace("Autoload: Looking for plugin: '%s'\n", s.c_str()); autoload_state = State::Processing; @@ -123,7 +126,7 @@ private: } if (!match) { - pr_info("Autoload: Can't find plugin: %.*s\n", (int)s.size(), s.data()); + pr_info("Autoload: Can't find plugin: '%.*s'\n", (int)s.size(), s.data()); return false; } @@ -133,7 +136,7 @@ private: return true; } - PluginAutoloadSettings const &plugin_settings; + PluginAutoloadSettings &plugin_settings; PluginManager &plugins; PluginFileList const *found_plugins = nullptr; unsigned slug_idx = 0;