From 48edfe540907e9b29e4e1425d014bed0e8aa0919 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Wed, 11 Mar 2009 20:18:37 +0000 Subject: [PATCH] Add Get_arglength, make trim(string a bit more flexible with whitespace so that configfiles from windows can be used on linux without converting Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3316 --- include/programs.h | 4 +++- src/misc/setup.cpp | 13 ++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/programs.h b/include/programs.h index a6f7e172..b86987a0 100644 --- a/include/programs.h +++ b/include/programs.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: programs.h,v 1.17 2008-07-26 19:06:26 qbix79 Exp $ */ +/* $Id: programs.h,v 1.18 2009-03-11 20:18:37 qbix79 Exp $ */ #ifndef DOSBOX_PROGRAMS_H #define DOSBOX_PROGRAMS_H @@ -54,6 +54,8 @@ public: bool GetStringRemain(std::string & value); unsigned int GetCount(void); void Shift(unsigned int amount=1); + Bit16u Get_arglength(); + private: typedef std::list::iterator cmd_it; std::list cmds; diff --git a/src/misc/setup.cpp b/src/misc/setup.cpp index 2fb54478..1cbbea0e 100644 --- a/src/misc/setup.cpp +++ b/src/misc/setup.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: setup.cpp,v 1.54 2009-02-15 20:01:08 qbix79 Exp $ */ +/* $Id: setup.cpp,v 1.55 2009-03-11 20:18:37 qbix79 Exp $ */ #include "dosbox.h" #include "cross.h" @@ -556,9 +556,9 @@ Hex Section_prop::Get_hex(string const& _propname) const { } void trim(string& in) { - string::size_type loc = in.find_first_not_of(' '); + 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(' '); + loc = in.find_last_not_of(" \r\t\f\n"); if(loc != string::npos) in.erase(loc+1); } @@ -956,6 +956,13 @@ CommandLine::CommandLine(int argc,char const * const argv[]) { i++; } } +Bit16u CommandLine::Get_arglength() { + if(cmds.empty()) return 0; + Bit16u i=1; + for(cmd_it it=cmds.begin();it != cmds.end();it++) + i+=(*it).size() + 1; + return --i; +} CommandLine::CommandLine(char const * const name,char const * const cmdline) {