From: Thomas Debesse Date: Tue, 18 Jul 2017 08:12:04 +0000 (+0200) Subject: some “char*” to “const char*” declaration X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=commitdiff_plain;h=5acef430dfdf884a7f018a17fbef64d9eaf6209e some “char*” to “const char*” declaration - ISO C++ forbids converting a string constant to ‘char*’ These are obvious fixes when it's better to declare functions as expecting “const char*“. --- diff --git a/contrib/bobtoolz/DMap.cpp b/contrib/bobtoolz/DMap.cpp index 72356946..18edc3b1 100644 --- a/contrib/bobtoolz/DMap.cpp +++ b/contrib/bobtoolz/DMap.cpp @@ -58,7 +58,7 @@ DMap::~DMap(){ ClearEntities(); } -DEntity* DMap::AddEntity( char *classname, int ID ){ +DEntity* DMap::AddEntity( const char *classname, int ID ){ DEntity* newEntity; if ( ID == -1 ) { newEntity = new DEntity( classname, m_nNextEntity++ ); diff --git a/contrib/bobtoolz/DMap.h b/contrib/bobtoolz/DMap.h index b4a3f79b..f527d04d 100644 --- a/contrib/bobtoolz/DMap.h +++ b/contrib/bobtoolz/DMap.h @@ -45,7 +45,7 @@ DEntity* GetWorldSpawn(); void ClearEntities(); DEntity* GetEntityForID( int ID ); -DEntity* AddEntity( char* classname = "worldspawn", int ID = -1 ); +DEntity* AddEntity( const char* classname = "worldspawn", int ID = -1 ); std::list entityList; diff --git a/contrib/bobtoolz/bobToolz-GTK.cpp b/contrib/bobtoolz/bobToolz-GTK.cpp index 6cf91a0b..007d51af 100644 --- a/contrib/bobtoolz/bobToolz-GTK.cpp +++ b/contrib/bobtoolz/bobToolz-GTK.cpp @@ -57,10 +57,10 @@ void BobToolz_destroy(){ } // plugin name -char* PLUGIN_NAME = "bobToolz"; +const char* PLUGIN_NAME = "bobToolz"; // commands in the menu -static char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Split patches cols,Split patches rows,Turn edge"; +static const char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Split patches cols,Split patches rows,Turn edge"; // globals ui::Widget g_pRadiantWnd; diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp index 41e4d410..fb9c1806 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@ -115,7 +115,7 @@ static void dialog_button_callback_settex( GtkWidget *widget, gpointer data ){ Data validation Routines ---------------------------------*/ -bool ValidateTextFloat( const char* pData, char* error_title, float* value ){ +bool ValidateTextFloat( const char* pData, const char* error_title, float* value ){ if ( pData ) { float testNum = (float)atof( pData ); @@ -134,7 +134,7 @@ bool ValidateTextFloat( const char* pData, char* error_title, float* value ){ return FALSE; } -bool ValidateTextFloatRange( const char* pData, float min, float max, char* error_title, float* value ){ +bool ValidateTextFloatRange( const char* pData, float min, float max, const char* error_title, float* value ){ char error_buffer[256]; sprintf( error_buffer, "Please Enter A Floating Point Number Between %.3f and %.3f", min, max ); @@ -156,7 +156,7 @@ bool ValidateTextFloatRange( const char* pData, float min, float max, char* erro return FALSE; } -bool ValidateTextIntRange( const char* pData, int min, int max, char* error_title, int* value ){ +bool ValidateTextIntRange( const char* pData, int min, int max, const char* error_title, int* value ){ char error_buffer[256]; sprintf( error_buffer, "Please Enter An Integer Between %i and %i", min, max ); @@ -178,7 +178,7 @@ bool ValidateTextIntRange( const char* pData, int min, int max, char* error_titl return FALSE; } -bool ValidateTextInt( const char* pData, char* error_title, int* value ){ +bool ValidateTextInt( const char* pData, const char* error_title, int* value ){ if ( pData ) { int testNum = atoi( pData ); @@ -584,7 +584,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ EMessageBoxReturn ret; int loop = 1; - char *text = "Please set a value in the boxes below and press 'OK' to build the stairs"; + const char *text = "Please set a value in the boxes below and press 'OK' to build the stairs"; auto window = ui::Window( ui::window_type::TOP ); @@ -1891,7 +1891,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ EMessageBoxReturn ret; int loop = 1; - char const *text = "Please set a value in the boxes below and press 'OK' to make a chain"; + const char *text = "Please set a value in the boxes below and press 'OK' to make a chain"; auto window = ui::Window( ui::window_type::TOP ); diff --git a/contrib/prtview/prtview.cpp b/contrib/prtview/prtview.cpp index 301ac9ea..ffb813ea 100644 --- a/contrib/prtview/prtview.cpp +++ b/contrib/prtview/prtview.cpp @@ -162,7 +162,7 @@ void SaveConfig(){ #define CONFIG_SECTION "Configuration" -int INIGetInt( char *key, int def ){ +int INIGetInt( const char *key, int def ){ char value[1024]; if ( read_var( INIfn.c_str(), CONFIG_SECTION, key, value ) ) { @@ -173,7 +173,7 @@ int INIGetInt( char *key, int def ){ } } -void INISetInt( char *key, int val, char *comment /* = NULL */ ){ +void INISetInt( const char *key, int val, const char *comment /* = NULL */ ){ char s[1000]; if ( comment ) { diff --git a/contrib/prtview/prtview.h b/contrib/prtview/prtview.h index e149ae80..df84d6a2 100644 --- a/contrib/prtview/prtview.h +++ b/contrib/prtview/prtview.h @@ -25,8 +25,8 @@ void InitInstance(); void SaveConfig(); -int INIGetInt( char *key, int def ); -void INISetInt( char *key, int val, char *comment = 0 ); +int INIGetInt( const char *key, int def ); +void INISetInt( const char *key, int val, const char *comment = 0 ); #define IDOK 1 #define IDCANCEL 2 diff --git a/contrib/shaderplug/shaderplug.cpp b/contrib/shaderplug/shaderplug.cpp index e8f4f5fc..75171bd8 100644 --- a/contrib/shaderplug/shaderplug.cpp +++ b/contrib/shaderplug/shaderplug.cpp @@ -118,7 +118,7 @@ void LoadTextureFile( const char* filename ){ typedef FreeCaller1 LoadTextureFileCaller; -void GetTextures( char* extension ){ +void GetTextures( const char* extension ){ GlobalFileSystem().forEachFile( "textures/", extension, LoadTextureFileCaller(), 0 ); } diff --git a/contrib/ufoaiplug/ufoai_level.cpp b/contrib/ufoaiplug/ufoai_level.cpp index c7554e4d..41a4c62b 100644 --- a/contrib/ufoaiplug/ufoai_level.cpp +++ b/contrib/ufoaiplug/ufoai_level.cpp @@ -130,7 +130,7 @@ void get_team_count( const char *classname, int *count, int *team ){ /** * @brief Some default values to worldspawn like maxlevel and so on */ -void assign_default_values_to_worldspawn( bool override, char **returnMsg ){ +void assign_default_values_to_worldspawn( bool override, const char **returnMsg ){ static char message[1024]; Entity* worldspawn; int teams = 0; @@ -190,7 +190,7 @@ int check_entity_flags( const char *classname, const char *flag ){ * @brief Will check e.g. the map entities for valid values * @todo: check for maxlevel */ -void check_map_values( char **returnMsg ){ +void check_map_values( const char **returnMsg ){ static char message[1024]; int count = 0; int teams = 0; diff --git a/libs/splines/q_shared.cpp b/libs/splines/q_shared.cpp index 033a6ee3..204d980d 100644 --- a/libs/splines/q_shared.cpp +++ b/libs/splines/q_shared.cpp @@ -716,7 +716,7 @@ void QDECL Com_sprintf( char *dest, int size, const char *fmt, ... ) { FIXME: make this buffer size safe someday ============ */ -char * QDECL va( char *format, ... ) { +char *QDECL va( const char *format, ... ) { va_list argptr; static char string[2][32000]; // in case va is called by nested functions static int index = 0; @@ -750,7 +750,7 @@ char * QDECL va( char *format, ... ) { FIXME: overflow check? =============== */ -char *Info_ValueForKey( const char *s, const char *key ) { +const char *Info_ValueForKey( const char *s, const char *key ) { char pkey[MAX_INFO_KEY]; static char value[2][MAX_INFO_VALUE]; // use two buffers so compares // work without stomping on each other diff --git a/libs/splines/q_shared.h b/libs/splines/q_shared.h index 6ebfb99f..61f1024b 100644 --- a/libs/splines/q_shared.h +++ b/libs/splines/q_shared.h @@ -646,7 +646,7 @@ float BigFloat( float l ); float LittleFloat( float l ); void Swap_Init( void ); -char * QDECL va( char *format, ... ); +char *QDECL va( const char *format, ... ); #ifdef __cplusplus } @@ -776,7 +776,7 @@ int Com_IndexForGrowListElement( const growList_t *list, const void *ele // // key / value info strings // -char *Info_ValueForKey( const char *s, const char *key ); +const char *Info_ValueForKey( const char *s, const char *key ); void Info_RemoveKey( char *s, const char *key ); void Info_SetValueForKey( char *s, const char *key, const char *value ); qboolean Info_Validate( const char *s ); diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index a5e03e31..79944252 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -919,7 +919,7 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){ // ============================================================================= // Add new shader tag dialog -EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, char* title ){ +EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, const char* title ){ ModalDialog dialog; GtkEntry* textentry; ModalDialogButton ok_button( dialog, eIDOK ); @@ -980,7 +980,7 @@ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, char* title ){ return ret; } -EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, char* title ){ +EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, const char* title ){ ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); diff --git a/radiant/gtkdlgs.h b/radiant/gtkdlgs.h index 0ff194e6..05f8b8b9 100644 --- a/radiant/gtkdlgs.h +++ b/radiant/gtkdlgs.h @@ -35,8 +35,8 @@ #include "string/string.h" EMessageBoxReturn DoLightIntensityDlg( int *intensity ); -EMessageBoxReturn DoShaderTagDlg( CopiedString *tag, char* title ); -EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, char* title ); +EMessageBoxReturn DoShaderTagDlg( CopiedString *tag, const char* title ); +EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, const char* title ); EMessageBoxReturn DoTextureLayout( float *fx, float *fy ); void DoTextEditor( const char* filename, int cursorpos );