diff options
author | Andrey Nazarov <skuller@skuller.net> | 2009-09-05 11:25:06 +0000 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2009-09-05 11:25:06 +0000 |
commit | a212ea6fb40dab69a40f2ef5db0efe3ae9526301 (patch) | |
tree | 14233b4794c5baa61fef0dadd3b06cd6970952a0 /source/cvar.c | |
parent | a63351b924daa288b120af78607434ca5acc60d8 (diff) |
Made Cvar_BitInfo strip non-printable characters just like Info_SetValueForKey does.
Diffstat (limited to 'source/cvar.c')
-rw-r--r-- | source/cvar.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/source/cvar.c b/source/cvar.c index ea12b84..966a0c4 100644 --- a/source/cvar.c +++ b/source/cvar.c @@ -218,7 +218,7 @@ The flags will be or'ed in if the variable exists. ============ */ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) { - cvar_t *var, *c, **p; + cvar_t *var, *c, **p; unsigned hash; size_t length; @@ -1052,9 +1052,10 @@ static void Cvar_Reset_c( genctx_t *ctx, int argnum ) { } size_t Cvar_BitInfo( char *info, int bit ) { - char newi[MAX_INFO_STRING]; + char newi[MAX_INFO_STRING], *v; cvar_t *var; size_t len, total = 0; + int c; for( var = cvar_vars; var; var = var->next ) { if( !( var->flags & bit ) ) { @@ -1071,9 +1072,17 @@ size_t Cvar_BitInfo( char *info, int bit ) { if( total + len >= MAX_INFO_STRING ) { break; } - memcpy( info + total, newi, len ); - total += len; + + // only copy ascii values + v = newi; + while( *v ) { + c = *v++; + c &= 127; // strip high bits + if( Q_isprint( c ) ) + info[total++] = c; + } } + info[total] = 0; return total; } |