From 061a1dee44b9a8da26d29b7d75ade2c129cb23e0 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 27 Mar 2018 19:20:18 +0300 Subject: [PATCH 1/5] textscreen: Make txt_fileselect_s prompt member const --- textscreen/txt_fileselect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/textscreen/txt_fileselect.c b/textscreen/txt_fileselect.c index 8fefc66c..42b6f42d 100644 --- a/textscreen/txt_fileselect.c +++ b/textscreen/txt_fileselect.c @@ -32,7 +32,7 @@ struct txt_fileselect_s { txt_widget_t widget; txt_inputbox_t *inputbox; int size; - char *prompt; + const char *prompt; const char **extensions; }; From 0c4fe5bbe5efbef063e0d94b29cc2cc059fab654 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 27 Mar 2018 19:21:38 +0300 Subject: [PATCH 2/5] Make TXT_NewFileSelector prompt parameter const --- textscreen/txt_fileselect.c | 2 +- textscreen/txt_fileselect.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/textscreen/txt_fileselect.c b/textscreen/txt_fileselect.c index 42b6f42d..21016b79 100644 --- a/textscreen/txt_fileselect.c +++ b/textscreen/txt_fileselect.c @@ -808,7 +808,7 @@ static void InputBoxChanged(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(fileselect)) } txt_fileselect_t *TXT_NewFileSelector(char **variable, int size, - char *prompt, const char **extensions) + const char *prompt, const char **extensions) { txt_fileselect_t *fileselect; diff --git a/textscreen/txt_fileselect.h b/textscreen/txt_fileselect.h index 10ed84c1..fe5fac79 100644 --- a/textscreen/txt_fileselect.h +++ b/textscreen/txt_fileselect.h @@ -66,7 +66,7 @@ char *TXT_SelectFile(const char *prompt, const char **extensions); */ txt_fileselect_t *TXT_NewFileSelector(char **variable, int size, - char *prompt, const char **extensions); + const char *prompt, const char **extensions); /** * Special value to use for 'extensions' that selects a directory From fccdde81b5d69771667393972d48e2e7bc8bc7f9 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 27 Mar 2018 19:28:43 +0300 Subject: [PATCH 3/5] Make TXT_NewDropdownList values parameter const --- src/setup/multiplayer.c | 22 +++++++++++----------- src/setup/sound.c | 2 +- textscreen/examples/guitest.c | 2 +- textscreen/txt_dropdown.c | 2 +- textscreen/txt_dropdown.h | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index 284133d3..21bdda58 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -59,7 +59,7 @@ static const iwad_t fallback_iwads[] = { // Array of IWADs found to be installed static const iwad_t **found_iwads; -static char **iwad_labels; +static const char **iwad_labels; // Index of the currently selected IWAD @@ -71,49 +71,49 @@ static char *iwadfile; static const char *wad_extensions[] = { "wad", "lmp", "deh", NULL }; -static char *doom_skills[] = +static const char *doom_skills[] = { "I'm too young to die.", "Hey, not too rough.", "Hurt me plenty.", "Ultra-Violence.", "NIGHTMARE!", }; -static char *chex_skills[] = +static const char *chex_skills[] = { "Easy does it", "Not so sticky", "Gobs of goo", "Extreme ooze", "SUPER SLIMEY!" }; -static char *heretic_skills[] = +static const char *heretic_skills[] = { "Thou needeth a wet-nurse", "Yellowbellies-R-us", "Bringest them oneth", "Thou art a smite-meister", "Black plague possesses thee" }; -static char *hexen_fighter_skills[] = +static const char *hexen_fighter_skills[] = { "Squire", "Knight", "Warrior", "Berserker", "Titan" }; -static char *hexen_cleric_skills[] = +static const char *hexen_cleric_skills[] = { "Altar boy", "Acolyte", "Priest", "Cardinal", "Pope" }; -static char *hexen_mage_skills[] = +static const char *hexen_mage_skills[] = { "Apprentice", "Enchanter", "Sorceror", "Warlock", "Archimage" }; -static char *strife_skills[] = +static const char *strife_skills[] = { "Training", "Rookie", "Veteran", "Elite", "Bloodbath" }; -static char *character_classes[] = { "Fighter", "Cleric", "Mage" }; +static const char *character_classes[] = { "Fighter", "Cleric", "Mage" }; -static char *gamemodes[] = { "Co-operative", "Deathmatch", "Deathmatch 2.0" }; +static const char *gamemodes[] = { "Co-operative", "Deathmatch", "Deathmatch 2.0" }; -static char *strife_gamemodes[] = +static const char *strife_gamemodes[] = { "Normal deathmatch", "Items respawn", // (altdeath) diff --git a/src/setup/sound.c b/src/setup/sound.c index 0e3173ae..475cfb50 100644 --- a/src/setup/sound.c +++ b/src/setup/sound.c @@ -34,7 +34,7 @@ typedef enum NUM_OPLMODES, } oplmode_t; -static char *opltype_strings[] = +static const char *opltype_strings[] = { "OPL2", "OPL3" diff --git a/textscreen/examples/guitest.c b/textscreen/examples/guitest.c index 0307602c..faa5d28b 100644 --- a/textscreen/examples/guitest.c +++ b/textscreen/examples/guitest.c @@ -88,7 +88,7 @@ void CloseWindow(TXT_UNCAST_ARG(button), void *user_data) void UnicodeWindow(TXT_UNCAST_ARG(widget), void *user_data) { - static char *strings[] = { + static const char *strings[] = { "lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato", "domenica", }; diff --git a/textscreen/txt_dropdown.c b/textscreen/txt_dropdown.c index 5d72bf71..2439015b 100644 --- a/textscreen/txt_dropdown.c +++ b/textscreen/txt_dropdown.c @@ -288,7 +288,7 @@ txt_widget_class_t txt_dropdown_list_class = NULL, }; -txt_dropdown_list_t *TXT_NewDropdownList(int *variable, char **values, +txt_dropdown_list_t *TXT_NewDropdownList(int *variable, const char **values, int num_values) { txt_dropdown_list_t *list; diff --git a/textscreen/txt_dropdown.h b/textscreen/txt_dropdown.h index ca21ec8d..69bc7d50 100644 --- a/textscreen/txt_dropdown.h +++ b/textscreen/txt_dropdown.h @@ -43,7 +43,7 @@ struct txt_dropdown_list_s { txt_widget_t widget; int *variable; - char **values; + const char **values; int num_values; }; @@ -62,7 +62,7 @@ struct txt_dropdown_list_s */ txt_dropdown_list_t *TXT_NewDropdownList(int *variable, - char **values, int num_values); + const char **values, int num_values); #endif /* #ifndef TXT_DROPDOWN_H */ From 695895ddb2231ffed9284dd5346d1c6007e5c4df Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 27 Mar 2018 19:33:52 +0300 Subject: [PATCH 4/5] textscreen: Make AddOperatorButton label parameter const in calculator example --- textscreen/examples/calculator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/textscreen/examples/calculator.c b/textscreen/examples/calculator.c index f086e87e..c50af2ea 100644 --- a/textscreen/examples/calculator.c +++ b/textscreen/examples/calculator.c @@ -81,7 +81,7 @@ void Operator(TXT_UNCAST_ARG(button), TXT_UNCAST_ARG(op)) starting_input = 1; } -void AddOperatorButton(txt_table_t *table, char *label, operator_t op) +void AddOperatorButton(txt_table_t *table, const char *label, operator_t op) { char buf[10]; operator_t *op_copy; From f186ecd1ae72f3a76336cc6be983ea1d549b8e6b Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 27 Mar 2018 19:35:13 +0300 Subject: [PATCH 5/5] textscreen: Fix const correctness issue in guitest --- textscreen/examples/guitest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/textscreen/examples/guitest.c b/textscreen/examples/guitest.c index faa5d28b..1df95ce4 100644 --- a/textscreen/examples/guitest.c +++ b/textscreen/examples/guitest.c @@ -34,7 +34,7 @@ enum // also put some crazy extensions to test the escape function. a"b"c"""dd const char *extensions[] = { "wad", "lmp", "txt", "a\"b\"c\"\"\"dd", "", "\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"", NULL }; -char *radio_values[] = { "Badger", "Mushroom", "Snake" }; +const char *radio_values[] = { "Badger", "Mushroom", "Snake" }; char *textbox_value = NULL; int numbox_value = 0; int radiobutton_value;