From 54c993669aa4f734f6f0604d075bde6bf78007f1 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Sun, 6 May 2018 19:34:22 +0000 Subject: [PATCH] Strip spaces properly. Fixes bug #480 Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4100 --- include/support.h | 1 + src/gui/midi.cpp | 2 +- src/misc/setup.cpp | 7 ------- src/misc/support.cpp | 8 +++++++- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/support.h b/include/support.h index f20822be..91643fb1 100644 --- a/include/support.h +++ b/include/support.h @@ -53,6 +53,7 @@ bool IsHexWord(char * word); Bits ConvDecWord(char * word); Bits ConvHexWord(char * word); +void trim(std::string& str); void upcase(std::string &str); void lowcase(std::string &str); diff --git a/src/gui/midi.cpp b/src/gui/midi.cpp index f1d3e2f2..88196c2e 100644 --- a/src/gui/midi.cpp +++ b/src/gui/midi.cpp @@ -177,7 +177,7 @@ public: fullconf.erase(fullconf.find("delaysysex")); LOG_MSG("MIDI: Using delayed SysEx processing"); } - std::remove(fullconf.begin(), fullconf.end(), ' '); + trim(fullconf); const char * conf = fullconf.c_str(); midi.status=0x00; midi.cmd_pos=0; diff --git a/src/misc/setup.cpp b/src/misc/setup.cpp index a15c289c..957ef08f 100644 --- a/src/misc/setup.cpp +++ b/src/misc/setup.cpp @@ -608,13 +608,6 @@ Hex Section_prop::Get_hex(string const& _propname) const { return 0; } -void trim(string& in) { - string::size_type loc = in.find_first_not_of(" \r\t\f\n"); - if (loc != string::npos) in.erase(0,loc); - loc = in.find_last_not_of(" \r\t\f\n"); - if (loc != string::npos) in.erase(loc+1); -} - bool Section_prop::HandleInputline(string const& gegevens){ string str1 = gegevens; string::size_type loc = str1.find('='); diff --git a/src/misc/support.cpp b/src/misc/support.cpp index 67bbe11d..9b766a64 100644 --- a/src/misc/support.cpp +++ b/src/misc/support.cpp @@ -43,7 +43,13 @@ void lowcase(std::string &str) { int (*tf)(int) = std::tolower; std::transform(str.begin(), str.end(), str.begin(), tf); } - + +void trim(std::string &str) { + std::string::size_type loc = str.find_first_not_of(" \r\t\f\n"); + if (loc != std::string::npos) str.erase(0,loc); + loc = str.find_last_not_of(" \r\t\f\n"); + if (loc != std::string::npos) str.erase(loc+1); +} /* Ripped some source from freedos for this one.