Fix -Wwrite-strings warnings

deprecated conversion from string constant to ‘char*’

Constify lots of "char *".
This commit is contained in:
dhewg 2011-11-30 22:15:10 +01:00
parent 14329d47d8
commit 9d97eefb1a
28 changed files with 72 additions and 72 deletions

View file

@ -71,7 +71,7 @@ const char *idGameLocal::sufaceTypeNames[ MAX_SURFACE_TYPES ] = {
#ifdef _D3XP
// List of all defs used by the player that will stay on the fast timeline
static char* fastEntityList[] = {
static const char* fastEntityList[] = {
"player_doommarine",
"weapon_chainsaw",
"weapon_fists",

View file

@ -772,7 +772,7 @@ void idItemTeam::Spawn( void ) {
idItemTeam::LoadScript
===============
*/
function_t * idItemTeam::LoadScript( char * script ) {
function_t * idItemTeam::LoadScript( const char * script ) {
function_t * function = NULL;
idStr funcname = spawnArgs.GetString( script, "" );
if ( funcname.Length() ) {

View file

@ -257,7 +257,7 @@ private:
void Event_FlagCapture( void );
void PrivateReturn( void );
function_t * LoadScript( char * script );
function_t * LoadScript( const char * script );
void SpawnNugget( idVec3 pos );
void UpdateGuis( void );

View file

@ -4230,7 +4230,7 @@ idMultiplayerGame::GetTeamFlag
================
*/
void idMultiplayerGame::FindTeamFlags( void ) {
char * flagDefs[2] =
const char * flagDefs[2] =
{
"team_CTF_redflag",
"team_CTF_blueflag"

View file

@ -446,7 +446,7 @@ argv(0) god
==================
*/
void Cmd_God_f( const idCmdArgs &args ) {
char *msg;
const char *msg;
idPlayer *player;
player = gameLocal.GetLocalPlayer();
@ -475,7 +475,7 @@ argv(0) notarget
==================
*/
void Cmd_Notarget_f( const idCmdArgs &args ) {
char *msg;
const char *msg;
idPlayer *player;
player = gameLocal.GetLocalPlayer();
@ -502,7 +502,7 @@ argv(0) noclip
==================
*/
void Cmd_Noclip_f( const idCmdArgs &args ) {
char *msg;
const char *msg;
idPlayer *player;
player = gameLocal.GetLocalPlayer();

View file

@ -38,14 +38,14 @@ If you have questions concerning this license or the applicable additional terms
#define TOP_PRIORITY 7
bool idCompiler::punctuationValid[ 256 ];
char *idCompiler::punctuation[] = {
const char *idCompiler::punctuation[] = {
"+=", "-=", "*=", "/=", "%=", "&=", "|=", "++", "--",
"&&", "||", "<=", ">=", "==", "!=", "::", ";", ",",
"~", "!", "*", "/", "%", "(", ")", "-", "+",
"=", "[", "]", ".", "<", ">" , "&", "|", ":", NULL
};
opcode_t idCompiler::opcodes[] = {
const opcode_t idCompiler::opcodes[] = {
{ "<RETURN>", "RETURN", -1, false, &def_void, &def_void, &def_void },
{ "++", "UINC_F", 1, true, &def_float, &def_void, &def_void },
@ -207,7 +207,7 @@ idCompiler::idCompiler()
================
*/
idCompiler::idCompiler() {
char **ptr;
const char **ptr;
int id;
// make sure we have the right # of opcodes in the table
@ -630,8 +630,8 @@ Emits an opcode to push the variable onto the stack.
============
*/
bool idCompiler::EmitPush( idVarDef *expression, const idTypeDef *funcArg ) {
opcode_t *op;
opcode_t *out;
const opcode_t *op;
const opcode_t *out;
out = NULL;
for( op = &opcodes[ OP_PUSH_F ]; op->name && !strcmp( op->name, "<PUSH>" ); op++ ) {
@ -1166,7 +1166,7 @@ idVarDef *idCompiler::LookupDef( const char *name, const idVarDef *baseobj ) {
idVarDef *field;
etype_t type_b;
etype_t type_c;
opcode_t *op;
const opcode_t *op;
// check if we're accessing a field
if ( baseobj && ( baseobj->Type() == ev_object ) ) {
@ -1463,8 +1463,8 @@ idCompiler::GetExpression
==============
*/
idVarDef *idCompiler::GetExpression( int priority ) {
opcode_t *op;
opcode_t *oldop;
const opcode_t *op;
const opcode_t *oldop;
idVarDef *e;
idVarDef *e2;
const idVarDef *oldtype;
@ -1677,7 +1677,7 @@ void idCompiler::ParseReturnStatement( void ) {
idVarDef *e;
etype_t type_a;
etype_t type_b;
opcode_t *op;
const opcode_t *op;
if ( CheckToken( ";" ) ) {
if ( scope->TypeDef()->ReturnType()->Type() != ev_void ) {

View file

@ -31,8 +31,8 @@ If you have questions concerning this license or the applicable additional terms
const char * const RESULT_STRING = "<RESULT>";
typedef struct opcode_s {
char *name;
char *opname;
const char *name;
const char *opname;
int priority;
bool rightAssociative;
idVarDef *type_a;
@ -197,7 +197,7 @@ enum {
class idCompiler {
private:
static bool punctuationValid[ 256 ];
static char *punctuation[];
static const char *punctuation[];
idParser parser;
idParser *parserPtr;
@ -269,7 +269,7 @@ private:
void ParseNamespace( idVarDef *newScope );
public :
static opcode_t opcodes[];
static const opcode_t opcodes[];
idCompiler();
void CompileFile( const char *text, const char *filename, bool console );

View file

@ -425,7 +425,7 @@ idInterpreter::Error
Aborts the currently executing function
============
*/
void idInterpreter::Error( char *fmt, ... ) const {
void idInterpreter::Error( const char *fmt, ... ) const {
va_list argptr;
char text[ 1024 ];
@ -450,7 +450,7 @@ idInterpreter::Warning
Prints file and line number information with warning.
============
*/
void idInterpreter::Warning( char *fmt, ... ) const {
void idInterpreter::Warning( const char *fmt, ... ) const {
va_list argptr;
char text[ 1024 ];

View file

@ -93,8 +93,8 @@ public:
int CurrentLine( void ) const;
const char *CurrentFile( void ) const;
void Error( char *fmt, ... ) const id_attribute((format(printf,2,3)));
void Warning( char *fmt, ... ) const id_attribute((format(printf,2,3)));
void Error( const char *fmt, ... ) const id_attribute((format(printf,2,3)));
void Warning( const char *fmt, ... ) const id_attribute((format(printf,2,3)));
void DisplayInfo( void ) const;
bool BeginMultiFrameEvent( idEntity *ent, const idEventDef *event );

View file

@ -1627,7 +1627,7 @@ idProgram::DisassembleStatement
==============
*/
void idProgram::DisassembleStatement( idFile *file, int instructionPointer ) const {
opcode_t *op;
const opcode_t *op;
const statement_t *statement;
statement = &statements[ instructionPointer ];

View file

@ -30,9 +30,9 @@ If you have questions concerning this license or the applicable additional terms
#pragma hdrstop
typedef struct {
char *name;
const char *name;
int keynum;
char *strId; // localized string id
const char *strId; // localized string id
} keyname_t;
// keys that can be set without a special name
@ -43,7 +43,7 @@ const char* OSX_GetLocalizedString( const char* );
#endif
// names not in this list can either be lowercase ascii, or '0xnn' hex sequences
keyname_t keynames[] =
static const keyname_t keynames[] =
{
{"TAB", K_TAB, "#str_07018"},
{"ENTER", K_ENTER, "#str_07019"},
@ -199,7 +199,7 @@ idKey * keys = NULL;
#ifdef ID_DOOM_LEGACY
char * cheatCodes[] = {
static const char * cheatCodes[] = {
"iddqd", // Invincibility
"idkfa", // All weapons, keys, ammo, and 200% armor
"idfa", // Reset ammunition
@ -233,7 +233,7 @@ idKeyInput::ArgCompletion_KeyName
===================
*/
void idKeyInput::ArgCompletion_KeyName( const idCmdArgs &args, void(*callback)( const char *s ) ) {
keyname_t *kn;
const keyname_t *kn;
int i;
for( i = 0; i < sizeof( unnamedkeys ) - 1; i++ ) {
@ -289,7 +289,7 @@ to be configured even if they don't have defined names.
===================
*/
int idKeyInput::StringToKeyNum( const char *str ) {
keyname_t *kn;
const keyname_t *kn;
if ( !str || !str[0] ) {
return -1;
@ -342,7 +342,7 @@ given keynum.
===================
*/
const char *idKeyInput::KeyNumToString( int keynum, bool localized ) {
keyname_t *kn;
const keyname_t *kn;
static char tinystr[5];
int i, j;

View file

@ -395,7 +395,7 @@ argv(0) god
==================
*/
void Cmd_God_f( const idCmdArgs &args ) {
char *msg;
const char *msg;
idPlayer *player;
player = gameLocal.GetLocalPlayer();
@ -424,7 +424,7 @@ argv(0) notarget
==================
*/
void Cmd_Notarget_f( const idCmdArgs &args ) {
char *msg;
const char *msg;
idPlayer *player;
player = gameLocal.GetLocalPlayer();
@ -451,7 +451,7 @@ argv(0) noclip
==================
*/
void Cmd_Noclip_f( const idCmdArgs &args ) {
char *msg;
const char *msg;
idPlayer *player;
player = gameLocal.GetLocalPlayer();

View file

@ -38,14 +38,14 @@ If you have questions concerning this license or the applicable additional terms
#define TOP_PRIORITY 7
bool idCompiler::punctuationValid[ 256 ];
char *idCompiler::punctuation[] = {
const char *idCompiler::punctuation[] = {
"+=", "-=", "*=", "/=", "%=", "&=", "|=", "++", "--",
"&&", "||", "<=", ">=", "==", "!=", "::", ";", ",",
"~", "!", "*", "/", "%", "(", ")", "-", "+",
"=", "[", "]", ".", "<", ">" , "&", "|", ":", NULL
};
opcode_t idCompiler::opcodes[] = {
const opcode_t idCompiler::opcodes[] = {
{ "<RETURN>", "RETURN", -1, false, &def_void, &def_void, &def_void },
{ "++", "UINC_F", 1, true, &def_float, &def_void, &def_void },
@ -207,7 +207,7 @@ idCompiler::idCompiler()
================
*/
idCompiler::idCompiler() {
char **ptr;
const char **ptr;
int id;
// make sure we have the right # of opcodes in the table
@ -630,8 +630,8 @@ Emits an opcode to push the variable onto the stack.
============
*/
bool idCompiler::EmitPush( idVarDef *expression, const idTypeDef *funcArg ) {
opcode_t *op;
opcode_t *out;
const opcode_t *op;
const opcode_t *out;
out = NULL;
for( op = &opcodes[ OP_PUSH_F ]; op->name && !strcmp( op->name, "<PUSH>" ); op++ ) {
@ -1166,7 +1166,7 @@ idVarDef *idCompiler::LookupDef( const char *name, const idVarDef *baseobj ) {
idVarDef *field;
etype_t type_b;
etype_t type_c;
opcode_t *op;
const opcode_t *op;
// check if we're accessing a field
if ( baseobj && ( baseobj->Type() == ev_object ) ) {
@ -1463,8 +1463,8 @@ idCompiler::GetExpression
==============
*/
idVarDef *idCompiler::GetExpression( int priority ) {
opcode_t *op;
opcode_t *oldop;
const opcode_t *op;
const opcode_t *oldop;
idVarDef *e;
idVarDef *e2;
const idVarDef *oldtype;
@ -1677,7 +1677,7 @@ void idCompiler::ParseReturnStatement( void ) {
idVarDef *e;
etype_t type_a;
etype_t type_b;
opcode_t *op;
const opcode_t *op;
if ( CheckToken( ";" ) ) {
if ( scope->TypeDef()->ReturnType()->Type() != ev_void ) {

View file

@ -31,8 +31,8 @@ If you have questions concerning this license or the applicable additional terms
const char * const RESULT_STRING = "<RESULT>";
typedef struct opcode_s {
char *name;
char *opname;
const char *name;
const char *opname;
int priority;
bool rightAssociative;
idVarDef *type_a;
@ -197,7 +197,7 @@ enum {
class idCompiler {
private:
static bool punctuationValid[ 256 ];
static char *punctuation[];
static const char *punctuation[];
idParser parser;
idParser *parserPtr;
@ -269,7 +269,7 @@ private:
void ParseNamespace( idVarDef *newScope );
public :
static opcode_t opcodes[];
static const opcode_t opcodes[];
idCompiler();
void CompileFile( const char *text, const char *filename, bool console );

View file

@ -425,7 +425,7 @@ idInterpreter::Error
Aborts the currently executing function
============
*/
void idInterpreter::Error( char *fmt, ... ) const {
void idInterpreter::Error( const char *fmt, ... ) const {
va_list argptr;
char text[ 1024 ];
@ -450,7 +450,7 @@ idInterpreter::Warning
Prints file and line number information with warning.
============
*/
void idInterpreter::Warning( char *fmt, ... ) const {
void idInterpreter::Warning( const char *fmt, ... ) const {
va_list argptr;
char text[ 1024 ];

View file

@ -93,8 +93,8 @@ public:
int CurrentLine( void ) const;
const char *CurrentFile( void ) const;
void Error( char *fmt, ... ) const id_attribute((format(printf,2,3)));
void Warning( char *fmt, ... ) const id_attribute((format(printf,2,3)));
void Error( const char *fmt, ... ) const id_attribute((format(printf,2,3)));
void Warning( const char *fmt, ... ) const id_attribute((format(printf,2,3)));
void DisplayInfo( void ) const;
bool BeginMultiFrameEvent( idEntity *ent, const idEventDef *event );

View file

@ -1627,7 +1627,7 @@ idProgram::DisassembleStatement
==============
*/
void idProgram::DisassembleStatement( idFile *file, int instructionPointer ) const {
opcode_t *op;
const opcode_t *op;
const statement_t *statement;
statement = &statements[ instructionPointer ];

View file

@ -32,7 +32,7 @@ If you have questions concerning this license or the applicable additional terms
#define PUNCTABLE
//longer punctuations first
punctuation_t default_punctuations[] = {
static const punctuation_t default_punctuations[] = {
//binary operators
{">>=",P_RSHIFT_ASSIGN},
{"<<=",P_LSHIFT_ASSIGN},
@ -774,7 +774,7 @@ idLexer::ReadPunctuation
*/
int idLexer::ReadPunctuation( idToken *token ) {
int l, n, i;
char *p;
const char *p;
const punctuation_t *punc;
#ifdef PUNCTABLE

View file

@ -129,7 +129,7 @@ typedef enum {
// punctuation
typedef struct punctuation_s
{
char *p; // punctuation character(s)
const char *p; // punctuation character(s)
int n; // punctuation id
} punctuation_t;

View file

@ -625,7 +625,7 @@ void idParser::AddBuiltinDefines( void ) {
define_t *define;
struct builtin
{
char *string;
const char *string;
int id;
} builtin[] = {
{ "__LINE__", BUILTIN_LINE },

View file

@ -312,7 +312,7 @@ TIME_TYPE time_in_millisec( void ) {
PrintClocks
============
*/
void PrintClocks( char *string, int dataCount, int clocks, int otherClocks = 0 ) {
void PrintClocks( const char *string, int dataCount, int clocks, int otherClocks = 0 ) {
int i;
idLib::common->Printf( string );

View file

@ -1084,11 +1084,11 @@ Loads six files with proper extensions
*/
bool R_LoadCubeImages( const char *imgName, cubeFiles_t extensions, byte *pics[6], int *outSize, ID_TIME_T *timestamp ) {
int i, j;
char *cameraSides[6] = { "_forward.tga", "_back.tga", "_left.tga", "_right.tga",
const char *cameraSides[6] = { "_forward.tga", "_back.tga", "_left.tga", "_right.tga",
"_up.tga", "_down.tga" };
char *axisSides[6] = { "_px.tga", "_nx.tga", "_py.tga", "_ny.tga",
const char *axisSides[6] = { "_px.tga", "_nx.tga", "_py.tga", "_ny.tga",
"_pz.tga", "_nz.tga" };
char **sides;
const char **sides;
char fullName[MAX_IMAGE_NAME];
int width, height, size = 0;

View file

@ -911,7 +911,7 @@ void R_QuadraticImage( idImage *image ) {
typedef struct {
char *name;
const char *name;
int minimize, maximize;
} filterName_t;
@ -929,7 +929,7 @@ void idImageManager::ChangeTextureFilter( void ) {
int i;
idImage *glt;
const char *string;
static filterName_t textureFilters[] = {
static const filterName_t textureFilters[] = {
{"GL_LINEAR_MIPMAP_NEAREST", GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR},
{"GL_LINEAR_MIPMAP_LINEAR", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR},
{"GL_NEAREST", GL_NEAREST, GL_NEAREST},

View file

@ -224,11 +224,11 @@ idImage *idMaterial::GetEditorImage( void ) const {
// info parms
typedef struct {
char *name;
const char *name;
int clearSolid, surfaceFlags, contents;
} infoParm_t;
static infoParm_t infoParms[] = {
static const infoParm_t infoParms[] = {
// game relevant attributes
{"solid", 0, 0, CONTENTS_SOLID }, // may need to override a clearSolid
{"water", 1, 0, CONTENTS_WATER }, // used for water
@ -2325,7 +2325,7 @@ bool idMaterial::Parse( const char *text, const int textLength ) {
idMaterial::Print
===================
*/
char *opNames[] = {
static const char *opNames[] = {
"OP_TYPE_ADD",
"OP_TYPE_SUBTRACT",
"OP_TYPE_MULTIPLY",

View file

@ -315,7 +315,7 @@ PFNGLDEPTHBOUNDSEXTPROC qglDepthBoundsEXT;
R_CheckExtension
=================
*/
bool R_CheckExtension( char *name ) {
bool R_CheckExtension( const char *name ) {
if ( !strstr( glConfig.extensions_string, name ) ) {
common->Printf( "X..%s not found\n", name );
return false;
@ -1462,7 +1462,7 @@ void R_EnvShot_f( const idCmdArgs &args ) {
renderView_t ref;
viewDef_t primary;
int blends;
char *extensions[6] = { "_px.tga", "_nx.tga", "_py.tga", "_ny.tga",
const char *extensions[6] = { "_px.tga", "_nx.tga", "_py.tga", "_ny.tga",
"_pz.tga", "_nz.tga" };
int size;
@ -1602,7 +1602,7 @@ void R_MakeAmbientMap_f( const idCmdArgs &args ) {
renderView_t ref;
viewDef_t primary;
int downSample;
char *extensions[6] = { "_px.tga", "_nx.tga", "_py.tga", "_ny.tga",
const char *extensions[6] = { "_px.tga", "_nx.tga", "_py.tga", "_ny.tga",
"_pz.tga", "_nz.tga" };
int outSize;
byte *buffers[6];

View file

@ -1056,7 +1056,7 @@ void R_SetColorMappings( void );
void R_ScreenShot_f( const idCmdArgs &args );
void R_StencilShot( void );
bool R_CheckExtension( char *name );
bool R_CheckExtension( const char *name );
/*

View file

@ -44,7 +44,7 @@ If you have questions concerning this license or the applicable additional terms
DisplayRealTimeString
============
*/
void DisplayRealTimeString( char *string, ... ) {
void DisplayRealTimeString( const char *string, ... ) {
va_list argPtr;
char buf[MAX_STRING_CHARS];
static int lastUpdateTime;

View file

@ -46,7 +46,7 @@ If you have questions concerning this license or the applicable additional terms
class idBrush;
class idBrushList;
void DisplayRealTimeString( char *string, ... ) id_attribute((format(printf,1,2)));
void DisplayRealTimeString( const char *string, ... ) id_attribute((format(printf,1,2)));
//===============================================================