]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
some “char*” to “const char*” declaration
authorThomas Debesse <dev@illwieckz.net>
Tue, 18 Jul 2017 08:12:04 +0000 (10:12 +0200)
committerThomas Debesse <dev@illwieckz.net>
Tue, 1 Aug 2017 14:27:11 +0000 (16:27 +0200)
- ISO C++ forbids converting a string constant to ‘char*’
 These are obvious fixes when it's better to declare functions
 as expecting “const char*“.

12 files changed:
contrib/bobtoolz/DMap.cpp
contrib/bobtoolz/DMap.h
contrib/bobtoolz/bobToolz-GTK.cpp
contrib/bobtoolz/dialogs/dialogs-gtk.cpp
contrib/prtview/prtview.cpp
contrib/prtview/prtview.h
contrib/shaderplug/shaderplug.cpp
contrib/ufoaiplug/ufoai_level.cpp
libs/splines/q_shared.cpp
libs/splines/q_shared.h
radiant/gtkdlgs.cpp
radiant/gtkdlgs.h

index 72356946ca81b68e425171883dce4cad0da7ec58..18edc3b1fee51870082c1336f6a43ab908b23d08 100644 (file)
@@ -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++ );
index b4a3f79bff33e6a716f4d4ec75f9f6b3f0c9e13f..f527d04d85411299d50564f3de5ac9309c15369c 100644 (file)
@@ -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<DEntity*> entityList;
 
index 6cf91a0be9947d868d0ab628105e0fa95f2a38e8..007d51afd474c0cac22c8c68bb5469cdc1a32203 100644 (file)
@@ -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;
index 41e4d410622904bed2625cdfaeb4b645cff2793d..fb9c180633332506db486bc5352f2fc5b64f0d72 100644 (file)
@@ -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 );
 
index 301ac9ea154a8835682c9b22a6a89d3a285ea359..ffb813ea73cb5b520e8b0655617ab52011ec5fe5 100644 (file)
@@ -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 ) {
index e149ae80c99f9460a30bd5e46eec3398051f6945..df84d6a24cf6eaf242bd62e00eee958b1a486fca 100644 (file)
@@ -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
index e8f4f5fc4e0fb868e4a6c762a1a3269cd1dbb804..75171bd8370d889b2e078fa19a5550563d401fe8 100644 (file)
@@ -118,7 +118,7 @@ void LoadTextureFile( const char* filename ){
 
 typedef FreeCaller1<const char*, LoadTextureFile> LoadTextureFileCaller;
 
-void GetTextures( char* extension ){
+void GetTextures( const char* extension ){
        GlobalFileSystem().forEachFile( "textures/", extension, LoadTextureFileCaller(), 0 );
 }
 
index c7554e4d2c4771858e3b438cd16cd1afa468ca03..41a4c62bd371eb9332219c24bffa7dafb0a4d4ae 100644 (file)
@@ -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;
index 033a6ee3120d4e725a727c498e5c08bc452b1cdd..204d980d176a6e5ad53afa6104303cfbf8d9a41b 100644 (file)
@@ -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
index 6ebfb99fa3ed25f8f1c2459de5b52806ac4b9d25..61f1024be1c2bd8e3509e922b383233cf2c37bd1 100644 (file)
@@ -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 );
index a5e03e318c0f12d6e0455d6fe383c6bec88c7c90..7994425239d4b490813d99a3beada1554345a345 100644 (file)
@@ -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 );
 
index 0ff194e606dd1ae80f42cac5a878d2229680ccb3..05f8b8b9ea38c31b9d42cac79d0f4664b8610e56 100644 (file)
@@ -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 );