]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
do not exit comment by ;, only by linefeed
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 28 May 2009 15:38:36 +0000 (15:38 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 28 May 2009 15:38:36 +0000 (15:38 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8994 d7cf8633-e32d-0410-b094-e92efae38249

cmd.c

diff --git a/cmd.c b/cmd.c
index 73f55456e1cb393df9737e3c7084b0d2496dcad8..366b33b8c4eb25977219f03a5484f0dd68b9e592 100644 (file)
--- 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;
                }