diff --git a/common/cmd.c b/common/cmd.c index b27a37c..5f04346 100644 --- a/common/cmd.c +++ b/common/cmd.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -153,51 +154,53 @@ void Cbuf_InsertText (char *text) } } -/* -============ -Cbuf_Execute -============ -*/ -void Cbuf_Execute (void) +static void +extract_line(char *line) { - int i;//, li; + int i; char *text; - char line[1024] = {0}; int quotes; - while (cmd_text.cursize) - { -// find a \n or ; line break - text = (char *)cmd_text.data; + // find a \n or ; line break + text = (char *)cmd_text.data; + quotes = 0; + for (i=0 ; i< cmd_text.cursize ; i++) { + if (text[i] == '"') + quotes++; + if ( !(quotes&1) && text[i] == ';') + break; // don't break if inside a quoted string + if (text[i] == '\n' || text[i] == '\r') + break; + } - quotes = 0; - for (i=0 ; i< cmd_text.cursize ; i++) - { - if (text[i] == '"') - quotes++; - if ( !(quotes&1) && text[i] == ';') - break; // don't break if inside a quoted string - if (text[i] == '\n' || text[i] == '\r') - break; - } + memcpy (line, text, i); + line[i] = '\0'; + // delete the text from the command buffer and move remaining commands down + // this is necessary because commands (exec, alias) can insert data at the + // beginning of the text buffer - memcpy (line, text, i); - line[i] = '\0'; + if (i == cmd_text.cursize) + cmd_text.cursize = 0; + else { + i++; + cmd_text.cursize -= i; + Q_memcpy (text, text+i, cmd_text.cursize); + } +} -// delete the text from the command buffer and move remaining commands down -// this is necessary because commands (exec, alias) can insert data at the -// beginning of the text buffer +/* - if (i == cmd_text.cursize) - cmd_text.cursize = 0; - else - { - i++; - cmd_text.cursize -= i; - Q_memcpy (text, text+i, cmd_text.cursize); - } + Cbuf_Execute -// execute the command line +*/ +void +Cbuf_Execute (void) +{ + char line[1024] = {0}; + + while (cmd_text.cursize) { + extract_line (line); + // execute the command line Cmd_ExecuteString (line, src_command); if (cmd_wait) @@ -208,6 +211,25 @@ void Cbuf_Execute (void) } } } +/* + + Cbuf_Execute + +*/ +void +Cbuf_Execute_Sets (void) +{ + char line[1024] = {0}; + + while (cmd_text.cursize) { + extract_line (line); + // execute the command line + if (strncmp(line,"set",3)==0 + && isspace(line[3])) + printf("+%s\n",line), + Cmd_ExecuteString (line, src_command); + } +} /* ============================================================================== diff --git a/common/cmd.h b/common/cmd.h index 8996b0e..6d55517 100644 --- a/common/cmd.h +++ b/common/cmd.h @@ -60,6 +60,7 @@ void Cbuf_InsertText (char *text); // commands. void Cbuf_Execute (void); +void Cbuf_Execute_Sets (void); // Pulls off \n terminated lines of text from the command buffer and sends // them through Cmd_ExecuteString. Stops when the buffer is empty. // Normally called once per frame, but may be explicitly invoked. diff --git a/common/host.c b/common/host.c index c7f21d9..6831caa 100644 --- a/common/host.c +++ b/common/host.c @@ -558,6 +558,7 @@ Host_Init (quakeparms_t *parms) // FIXME: stuff only +set here, shouldn't stuff all commands --KB Cmd_StuffCmds_f (); + Cbuf_Execute_Sets (); Cbuf_Execute (); V_Init ();