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
This commit is contained in:
parent
2fd9c8f349
commit
48edfe5409
2 changed files with 13 additions and 4 deletions
|
@ -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<std::string>::iterator cmd_it;
|
||||
std::list<std::string> cmds;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue