From e742952db8890d75ceddb28650d69b1c9c4adb90 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Thu, 28 Aug 2014 20:34:05 -0500 Subject: [PATCH] Port COM_ParseExt fixes to CommaParse --- code/renderergl1/tr_image.c | 14 ++++++-------- code/renderergl2/tr_image.c | 14 ++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/code/renderergl1/tr_image.c b/code/renderergl1/tr_image.c index dc7860ea..f8a88991 100644 --- a/code/renderergl1/tr_image.c +++ b/code/renderergl1/tr_image.c @@ -1443,12 +1443,15 @@ static char *CommaParse( char **data_p ) { // skip double slash comments if ( c == '/' && data[1] == '/' ) { - while (*data && *data != '\n') + data += 2; + while (*data && *data != '\n') { data++; + } } // skip /* */ comments else if ( c=='/' && data[1] == '*' ) { + data += 2; while ( *data && ( *data != '*' || data[1] != '/' ) ) { data++; @@ -1481,7 +1484,7 @@ static char *CommaParse( char **data_p ) { *data_p = ( char * ) data; return com_token; } - if (len < MAX_TOKEN_CHARS) + if (len < MAX_TOKEN_CHARS - 1) { com_token[len] = c; len++; @@ -1492,7 +1495,7 @@ static char *CommaParse( char **data_p ) { // parse a regular word do { - if (len < MAX_TOKEN_CHARS) + if (len < MAX_TOKEN_CHARS - 1) { com_token[len] = c; len++; @@ -1501,11 +1504,6 @@ static char *CommaParse( char **data_p ) { c = *data; } while (c>32 && c != ',' ); - if (len == MAX_TOKEN_CHARS) - { -// ri.Printf (PRINT_DEVELOPER, "Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS); - len = 0; - } com_token[len] = 0; *data_p = ( char * ) data; diff --git a/code/renderergl2/tr_image.c b/code/renderergl2/tr_image.c index 6c8dc456..e7b0e54d 100644 --- a/code/renderergl2/tr_image.c +++ b/code/renderergl2/tr_image.c @@ -3007,12 +3007,15 @@ static char *CommaParse( char **data_p ) { // skip double slash comments if ( c == '/' && data[1] == '/' ) { - while (*data && *data != '\n') + data += 2; + while (*data && *data != '\n') { data++; + } } // skip /* */ comments else if ( c=='/' && data[1] == '*' ) { + data += 2; while ( *data && ( *data != '*' || data[1] != '/' ) ) { data++; @@ -3045,7 +3048,7 @@ static char *CommaParse( char **data_p ) { *data_p = ( char * ) data; return com_token; } - if (len < MAX_TOKEN_CHARS) + if (len < MAX_TOKEN_CHARS - 1) { com_token[len] = c; len++; @@ -3056,7 +3059,7 @@ static char *CommaParse( char **data_p ) { // parse a regular word do { - if (len < MAX_TOKEN_CHARS) + if (len < MAX_TOKEN_CHARS - 1) { com_token[len] = c; len++; @@ -3065,11 +3068,6 @@ static char *CommaParse( char **data_p ) { c = *data; } while (c>32 && c != ',' ); - if (len == MAX_TOKEN_CHARS) - { -// ri.Printf (PRINT_DEVELOPER, "Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS); - len = 0; - } com_token[len] = 0; *data_p = ( char * ) data;