From: <kla...@us...> - 2017-06-21 20:11:59
|
Revision: 13731 http://sourceforge.net/p/vegastrike/code/13731 Author: klaussfreire Date: 2017-06-21 20:11:56 +0000 (Wed, 21 Jun 2017) Log Message: ----------- GCC 7 fix: use const char* instead of char* GCC 7 is far stricter with casting from/to const, so use const char * in vssetup structures and functions to avoid having to cast constant strings into mutable char* Modified Paths: -------------- trunk/vegastrike/setup/src/include/central.cpp trunk/vegastrike/setup/src/include/central.h trunk/vegastrike/setup/src/include/display_gtk.cpp trunk/vegastrike/setup/src/include/file.cpp trunk/vegastrike/setup/src/include/file.h Modified: trunk/vegastrike/setup/src/include/central.cpp =================================================================== --- trunk/vegastrike/setup/src/include/central.cpp 2017-06-21 18:02:22 UTC (rev 13730) +++ trunk/vegastrike/setup/src/include/central.cpp 2017-06-21 20:11:56 UTC (rev 13731) @@ -28,7 +28,7 @@ ShowMain(); } -void SetGroup(char *group, char *setting) { +void SetGroup(const char *group, const char *setting) { struct group *CURRENT; CURRENT = &GROUPS; do { @@ -36,7 +36,7 @@ if (strcmp(group, CURRENT->name) == 0) { CURRENT->setting = NewString(setting); return; } } while ((CURRENT = CURRENT->next) > 0); } -void SetInfo(char *catagory, char *info) { +void SetInfo(const char *catagory, const char *info) { struct catagory *CURRENT; CURRENT = &CATS; do { @@ -45,7 +45,7 @@ } while ((CURRENT = CURRENT->next) > 0); } -char *GetInfo(char *catagory) { +const char *GetInfo(const char *catagory) { struct catagory *CURRENT; CURRENT = &CATS; do { @@ -58,7 +58,7 @@ return catagory; } -char *GetSetting(char *group) { +const char *GetSetting(const char *group) { struct group *CUR; CUR = &GROUPS; do { @@ -65,10 +65,10 @@ if (CUR->name == NULL) { continue; } if (strcmp(CUR->name, group) == 0) { return CUR->setting; } } while ((CUR = CUR->next) > 0); - return '\0'; + return "\0"; } -struct catagory *GetCatStruct(char *name) { +struct catagory *GetCatStruct(const char *name) { struct catagory *CUR; CUR = &CATS; do { @@ -78,7 +78,7 @@ return 0; } -struct group *GetGroupStruct(char *name) { +struct group *GetGroupStruct(const char *name) { struct group *CUR; CUR = &GROUPS; do { Modified: trunk/vegastrike/setup/src/include/central.h =================================================================== --- trunk/vegastrike/setup/src/include/central.h 2017-06-21 18:02:22 UTC (rev 13730) +++ trunk/vegastrike/setup/src/include/central.h 2017-06-21 20:11:56 UTC (rev 13731) @@ -45,32 +45,32 @@ #define CONFIG_FILE "setup.config" void Start(int*,char***); -void SetGroup(char *group, char *setting); -void SetInfo(char *catagory, char *info); -char *GetInfo(char *catagory); -char *GetSetting(char *group); -struct catagory *GetCatStruct(char *name); -struct group *GetGroupStruct(char *name); +void SetGroup(const char *group, const char *setting); +void SetInfo(const char *catagory, const char *info); +const char *GetInfo(const char *catagory); +const char *GetSetting(const char *group); +struct catagory *GetCatStruct(const char *name); +struct group *GetGroupStruct(const char *name); typedef struct _GtkWidget GtkWidget; struct catagory { - char *group; - char *name; - char *info; + const char *group; + const char *name; + const char *info; GtkWidget *button; struct catagory *next; }; struct group { - char *name; - char *setting; + const char *name; + const char *setting; struct group *next; }; struct global_settings { - char *program_name; - char *config_file; - char *temp_file; - char *data_path; + const char *program_name; + const char *config_file; + const char *temp_file; + const char *data_path; int columns; }; Modified: trunk/vegastrike/setup/src/include/display_gtk.cpp =================================================================== --- trunk/vegastrike/setup/src/include/display_gtk.cpp 2017-06-21 18:02:22 UTC (rev 13730) +++ trunk/vegastrike/setup/src/include/display_gtk.cpp 2017-06-21 20:11:56 UTC (rev 13731) @@ -16,7 +16,7 @@ **************************************************************************/ #include "display.h" #ifdef GTK -void AddCats(GtkWidget *vbox, char *group, char *def); +void AddCats(GtkWidget *vbox, const char *group, const char *def); void ClickButton(GtkWidget *w, struct catagory *CUR); #ifdef _WIN32 @@ -149,7 +149,7 @@ } -void AddCats(GtkWidget *vbox, char *group, char *def) { +void AddCats(GtkWidget *vbox, const char *group, const char *def) { struct catagory *CUR; #ifdef USE_RADIO GSList *radiogroup = NULL; @@ -192,7 +192,8 @@ void ClickButton(GtkWidget *w, struct catagory *CUR) { struct catagory *OLD; struct group *NEW; - char *new_text, *old; + char *new_text; + const char *old; #ifdef USE_RADIO int length; Modified: trunk/vegastrike/setup/src/include/file.cpp =================================================================== --- trunk/vegastrike/setup/src/include/file.cpp 2017-06-21 18:02:22 UTC (rev 13730) +++ trunk/vegastrike/setup/src/include/file.cpp 2017-06-21 20:11:56 UTC (rev 13731) @@ -226,7 +226,7 @@ } } -void Modconfig( int setting, char *name, char *group ) +void Modconfig( int setting, const char *name, const char *group ) { FILE *rp, *wp; //read and write char line[MAX_READ+1], write[MAX_READ+1], mid[MAX_READ+1]; @@ -373,12 +373,12 @@ fclose( wp ); } -void EnableSetting( char *name, char *group ) +void EnableSetting( const char *name, const char *group ) { Modconfig( 2, name, group ); } -void DisableSetting( char *name, char *group ) +void DisableSetting( const char *name, const char *group ) { Modconfig( 1, name, group ); } Modified: trunk/vegastrike/setup/src/include/file.h =================================================================== --- trunk/vegastrike/setup/src/include/file.h 2017-06-21 18:02:22 UTC (rev 13730) +++ trunk/vegastrike/setup/src/include/file.h 2017-06-21 20:11:56 UTC (rev 13731) @@ -23,8 +23,8 @@ void LoadMainConfig(void); void LoadConfig(void); -void Modconfig(int setting, char *name, char *group); -void EnableSetting(char *name, char *group); -void DisableSetting(char *name, char *group); +void Modconfig(int setting, const char *name, const char *group); +void EnableSetting(const char *name, const char *group); +void DisableSetting(const char *name, const char *group); #endif |