From 4307d0cdde377e916a8756dede7180369016a2bd Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 28 May 2009 15:38:36 +0000 Subject: [PATCH] do not exit comment by ;, only by linefeed git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8994 d7cf8633-e32d-0410-b094-e92efae38249 --- cmd.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/cmd.c b/cmd.c index 73f55456..366b33b8 100644 --- a/cmd.c +++ b/cmd.c @@ -291,7 +291,7 @@ void Cbuf_Execute (void) char line[MAX_INPUTLINE]; char preprocessed[MAX_INPUTLINE]; char *firstchar; - int quotes; + qboolean quotes, comment; // LordHavoc: making sure the tokenizebuffer doesn't get filled up by repeated crashes cmd_tokenizebufferpos = 0; @@ -302,17 +302,31 @@ void Cbuf_Execute (void) // find a \n or ; line break text = (char *)cmd_text.data; - quotes = 0; - for (i=0 ; i< cmd_text.cursize ; i++) + quotes = false; + comment = false; + for (i=0 ; i < cmd_text.cursize ; i++) { - if (text[i] == '"') - quotes ^= 1; - // make sure i doesn't get > cursize which causes a negative - // size in memmove, which is fatal --blub - if (i < (cmd_text.cursize-1) && (text[i] == '\\' && (text[i+1] == '"' || text[i+1] == '\\'))) - i++; - if ( !quotes && text[i] == ';') - break; // don't break if inside a quoted string + if(!comment) + { + if (text[i] == '"') + quotes = !quotes; + + if(quotes) + { + // make sure i doesn't get > cursize which causes a negative + // size in memmove, which is fatal --blub + if (i < (cmd_text.cursize-1) && (text[i] == '\\' && (text[i+1] == '"' || text[i+1] == '\\'))) + i++; + } + else + { + if(text[i] == '/' && text[i + 1] == '/') + comment = true; + if(text[i] == ';') + break; // don't break if inside a quoted string or comment + } + } + if (text[i] == '\r' || text[i] == '\n') break; } -- 2.39.2