shithub: choc

Download patch

ref: 052d6e3ba9de4f8810d73d45da50d1a823689630
parent: 5c28b4cd722fa8ebad86005c32c4618020fdee41
parent: f95176a5b8bfd253a2e90841055a573209ef5d4d
author: Simon Howard <[email protected]>
date: Fri May 25 18:34:53 EDT 2018

Merge pull request #1041 from turol/const

Fix const correctness in dehacked

--- a/src/deh_defs.h
+++ b/src/deh_defs.h
@@ -30,7 +30,7 @@
 
 struct deh_section_s
 {
-    char *name;
+    const char *name;
 
     // Called on startup to initialize code
 
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -445,7 +445,7 @@
     return 1;
 }
 
-int DEH_LoadLumpByName(char *name, boolean allow_long, boolean allow_error)
+int DEH_LoadLumpByName(const char *name, boolean allow_long, boolean allow_error)
 {
     int lumpnum;
 
--- a/src/deh_main.h
+++ b/src/deh_main.h
@@ -32,7 +32,7 @@
 void DEH_ParseCommandLine(void);
 int DEH_LoadFile(const char *filename);
 int DEH_LoadLump(int lumpnum, boolean allow_long, boolean allow_error);
-int DEH_LoadLumpByName(char *name, boolean allow_long, boolean allow_error);
+int DEH_LoadLumpByName(const char *name, boolean allow_long, boolean allow_error);
 
 boolean DEH_ParseAssignment(char *line, char **variable_name, char **value);
 
--- a/src/deh_mapping.h
+++ b/src/deh_mapping.h
@@ -60,7 +60,7 @@
 {
     // field name
    
-    char *name;
+    const char *name;
 
     // location relative to the base in the deh_mapping_t struct
     // If this is NULL, it is an unsupported mapping
--- a/src/deh_str.c
+++ b/src/deh_str.c
@@ -80,7 +80,7 @@
 // Look up a string to see if it has been replaced with something else
 // This will be used throughout the program to substitute text
 
-char *DEH_String(char *s)
+const char *DEH_String(const char *s)
 {
     deh_substitution_t *subst;
 
@@ -366,9 +366,9 @@
 
 // Get replacement format string, checking arguments.
 
-static const char *FormatStringReplacement(char *s)
+static const char *FormatStringReplacement(const char *s)
 {
-    char *repl;
+    const char *repl;
 
     repl = DEH_String(s);
 
@@ -385,7 +385,7 @@
 
 // printf(), performing a replacement on the format string.
 
-void DEH_printf(char *fmt, ...)
+void DEH_printf(const char *fmt, ...)
 {
     va_list args;
     const char *repl;
@@ -401,7 +401,7 @@
 
 // fprintf(), performing a replacement on the format string.
 
-void DEH_fprintf(FILE *fstream, char *fmt, ...)
+void DEH_fprintf(FILE *fstream, const char *fmt, ...)
 {
     va_list args;
     const char *repl;
@@ -417,7 +417,7 @@
 
 // snprintf(), performing a replacement on the format string.
 
-void DEH_snprintf(char *buffer, size_t len, char *fmt, ...)
+void DEH_snprintf(char *buffer, size_t len, const char *fmt, ...)
 {
     va_list args;
     const char *repl;
--- a/src/deh_str.h
+++ b/src/deh_str.h
@@ -24,10 +24,10 @@
 
 // Used to do dehacked text substitutions throughout the program
 
-char *DEH_String(char *s) PRINTF_ARG_ATTR(1);
-void DEH_printf(char *fmt, ...) PRINTF_ATTR(1, 2);
-void DEH_fprintf(FILE *fstream, char *fmt, ...) PRINTF_ATTR(2, 3);
-void DEH_snprintf(char *buffer, size_t len, char *fmt, ...) PRINTF_ATTR(3, 4);
+const char *DEH_String(const char *s) PRINTF_ARG_ATTR(1);
+void DEH_printf(const char *fmt, ...) PRINTF_ATTR(1, 2);
+void DEH_fprintf(FILE *fstream, const char *fmt, ...) PRINTF_ATTR(2, 3);
+void DEH_snprintf(char *buffer, size_t len, const char *fmt, ...) PRINTF_ATTR(3, 4);
 void DEH_AddStringReplacement(const char *from_text, const char *to_text);
 
 
--- a/src/doom/deh_bexstr.c
+++ b/src/doom/deh_bexstr.c
@@ -26,8 +26,8 @@
 #include "dstrings.h"
 
 typedef struct {
-    char *macro;
-    char *string;
+    const char *macro;
+    const char *string;
 } bex_string_t;
 
 // mnemonic keys table
--- a/src/doom/deh_cheat.c
+++ b/src/doom/deh_cheat.c
@@ -28,7 +28,7 @@
 
 typedef struct 
 {
-    char *name;
+    const char *name;
     cheatseq_t *seq;
 } deh_cheat_t;
 
--- a/src/doom/deh_doom.c
+++ b/src/doom/deh_doom.c
@@ -19,7 +19,7 @@
 #include "deh_defs.h"
 #include "deh_main.h"
 
-char *deh_signatures[] =
+const char *deh_signatures[] =
 {
     "Patch File for DeHackEd v2.3",
     "Patch File for DeHackEd v3.0",
--- a/src/doom/deh_misc.c
+++ b/src/doom/deh_misc.c
@@ -132,7 +132,7 @@
 
 static struct
 {
-    char *deh_name;
+    const char *deh_name;
     int *value;
 } misc_settings[] = {
     {"Initial Health",      &deh_initial_health},
--- a/src/doom/f_finale.c
+++ b/src/doom/f_finale.c
@@ -94,8 +94,8 @@
     { pack_plut, 1, 31, "RROCK19",   P6TEXT},
 };
 
-char*	finaletext;
-char*	finaleflat;
+const char *finaletext;
+const char *finaleflat;
 
 void	F_StartCast (void);
 void	F_CastTicker (void);
@@ -660,7 +660,7 @@
 
 static void F_ArtScreenDrawer(void)
 {
-    char *lumpname;
+    const char *lumpname;
     
     if (gameepisode == 3)
     {
--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -618,7 +618,7 @@
     if ((gamemode == commercial)
      && (gameversion == exe_final2 || gameversion == exe_chex))
     {
-        char *skytexturename;
+        const char *skytexturename;
 
         if (gamemap < 12)
         {
@@ -1742,7 +1742,7 @@
   int		episode,
   int		map )
 {
-    char *skytexturename;
+    const char *skytexturename;
     int             i;
 
     if (paused)
--- a/src/doom/hu_stuff.c
+++ b/src/doom/hu_stuff.c
@@ -370,7 +370,7 @@
 {
 
     int		i;
-    char*	s;
+    const char *s;
 
     if (headsupactive)
 	HU_Stop();
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -2246,7 +2246,7 @@
 
     else if (M_ParmExists("-cdrom"))
     {
-        savegamedir = configdir;
+        savegamedir = M_StringDuplicate(configdir);
     }
 #endif
     // If not "doing" a configuration directory (Windows), don't "do"
--- a/src/strife/g_game.c
+++ b/src/strife/g_game.c
@@ -1934,7 +1934,7 @@
 ( skill_t       skill,
   int           map ) 
 { 
-    char *skytexturename;
+    const char *skytexturename;
     int             i; 
 
     if (paused) 
--- a/src/strife/hu_stuff.c
+++ b/src/strife/hu_stuff.c
@@ -214,7 +214,7 @@
 void HU_Start(void)
 {
     int         i;
-    char*       s;
+    const char *s;
 
     // haleyjd 20120211: [STRIFE] not called here.
     //if (headsupactive)
--- a/src/strife/p_switch.c
+++ b/src/strife/p_switch.c
@@ -1015,7 +1015,7 @@
             P_GiveItemToPlayer(thing->player, SPR_TOKN, MT_TOKEN_NEW_ACCURACY);
             P_ChangeSwitchTexture(line, 0);
             DEH_snprintf(usemessage, sizeof(usemessage),
-                DEH_String("Congratulations! You have completed the training area."));
+                "Congratulations! You have completed the training area.");
             thing->player->message = usemessage;
         }
         break;