summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-18 13:25:27 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-18 13:25:27 +0200
commit24316f2e717237d754c6b1ce75be024e4ef34edb (patch)
tree6590ed660ff9334ec2dd10d794106913a78cbf33 /src
parent655c0384179f3a72132784bb85f0d722231b8e11 (diff)
Fix trailing spaces in config
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.cpp6
-rw-r--r--src/helpers/MiscFunctions.cpp12
-rw-r--r--src/helpers/MiscFunctions.hpp3
3 files changed, 18 insertions, 3 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 7a42137b..54bc2c0c 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -82,6 +82,7 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s
return;
}
+
auto& CONFIGENTRY = configValues.at(COMMAND);
if (CONFIGENTRY.intValue != -1) {
try {
@@ -271,8 +272,9 @@ void CConfigManager::parseLine(std::string& line) {
if (EQUALSPLACE == std::string::npos)
return;
- const auto COMMAND = line.substr(0, EQUALSPLACE);
- const auto VALUE = line.substr(EQUALSPLACE + 1);
+ const auto COMMAND = removeBeginEndSpacesTabs(line.substr(0, EQUALSPLACE));
+ const auto VALUE = removeBeginEndSpacesTabs(line.substr(EQUALSPLACE + 1));
+ //
if (COMMAND == "exec") {
if (isFirstLaunch) {
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp
index a3aa7871..63751781 100644
--- a/src/helpers/MiscFunctions.cpp
+++ b/src/helpers/MiscFunctions.cpp
@@ -61,4 +61,16 @@ void scaleBox(wlr_box* box, float scale) {
box->height = std::round((box->y + box->height) * scale) - std::round(box->y * scale);
box->x = std::round(box->x * scale);
box->y = std::round(box->y * scale);
+}
+
+std::string removeBeginEndSpacesTabs(std::string str) {
+ while (str[0] == ' ' || str[0] == '\t') {
+ str = str.substr(1);
+ }
+
+ while (str[str.length() - 1] == ' ' || str[str.length() - 1] == '\t') {
+ str = str.substr(0, str.length() - 1);
+ }
+
+ return str;
} \ No newline at end of file
diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp
index c4192ff1..08e69e34 100644
--- a/src/helpers/MiscFunctions.hpp
+++ b/src/helpers/MiscFunctions.hpp
@@ -5,4 +5,5 @@
void addWLSignal(wl_signal*, wl_listener*, void* pOwner, std::string ownerString);
void wlr_signal_emit_safe(struct wl_signal *signal, void *data);
std::string getFormat(const char *fmt, ...); // Basically Debug::log to a string
-void scaleBox(wlr_box*, float); \ No newline at end of file
+void scaleBox(wlr_box*, float);
+std::string removeBeginEndSpacesTabs(std::string); \ No newline at end of file