mirror of
https://github.com/blendogames/thirtyflightsofloving.git
synced 2025-01-18 22:41:49 +00:00
Added Q_StrScanToken() to replace StringContainsToken() for non-ambiguous token searching.
Changed CL_FilterStuffText() to use Q_StrScanToken() instead of strstr().
This commit is contained in:
parent
b020f21541
commit
9b4e85322c
6 changed files with 81 additions and 26 deletions
|
@ -783,7 +783,8 @@ qboolean CL_FilterStuffText (char *stufftext)
|
||||||
// code by xian- cycle through list of malicious commands
|
// code by xian- cycle through list of malicious commands
|
||||||
while (bad_stuffcmds[i] != NULL)
|
while (bad_stuffcmds[i] != NULL)
|
||||||
{
|
{
|
||||||
if ( strstr(parsetext, bad_stuffcmds[i]) )
|
// if ( strstr(parsetext, bad_stuffcmds[i]) )
|
||||||
|
if ( Q_StrScanToken(parsetext, bad_stuffcmds[i], true) )
|
||||||
return false;
|
return false;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ extern int Q_SortStrcmp ( const char * * arg1 , const char * * arg2 ) ;
|
||||||
extern int Q_strcmp ( const char * string1 , const char * string2 ) ;
|
extern int Q_strcmp ( const char * string1 , const char * string2 ) ;
|
||||||
extern int Q_strncmp ( const char * string1 , const char * string2 , int n ) ;
|
extern int Q_strncmp ( const char * string1 , const char * string2 , int n ) ;
|
||||||
extern int Q_stricmp ( char * s1 , char * s2 ) ;
|
extern int Q_stricmp ( char * s1 , char * s2 ) ;
|
||||||
|
extern qboolean Q_StrScanToken ( const char * string , const char * findToken , qboolean isCommand ) ;
|
||||||
extern qboolean Q_GlobMatch ( const char * pattern , const char * text , qboolean caseSensitive ) ;
|
extern qboolean Q_GlobMatch ( const char * pattern , const char * text , qboolean caseSensitive ) ;
|
||||||
extern void Com_PageInMemory ( byte * buffer , int size ) ;
|
extern void Com_PageInMemory ( byte * buffer , int size ) ;
|
||||||
extern char * COM_ParseExt ( char * * data_p , qboolean allowNewLines ) ;
|
extern char * COM_ParseExt ( char * * data_p , qboolean allowNewLines ) ;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
{"Q_strcmp", (byte *)Q_strcmp},
|
{"Q_strcmp", (byte *)Q_strcmp},
|
||||||
{"Q_strncmp", (byte *)Q_strncmp},
|
{"Q_strncmp", (byte *)Q_strncmp},
|
||||||
{"Q_stricmp", (byte *)Q_stricmp},
|
{"Q_stricmp", (byte *)Q_stricmp},
|
||||||
|
{"Q_StrScanToken", (byte *)Q_StrScanToken},
|
||||||
{"Q_GlobMatch", (byte *)Q_GlobMatch},
|
{"Q_GlobMatch", (byte *)Q_GlobMatch},
|
||||||
{"Com_PageInMemory", (byte *)Com_PageInMemory},
|
{"Com_PageInMemory", (byte *)Com_PageInMemory},
|
||||||
{"COM_ParseExt", (byte *)COM_ParseExt},
|
{"COM_ParseExt", (byte *)COM_ParseExt},
|
||||||
|
|
|
@ -1818,6 +1818,55 @@ match:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
===============
|
||||||
|
Q_StrScanToken
|
||||||
|
|
||||||
|
A non-ambiguous alternative to strstr.
|
||||||
|
Useful for parsing the GL extension string.
|
||||||
|
Similar to code in Fruitz of Dojo Quake2 MacOSX Port.
|
||||||
|
isCommand parm allows for ';' as separator.
|
||||||
|
===============
|
||||||
|
*/
|
||||||
|
qboolean Q_StrScanToken (const char *string, const char *findToken, qboolean isCommand)
|
||||||
|
{
|
||||||
|
int tokenLen;
|
||||||
|
const char *strPos;
|
||||||
|
char *tokPos, *terminatorPos;
|
||||||
|
|
||||||
|
if ( !string || !findToken )
|
||||||
|
return false;
|
||||||
|
if ( (strchr(findToken, ' ') != NULL) || (findToken[0] == 0) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
strPos = string;
|
||||||
|
tokenLen = (int)strlen(findToken);
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
tokPos = strstr (strPos, findToken);
|
||||||
|
|
||||||
|
if ( !tokPos )
|
||||||
|
break;
|
||||||
|
|
||||||
|
terminatorPos = tokPos + tokenLen;
|
||||||
|
|
||||||
|
if (isCommand) {
|
||||||
|
if ( (tokPos == strPos || *(tokPos - 1) == ';' || *(tokPos - 1) == ' ') && (*terminatorPos == ';' || *terminatorPos == ' ' || *terminatorPos == 0) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( (tokPos == strPos || *(tokPos - 1) == ' ') && (*terminatorPos == ' ' || *terminatorPos == 0) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
strPos = terminatorPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
Q_stricmp
|
Q_stricmp
|
||||||
|
|
|
@ -458,6 +458,9 @@ int Q_strcmp (const char *string1, const char *string2);
|
||||||
// string compare for qsort calls
|
// string compare for qsort calls
|
||||||
int Q_SortStrcmp (const char **arg1, const char **arg2);
|
int Q_SortStrcmp (const char **arg1, const char **arg2);
|
||||||
|
|
||||||
|
// non-ambiguous string token search
|
||||||
|
qboolean Q_StrScanToken (const char *string, const char *findToken, qboolean isCommand);
|
||||||
|
|
||||||
// portable case insensitive string compare
|
// portable case insensitive string compare
|
||||||
int Q_stricmp (char *s1, char *s2);
|
int Q_stricmp (char *s1, char *s2);
|
||||||
int Q_strcasecmp (char *s1, char *s2);
|
int Q_strcasecmp (char *s1, char *s2);
|
||||||
|
|
|
@ -1156,7 +1156,7 @@ qboolean R_SetMode (void)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 // replaced by Q_StrScanToken()
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
StringContainsToken
|
StringContainsToken
|
||||||
|
@ -1197,7 +1197,7 @@ qboolean StringContainsToken (const char *string, const char *findToken)
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
|
@ -1228,7 +1228,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
glConfig.multitexture = true;
|
glConfig.multitexture = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( (!glConfig.multitexture) && StringContainsToken( glConfig.extensions_string, "GL_ARB_multitexture" ) )
|
if ( (!glConfig.multitexture) && Q_StrScanToken( glConfig.extensions_string, "GL_ARB_multitexture", false ) )
|
||||||
{
|
{
|
||||||
if (r_ext_multitexture->integer)
|
if (r_ext_multitexture->integer)
|
||||||
{
|
{
|
||||||
|
@ -1253,8 +1253,8 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
// GL_EXT_compiled_vertex_array
|
// GL_EXT_compiled_vertex_array
|
||||||
// GL_SGI_compiled_vertex_array
|
// GL_SGI_compiled_vertex_array
|
||||||
glConfig.extCompiledVertArray = false;
|
glConfig.extCompiledVertArray = false;
|
||||||
if ( StringContainsToken( glConfig.extensions_string, "GL_EXT_compiled_vertex_array" ) ||
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_EXT_compiled_vertex_array", false ) ||
|
||||||
StringContainsToken( glConfig.extensions_string, "GL_SGI_compiled_vertex_array" ) )
|
Q_StrScanToken( glConfig.extensions_string, "GL_SGI_compiled_vertex_array", false ) )
|
||||||
{
|
{
|
||||||
if (r_ext_compiled_vertex_array->integer) {
|
if (r_ext_compiled_vertex_array->integer) {
|
||||||
qglLockArraysEXT = (void *) qwglGetProcAddress( "glLockArraysEXT" );
|
qglLockArraysEXT = (void *) qwglGetProcAddress( "glLockArraysEXT" );
|
||||||
|
@ -1294,7 +1294,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
else
|
else
|
||||||
VID_Printf (PRINT_ALL, "...ignoring glDrawRangeElements\n");
|
VID_Printf (PRINT_ALL, "...ignoring glDrawRangeElements\n");
|
||||||
}
|
}
|
||||||
else if ( StringContainsToken( glConfig.extensions_string, "GL_EXT_draw_range_elements" ) )
|
else if ( Q_StrScanToken( glConfig.extensions_string, "GL_EXT_draw_range_elements", false ) )
|
||||||
{
|
{
|
||||||
if (r_ext_draw_range_elements->integer)
|
if (r_ext_draw_range_elements->integer)
|
||||||
{
|
{
|
||||||
|
@ -1317,7 +1317,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
|
|
||||||
// GL_ARB_texture_non_power_of_two
|
// GL_ARB_texture_non_power_of_two
|
||||||
glConfig.arbTextureNonPowerOfTwo = false;
|
glConfig.arbTextureNonPowerOfTwo = false;
|
||||||
if ( StringContainsToken( glConfig.extensions_string, "GL_ARB_texture_non_power_of_two" ) )
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_ARB_texture_non_power_of_two", false ) )
|
||||||
{
|
{
|
||||||
if (r_arb_texturenonpoweroftwo->integer) {
|
if (r_arb_texturenonpoweroftwo->integer) {
|
||||||
VID_Printf (PRINT_ALL, "...using GL_ARB_texture_non_power_of_two\n");
|
VID_Printf (PRINT_ALL, "...using GL_ARB_texture_non_power_of_two\n");
|
||||||
|
@ -1333,7 +1333,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// WGL_EXT_swap_control
|
// WGL_EXT_swap_control
|
||||||
if ( StringContainsToken( glConfig.extensions_string, "WGL_EXT_swap_control" ) )
|
if ( Q_StrScanToken( glConfig.extensions_string, "WGL_EXT_swap_control", false ) )
|
||||||
{
|
{
|
||||||
qwglSwapIntervalEXT = ( BOOL (WINAPI *)(int)) qwglGetProcAddress( "wglSwapIntervalEXT" );
|
qwglSwapIntervalEXT = ( BOOL (WINAPI *)(int)) qwglGetProcAddress( "wglSwapIntervalEXT" );
|
||||||
VID_Printf (PRINT_ALL, "...enabling WGL_EXT_swap_control\n" );
|
VID_Printf (PRINT_ALL, "...enabling WGL_EXT_swap_control\n" );
|
||||||
|
@ -1344,7 +1344,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if ( StringContainsToken( glConfig.extensions_string, "GL_EXT_point_parameters" ) )
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_EXT_point_parameters", false ) )
|
||||||
{
|
{
|
||||||
if ( gl_ext_pointparameters->integer )
|
if ( gl_ext_pointparameters->integer )
|
||||||
{
|
{
|
||||||
|
@ -1359,8 +1359,8 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
VID_Printf (PRINT_ALL, "...GL_EXT_point_parameters not found\n" );
|
VID_Printf (PRINT_ALL, "...GL_EXT_point_parameters not found\n" );
|
||||||
|
|
||||||
if ( !qglColorTableEXT &&
|
if ( !qglColorTableEXT &&
|
||||||
StringContainsToken( glConfig.extensions_string, "GL_EXT_paletted_texture" ) &&
|
Q_StrScanToken( glConfig.extensions_string, "GL_EXT_paletted_texture", false ) &&
|
||||||
StringContainsToken( glConfig.extensions_string, "GL_EXT_shared_texture_palette" ) )
|
Q_StrScanToken( glConfig.extensions_string, "GL_EXT_shared_texture_palette", false ) )
|
||||||
{
|
{
|
||||||
if (gl_ext_palettedtexture->integer)
|
if (gl_ext_palettedtexture->integer)
|
||||||
{
|
{
|
||||||
|
@ -1376,7 +1376,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
|
|
||||||
// GL_ARB_vertex_buffer_object
|
// GL_ARB_vertex_buffer_object
|
||||||
glConfig.vertexBufferObject = false;
|
glConfig.vertexBufferObject = false;
|
||||||
if ( StringContainsToken( glConfig.extensions_string, "GL_ARB_vertex_buffer_object" ) )
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_ARB_vertex_buffer_object", false ) )
|
||||||
{
|
{
|
||||||
/*if (r_arb_vertex_buffer_object->integer)
|
/*if (r_arb_vertex_buffer_object->integer)
|
||||||
{
|
{
|
||||||
|
@ -1399,7 +1399,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
|
|
||||||
// GL_ARB_texture_env_combine - Vic
|
// GL_ARB_texture_env_combine - Vic
|
||||||
glConfig.mtexcombine = false;
|
glConfig.mtexcombine = false;
|
||||||
if (StringContainsToken(glConfig.extensions_string, "GL_ARB_texture_env_combine"))
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_ARB_texture_env_combine", false ) )
|
||||||
{
|
{
|
||||||
if (r_ext_mtexcombine->integer)
|
if (r_ext_mtexcombine->integer)
|
||||||
{
|
{
|
||||||
|
@ -1416,7 +1416,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
// GL_EXT_texture_env_combine - Vic
|
// GL_EXT_texture_env_combine - Vic
|
||||||
if (!glConfig.mtexcombine)
|
if (!glConfig.mtexcombine)
|
||||||
{
|
{
|
||||||
if (StringContainsToken(glConfig.extensions_string, "GL_EXT_texture_env_combine"))
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_EXT_texture_env_combine", false ) )
|
||||||
{
|
{
|
||||||
if (r_ext_mtexcombine->integer)
|
if (r_ext_mtexcombine->integer)
|
||||||
{
|
{
|
||||||
|
@ -1433,7 +1433,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
|
|
||||||
// GL_EXT_stencil_wrap
|
// GL_EXT_stencil_wrap
|
||||||
glConfig.extStencilWrap = false;
|
glConfig.extStencilWrap = false;
|
||||||
if (StringContainsToken(glConfig.extensions_string, "GL_EXT_stencil_wrap"))
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_EXT_stencil_wrap", false ) )
|
||||||
{
|
{
|
||||||
VID_Printf (PRINT_ALL, "...using GL_EXT_stencil_wrap\n");
|
VID_Printf (PRINT_ALL, "...using GL_EXT_stencil_wrap\n");
|
||||||
glConfig.extStencilWrap = true;
|
glConfig.extStencilWrap = true;
|
||||||
|
@ -1443,7 +1443,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
|
|
||||||
// GL_ATI_separate_stencil - Barnes
|
// GL_ATI_separate_stencil - Barnes
|
||||||
glConfig.atiSeparateStencil = false;
|
glConfig.atiSeparateStencil = false;
|
||||||
if (StringContainsToken(glConfig.extensions_string, "GL_ATI_separate_stencil"))
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_ATI_separate_stencil", false ) )
|
||||||
{
|
{
|
||||||
// if (r_stencilTwoSide->integer)
|
// if (r_stencilTwoSide->integer)
|
||||||
// {
|
// {
|
||||||
|
@ -1466,7 +1466,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
|
|
||||||
// GL_EXT_stencil_two_side - Echon
|
// GL_EXT_stencil_two_side - Echon
|
||||||
glConfig.extStencilTwoSide = false;
|
glConfig.extStencilTwoSide = false;
|
||||||
if (StringContainsToken(glConfig.extensions_string, "GL_EXT_stencil_two_side"))
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_EXT_stencil_two_side", false ) )
|
||||||
{
|
{
|
||||||
// if (r_stencilTwoSide->integer)
|
// if (r_stencilTwoSide->integer)
|
||||||
// {
|
// {
|
||||||
|
@ -1488,7 +1488,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
|
|
||||||
// GL_ARB_fragment_program
|
// GL_ARB_fragment_program
|
||||||
glConfig.arb_fragment_program = false;
|
glConfig.arb_fragment_program = false;
|
||||||
if (StringContainsToken(glConfig.extensions_string, "GL_ARB_fragment_program"))
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_ARB_fragment_program", false ) )
|
||||||
{
|
{
|
||||||
if (r_arb_fragment_program->integer)
|
if (r_arb_fragment_program->integer)
|
||||||
{
|
{
|
||||||
|
@ -1536,7 +1536,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
glConfig.arb_vertex_program = false;
|
glConfig.arb_vertex_program = false;
|
||||||
if (glConfig.arb_fragment_program)
|
if (glConfig.arb_fragment_program)
|
||||||
{
|
{
|
||||||
if (StringContainsToken(glConfig.extensions_string, "GL_ARB_vertex_program"))
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_ARB_vertex_program", false ) )
|
||||||
{
|
{
|
||||||
if (r_arb_vertex_program->integer)
|
if (r_arb_vertex_program->integer)
|
||||||
{
|
{
|
||||||
|
@ -1562,7 +1562,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
R_Compile_ARB_Programs ();
|
R_Compile_ARB_Programs ();
|
||||||
|
|
||||||
// GL_NV_texture_shader - MrG
|
// GL_NV_texture_shader - MrG
|
||||||
if ( StringContainsToken( glConfig.extensions_string, "GL_NV_texture_shader" ) )
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_NV_texture_shader", false ) )
|
||||||
{
|
{
|
||||||
VID_Printf (PRINT_ALL, "...using GL_NV_texture_shader\n" );
|
VID_Printf (PRINT_ALL, "...using GL_NV_texture_shader\n" );
|
||||||
glConfig.NV_texshaders = true;
|
glConfig.NV_texshaders = true;
|
||||||
|
@ -1575,7 +1575,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
|
|
||||||
// GL_EXT_texture_filter_anisotropic - NeVo
|
// GL_EXT_texture_filter_anisotropic - NeVo
|
||||||
glConfig.anisotropic = false;
|
glConfig.anisotropic = false;
|
||||||
if ( StringContainsToken( glConfig.extensions_string, "GL_EXT_texture_filter_anisotropic" ) )
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_EXT_texture_filter_anisotropic", false ) )
|
||||||
{
|
{
|
||||||
VID_Printf (PRINT_ALL,"...using GL_EXT_texture_filter_anisotropic\n" );
|
VID_Printf (PRINT_ALL,"...using GL_EXT_texture_filter_anisotropic\n" );
|
||||||
glConfig.anisotropic = true;
|
glConfig.anisotropic = true;
|
||||||
|
@ -1593,7 +1593,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
// GL_NV_fog_distance
|
// GL_NV_fog_distance
|
||||||
glConfig.nvFogAvailable = false;
|
glConfig.nvFogAvailable = false;
|
||||||
glConfig.nvFogMode = 0;
|
glConfig.nvFogMode = 0;
|
||||||
if ( StringContainsToken( glConfig.extensions_string, "GL_NV_fog_distance") )
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_NV_fog_distance", false ) )
|
||||||
{
|
{
|
||||||
if (r_nvfog_dist->integer)
|
if (r_nvfog_dist->integer)
|
||||||
{
|
{
|
||||||
|
@ -1613,7 +1613,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GL_SGIS_generate_mipmap
|
// GL_SGIS_generate_mipmap
|
||||||
if ( StringContainsToken( glConfig.extensions_string, "GL_SGIS_generate_mipmap") )
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_SGIS_generate_mipmap", false ) )
|
||||||
{
|
{
|
||||||
if (r_sgis_generatemipmap->integer) {
|
if (r_sgis_generatemipmap->integer) {
|
||||||
VID_Printf (PRINT_ALL, "...using GL_SGIS_generate_mipmap\n" );
|
VID_Printf (PRINT_ALL, "...using GL_SGIS_generate_mipmap\n" );
|
||||||
|
@ -1631,7 +1631,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GL_ARB_texture_compression - Heffo
|
// GL_ARB_texture_compression - Heffo
|
||||||
if ( StringContainsToken( glConfig.extensions_string, "GL_ARB_texture_compression" ) )
|
if ( Q_StrScanToken( glConfig.extensions_string, "GL_ARB_texture_compression", false ) )
|
||||||
{
|
{
|
||||||
if(!r_ext_texture_compression->integer)
|
if(!r_ext_texture_compression->integer)
|
||||||
{
|
{
|
||||||
|
@ -1653,7 +1653,7 @@ qboolean R_CheckGLExtensions (char *reason)
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// WGL_3DFX_gamma_control
|
// WGL_3DFX_gamma_control
|
||||||
if ( StringContainsToken(glConfig.extensions_string, "WGL_3DFX_gamma_control") )
|
if ( Q_StrScanToken(glConfig.extensions_string, "WGL_3DFX_gamma_control", false ) )
|
||||||
{
|
{
|
||||||
if (!r_ignorehwgamma->integer)
|
if (!r_ignorehwgamma->integer)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue