From 2a1cee61e17a4e573e34b8615d2c524f445d85e6 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Wed, 18 Feb 2004 15:31:13 +0000 Subject: [PATCH] fixed tab problems when parsing commands (bug: #897177) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1682 --- include/shell.h | 4 ++-- src/misc/support.cpp | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/shell.h b/include/shell.h index 4d0bcd03..202b90b9 100644 --- a/include/shell.h +++ b/include/shell.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell.h,v 1.2 2004-01-10 14:03:33 qbix79 Exp $ */ +/* $Id: shell.h,v 1.3 2004-02-18 15:31:13 qbix79 Exp $ */ #ifndef SHELL_H_ #define SHELL_H_ @@ -119,7 +119,7 @@ struct SHELL_Cmd { static inline void StripSpaces(char*&args) { - while(*args && (*args == ' ')) + while(*args && ((*args == ' ') || (*args == '\t'))) args++; } diff --git a/src/misc/support.cpp b/src/misc/support.cpp index 0eadec29..eb95fbb5 100644 --- a/src/misc/support.cpp +++ b/src/misc/support.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: support.cpp,v 1.21 2004-01-10 14:03:35 qbix79 Exp $ */ +/* $Id: support.cpp,v 1.22 2004-02-18 15:31:13 qbix79 Exp $ */ #include #include @@ -90,7 +90,7 @@ bool ScanCMDBool(char * cmd,char * check) { while ((scan=strchr(scan,'/'))) { /* found a / now see behind it */ scan++; - if (strncasecmp(scan,check,c_len)==0 && (scan[c_len]==' ' || scan[c_len]=='/' || scan[c_len]==0)) { + if (strncasecmp(scan,check,c_len)==0 && (scan[c_len]==' ' || scan[c_len]=='\t' || scan[c_len]=='/' || scan[c_len]==0)) { /* Found a math now remove it from the string */ memmove(scan-1,scan+c_len,strlen(scan+c_len)+1); trim(scan-1); @@ -106,7 +106,7 @@ bool ScanCMDHex(char * cmd,char * check,Bits * result) { while ((scan=strchr(scan,'/'))) { /* found a / now see behind it */ scan++; - if (strncasecmp(scan,check,c_len)==0 && (scan[c_len]==' ' || scan[c_len]==0)) { + if (strncasecmp(scan,check,c_len)==0 && (scan[c_len]==' ' || scan[c_len]=='\t' || scan[c_len]==0)) { /* Found a match now find the number and remove it from the string */ char * begin=scan-1; scan=ltrim(scan+c_len); @@ -128,7 +128,7 @@ bool ScanCMDHex(char * cmd,char * check,Bits * result) { char * ScanCMDRemain(char * cmd) { char * scan,*found;; if ((scan=found=strchr(cmd,'/'))) { - while (*scan!=' ' && *scan!=0) scan++; + while (*scan!=' ' && *scan!='\t' && *scan!=0) scan++; *scan=0; return found; } else return 0; @@ -141,11 +141,16 @@ char * StripWord(char * cmd) { quoted=true; cmd++; } - char * end; + char * end = 0; if (quoted) { end=strchr(cmd,'"'); } else { - end=strchr(cmd,' '); + for(char* in=cmd;*in;in++){ + if(*in==' '||*in=='\t'){ + end=in; + break; + } + } } if (!end) { return cmd+strlen(cmd);