2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-02-06 02:30:44 +03:00

Cbuf_Execute: Add checks commented out for multi-lines. (#719)

This commit is contained in:
Dmitry Novikov 2021-01-28 05:41:57 +07:00 committed by GitHub
parent d6fff73df8
commit aaf56989f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -164,8 +164,9 @@ void Cbuf_Execute(void)
{ {
int i; int i;
char *text; char *text;
char line[MAX_CMD_LINE]; char line[MAX_CMD_LINE] = {0};
int quotes; int quotes;
bool commented;
while (cmd_text.cursize) while (cmd_text.cursize)
{ {
@ -173,12 +174,21 @@ void Cbuf_Execute(void)
text = (char *)cmd_text.data; text = (char *)cmd_text.data;
quotes = 0; quotes = 0;
commented = false;
#ifdef REHLDS_FIXES
if (cmd_text.cursize > 1 && text[0] == '/' && text[1] == '/')
commented = true;
#endif
for (i = 0; i < cmd_text.cursize; i++) for (i = 0; i < cmd_text.cursize; i++)
{ {
if (text[i] == '"') if (text[i] == '"')
quotes++; quotes++;
if (!(quotes & 1) && text[i] == ';')
break; // don't break if inside a quoted string if (!(quotes & 1) && !commented && text[i] == ';')
break; // don't break if inside a quoted or commented out strings
if (text[i] == '\n') if (text[i] == '\n')
break; break;
} }