Skip to content

Commit

Permalink
Trim spaces from autoload plugin names
Browse files Browse the repository at this point in the history
  • Loading branch information
danngreen committed Dec 30, 2024
1 parent 42ec0b4 commit ba36f59
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions firmware/src/dynload/autoload_plugins.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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} {
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down

0 comments on commit ba36f59

Please sign in to comment.