From 0e48d7916288094033c09e693728d16a9cdbc931 Mon Sep 17 00:00:00 2001 From: Daniel Caujolle-Bert Date: Wed, 5 Jan 2022 08:54:06 +0000 Subject: [PATCH] Apply left trim to remote command argument (otherwise string compare are failing); --- YSFGateway/YSFGateway.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 24831d2..dd678d6 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -47,6 +47,7 @@ const char* DEFAULT_INI_FILE = "/etc/YSFGateway.ini"; #include #include #include +#include int main(int argc, char** argv) { @@ -880,6 +881,8 @@ void CYSFGateway::processRemoteCommands() buffer[res] = '\0'; if (::memcmp(buffer + 0U, "LinkYSF", 7U) == 0) { std::string id = std::string((char*)(buffer + 7U)); + // Left trim + id.erase(id.begin(), std::find_if(id.begin(), id.end(), std::not1(std::ptr_fun(std::isspace)))); CYSFReflector* reflector = m_reflectors->findById(id); if (reflector == NULL) reflector = m_reflectors->findByName(id); @@ -909,6 +912,8 @@ void CYSFGateway::processRemoteCommands() } } else if (::memcmp(buffer + 0U, "LinkFCS", 7U) == 0) { std::string raw = std::string((char*)(buffer + 7U)); + // Left trim + raw.erase(raw.begin(), std::find_if(raw.begin(), raw.end(), std::not1(std::ptr_fun(std::isspace)))); std::string id = "FCS00"; std::string idShort = "FCS"; if (raw.length() == 3U) {