From 50cb16a1c276b055ee3bd0654298250927c24321 Mon Sep 17 00:00:00 2001 From: flowtron Date: Thu, 13 May 2010 21:47:32 +0000 Subject: [PATCH] added "\r" to whitespaceskip, not elementskip though. also fixed findlist bug [ http://sourceforge.net/tracker/?func=detail&aid=2981918&group_id=123597&atid=697089 ] - THX-2: General Disarray git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4849 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/command.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/source/src/command.cpp b/source/src/command.cpp index 81ffd13e..62eb5f30 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -753,7 +753,7 @@ void format(char **args, int numargs) result(s.getbuf()); } -#define whitespaceskip s += strspn(s, "\n\t ") +#define whitespaceskip s += strspn(s, "\n\t \r") #define elementskip *s=='"' ? (++s, s += strcspn(s, "\"\n\0"), s += *s=='"') : s += strcspn(s, "\n\t \0") void explodelist(const char *s, vector &elems) @@ -803,19 +803,20 @@ void at(char *s, char *pos) int find(const char *s, const char *key) { whitespaceskip; - for(int i = 0; *s; i++) - { - const char *a = s, *e = s; - elementskip; - if(*e=='"') - { - e++; - if(s[-1]=='"') --s; - } - if(!strncmp(e, key, s-e)) return i; - else s = a; - elementskip, whitespaceskip; - } + int len = strlen(key); + for(int i = 0; *s; i++) + { + const char *a = s, *e = s; + elementskip; + if(*e=='"') + { + e++; + if(s[-1]=='"') --s; + } + if(s-e==len && !strncmp(e, key, s-e)) return i; + else s = a; + elementskip, whitespaceskip; + } return -1; }