shithub: choc

Download patch

ref: 5ff1698982eb861a55031de14654a195a6895006
parent: ded7e89d0f5ee328b88c90000dcf3e3e2cba7b88
parent: f3ce0c7fdd434b100fd0aa51066602c1a8a7599d
author: Simon Howard <[email protected]>
date: Sat Mar 17 19:49:03 EDT 2018

Merge branch 'master' of github.com:chocolate-doom/chocolate-doom

--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -17,6 +17,12 @@
 
 if HAVE_PYTHON
 
+if HAVE_WINDRES
+
+WIN32=-D_WIN32
+
+endif
+
 GENERATED_MAN_PAGES =               \
            @[email protected]         \
            default.cfg.5            \
@@ -73,7 +79,7 @@
                   $(top_srcdir)/src/ $(top_srcdir)/src/doom/ > $@
 
 INSTALL.doom: INSTALL.template
-	$(srcdir)/simplecpp -DDOOM \
+	$(srcdir)/simplecpp -DDOOM $(WIN32) \
             -DLONG_GAME_NAME="@PACKAGE_SHORTNAME@ Doom" \
             -DLONG_EXE_NAME="@PROGRAM_PREFIX@doom" \
             -DPRECOMPILED < $(srcdir)/INSTALL.template > $@
@@ -99,7 +105,7 @@
                   $(top_srcdir)/src/ $(top_srcdir)/src/heretic/ > $@
 
 INSTALL.heretic: INSTALL.template
-	$(srcdir)/simplecpp -DHERETIC \
+	$(srcdir)/simplecpp -DHERETIC $(WIN32) \
             -DLONG_GAME_NAME="@PACKAGE_SHORTNAME@ Heretic" \
             -DLONG_EXE_NAME="@PROGRAM_PREFIX@heretic" \
             -DPRECOMPILED < $(srcdir)/INSTALL.template > $@
@@ -126,7 +132,7 @@
                   $(top_srcdir)/src/ $(top_srcdir)/src/hexen/ > $@
 
 INSTALL.hexen: INSTALL.template
-	$(srcdir)/simplecpp -DHEXEN \
+	$(srcdir)/simplecpp -DHEXEN $(WIN32) \
             -DLONG_GAME_NAME="@PACKAGE_SHORTNAME@ Hexen" \
             -DLONG_EXE_NAME="@PROGRAM_PREFIX@hexen" \
             -DPRECOMPILED < $(srcdir)/INSTALL.template > $@
@@ -163,7 +169,7 @@
                   $(top_srcdir)/src/ $(top_srcdir)/src/strife/ > $@
 
 INSTALL.strife: INSTALL.template
-	$(srcdir)/simplecpp -DSTRIFE  \
+	$(srcdir)/simplecpp -DSTRIFE $(WIN32) \
             -DLONG_EXE_NAME="@PROGRAM_PREFIX@strife" \
             -DLONG_GAME_NAME="@PACKAGE_SHORTNAME@ Strife" \
             -DPRECOMPILED < $(srcdir)/INSTALL.template > $@
--- a/pkg/win32/GNUmakefile
+++ b/pkg/win32/GNUmakefile
@@ -53,11 +53,7 @@
 		cp $(TOPLEVEL)/$$f $@/$$(basename $$f .md).txt;  \
 	done
 	cp $(TOPLEVEL)/man/CMDLINE.$* $@/CMDLINE.txt
-
-	$(TOPLEVEL)/man/simplecpp -D_WIN32 -DPRECOMPILED  \
-	             -D$(shell echo $* | tr a-z A-Z)      \
-	         < $(TOPLEVEL)/man/INSTALL.template       \
-	         > $@/INSTALL.txt
+	cp $(TOPLEVEL)/man/INSTALL.$* $@/INSTALL.txt
 
 clean:
 	rm -f $(ZIPS)
--- a/src/deh_str.c
+++ b/src/deh_str.c
@@ -38,9 +38,9 @@
 
 // This is the algorithm used by glib
 
-static unsigned int strhash(char *s)
+static unsigned int strhash(const char *s)
 {
-    char *p = s;
+    const char *p = s;
     unsigned int h = *p;
   
     if (h)
@@ -52,7 +52,7 @@
     return h;
 }
 
-static deh_substitution_t *SubstitutionForString(char *s)
+static deh_substitution_t *SubstitutionForString(const char *s)
 {
     int entry;
 
@@ -165,7 +165,7 @@
     ++hash_table_entries;
 }
 
-void DEH_AddStringReplacement(char *from_text, char *to_text)
+void DEH_AddStringReplacement(const char *from_text, const char *to_text)
 {
     deh_substitution_t *sub;
     size_t len;
@@ -251,7 +251,7 @@
 // Given the specified string, get the type of the first format
 // string encountered.
 
-static format_arg_t NextFormatArgument(char **str)
+static format_arg_t NextFormatArgument(const char **str)
 {
     format_arg_t argtype;
 
@@ -326,10 +326,10 @@
 
 // Return true if the specified string contains no format arguments.
 
-static boolean ValidFormatReplacement(char *original, char *replacement)
+static boolean ValidFormatReplacement(const char *original, const char *replacement)
 {
-    char *rover1;
-    char *rover2;
+    const char *rover1;
+    const char *rover2;
     int argtype1, argtype2;
 
     // Check each argument in turn and compare types.
--- a/src/deh_str.h
+++ b/src/deh_str.h
@@ -28,7 +28,7 @@
 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);
-void DEH_AddStringReplacement(char *from_text, char *to_text);
+void DEH_AddStringReplacement(const char *from_text, const char *to_text);
 
 
 #if 0
--- a/src/doom/hu_lib.c
+++ b/src/doom/hu_lib.c
@@ -208,8 +208,8 @@
 void
 HUlib_addMessageToSText
 ( hu_stext_t*	s,
-  char*		prefix,
-  char*		msg )
+  const char*	prefix,
+  const char*	msg )
 {
     HUlib_addLineToSText(s);
     if (prefix)
--- a/src/doom/hu_lib.h
+++ b/src/doom/hu_lib.h
@@ -134,8 +134,8 @@
 void
 HUlib_addMessageToSText
 ( hu_stext_t*	s,
-  char*		prefix,
-  char*		msg );
+  const char*	prefix,
+  const char*	msg );
 
 // draws stext
 void HUlib_drawSText(hu_stext_t* s);
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -632,32 +632,38 @@
 
 static boolean ReadSubstituteConfig(char *filename)
 {
-    char line[128];
-    FILE *fs;
-    char *error;
+    char *buffer;
+    char *line;
     int linenum = 1;
-//    int old_subst_music_len;
 
-    fs = fopen(filename, "r");
-
-    if (fs == NULL)
+    // This unnecessarily opens the file twice...
+    if (!M_FileExists(filename))
     {
         return false;
     }
 
-//    old_subst_music_len = subst_music_len;
+    M_ReadFile(filename, (byte **) &buffer);
 
-    while (!feof(fs))
+    line = buffer;
+
+    while (line != NULL)
     {
-        char *retval;
-        M_StringCopy(line, "", sizeof(line));
-        retval = fgets(line, sizeof(line), fs);
+        char *error;
+        char *next;
 
-        if (retval == NULL)
+        // find end of line
+        char *eol = strchr(line, '\n');
+        if (eol != NULL)
         {
-            fprintf(stderr, "%s:%i: Unexpected end of file\n", filename, linenum);
-            break;
+            // change the newline into NUL
+            *eol = '\0';
+            next = eol + 1;
         }
+        else
+        {
+            // end of buffer
+            next = NULL;
+        }
 
         error = ParseSubstituteLine(filename, line);
 
@@ -667,9 +673,10 @@
         }
 
         ++linenum;
+        line = next;
     }
 
-    fclose(fs);
+    Z_Free(buffer);
 
     return true;
 }
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -158,7 +158,7 @@
     return zonemem;
 }
 
-void I_PrintBanner(char *msg)
+void I_PrintBanner(const char *msg)
 {
     int i;
     int spaces = 35 - (strlen(msg) / 2);
@@ -181,7 +181,7 @@
     putchar('\n');
 }
 
-void I_PrintStartupBanner(char *gamedescription)
+void I_PrintStartupBanner(const char *gamedescription)
 {
     I_PrintDivider();
     I_PrintBanner(gamedescription);
@@ -261,7 +261,7 @@
 
 static boolean already_quitting = false;
 
-void I_Error (char *error, ...)
+void I_Error (const char *error, ...)
 {
     char msgbuf[512];
     va_list argptr;
--- a/src/i_system.h
+++ b/src/i_system.h
@@ -52,7 +52,7 @@
 // Clean exit, displays sell blurb.
 void I_Quit (void);
 
-void I_Error (char *error, ...) PRINTF_ATTR(1, 2);
+void I_Error (const char *error, ...) PRINTF_ATTR(1, 2);
 
 void I_Tactile (int on, int off, int total);
 
@@ -72,11 +72,11 @@
 
 // Print startup banner copyright message.
 
-void I_PrintStartupBanner(char *gamedescription);
+void I_PrintStartupBanner(const char *gamedescription);
 
 // Print a centered text banner displaying the given string.
 
-void I_PrintBanner(char *text);
+void I_PrintBanner(const char *text);
 
 // Print a dividing line for startup banners.
 
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -52,7 +52,7 @@
 // Create a directory
 //
 
-void M_MakeDirectory(char *path)
+void M_MakeDirectory(const char *path)
 {
 #ifdef _WIN32
     mkdir(path);
@@ -63,7 +63,7 @@
 
 // Check if a file exists
 
-boolean M_FileExists(char *filename)
+boolean M_FileExists(const char *filename)
 {
     FILE *fstream;
 
@@ -86,7 +86,7 @@
 // Check if a file exists by probing for common case variation of its filename.
 // Returns a newly allocated string that the caller is responsible for freeing.
 
-char *M_FileCaseExists(char *path)
+char *M_FileCaseExists(const char *path)
 {
     char *path_dup, *filename, *ext;
 
@@ -178,7 +178,7 @@
 // M_WriteFile
 //
 
-boolean M_WriteFile(char *name, void *source, int length)
+boolean M_WriteFile(const char *name, void *source, int length)
 {
     FILE *handle;
     int	count;
@@ -202,7 +202,7 @@
 // M_ReadFile
 //
 
-int M_ReadFile(char *name, byte **buffer)
+int M_ReadFile(const char *name, byte **buffer)
 {
     FILE *handle;
     int	count, length;
@@ -217,7 +217,7 @@
 
     length = M_FileLength(handle);
     
-    buf = Z_Malloc (length, PU_STATIC, NULL);
+    buf = Z_Malloc (length + 1, PU_STATIC, NULL);
     count = fread(buf, 1, length, handle);
     fclose (handle);
 	
@@ -224,6 +224,7 @@
     if (count < length)
 	I_Error ("Couldn't read file %s", name);
 		
+    buf[length] = '\0';
     *buffer = buf;
     return length;
 }
@@ -233,7 +234,7 @@
 //
 // The returned value must be freed with Z_Free after use.
 
-char *M_TempFile(char *s)
+char *M_TempFile(const char *s)
 {
     char *tempdir;
 
@@ -264,10 +265,10 @@
         || sscanf(str, " %d", result) == 1;
 }
 
-void M_ExtractFileBase(char *path, char *dest)
+void M_ExtractFileBase(const char *path, char *dest)
 {
-    char *src;
-    char *filename;
+    const char *src;
+    const char *filename;
     int length;
 
     src = path + strlen(path) - 1;
@@ -343,7 +344,7 @@
 // Case-insensitive version of strstr()
 //
 
-char *M_StrCaseStr(char *haystack, char *needle)
+const char *M_StrCaseStr(const char *haystack, const char *needle)
 {
     unsigned int haystack_len;
     unsigned int needle_len;
--- a/src/m_misc.h
+++ b/src/m_misc.h
@@ -25,18 +25,18 @@
 
 #include "doomtype.h"
 
-boolean M_WriteFile(char *name, void *source, int length);
-int M_ReadFile(char *name, byte **buffer);
-void M_MakeDirectory(char *dir);
-char *M_TempFile(char *s);
-boolean M_FileExists(char *file);
-char *M_FileCaseExists(char *file);
+boolean M_WriteFile(const char *name, void *source, int length);
+int M_ReadFile(const char *name, byte **buffer);
+void M_MakeDirectory(const char *dir);
+char *M_TempFile(const char *s);
+boolean M_FileExists(const char *file);
+char *M_FileCaseExists(const char *file);
 long M_FileLength(FILE *handle);
 boolean M_StrToInt(const char *str, int *result);
-void M_ExtractFileBase(char *path, char *dest);
+void M_ExtractFileBase(const char *path, char *dest);
 void M_ForceUppercase(char *text);
 void M_ForceLowercase(char *text);
-char *M_StrCaseStr(char *haystack, char *needle);
+const char *M_StrCaseStr(const char *haystack, const char *needle);
 char *M_StringDuplicate(const char *orig);
 boolean M_StringCopy(char *dest, const char *src, size_t dest_size);
 boolean M_StringConcat(char *dest, const char *src, size_t dest_size);
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -258,7 +258,7 @@
 // Returns -1 if name not found.
 //
 
-lumpindex_t W_CheckNumForName(char* name)
+lumpindex_t W_CheckNumForName(const char *name)
 {
     lumpindex_t i;
 
@@ -307,7 +307,7 @@
 // W_GetNumForName
 // Calls W_CheckNumForName, but bombs out if not found.
 //
-lumpindex_t W_GetNumForName(char* name)
+lumpindex_t W_GetNumForName(const char *name)
 {
     lumpindex_t i;
 
@@ -428,7 +428,7 @@
 //
 // W_CacheLumpName
 //
-void *W_CacheLumpName(char *name, int tag)
+void *W_CacheLumpName(const char *name, int tag)
 {
     return W_CacheLumpNum(W_GetNumForName(name), tag);
 }
@@ -464,7 +464,7 @@
     }
 }
 
-void W_ReleaseLumpName(char *name)
+void W_ReleaseLumpName(const char *name)
 {
     W_ReleaseLumpNum(W_GetNumForName(name));
 }
--- a/src/w_wad.h
+++ b/src/w_wad.h
@@ -56,14 +56,14 @@
 wad_file_t *W_AddFile(char *filename);
 void W_Reload(void);
 
-lumpindex_t W_CheckNumForName(char *name);
-lumpindex_t W_GetNumForName(char *name);
+lumpindex_t W_CheckNumForName(const char *name);
+lumpindex_t W_GetNumForName(const char *name);
 
 int W_LumpLength(lumpindex_t lump);
 void W_ReadLump(lumpindex_t lump, void *dest);
 
 void *W_CacheLumpNum(lumpindex_t lump, int tag);
-void *W_CacheLumpName(char *name, int tag);
+void *W_CacheLumpName(const char *name, int tag);
 
 void W_GenerateHashTable(void);
 
@@ -70,6 +70,6 @@
 extern unsigned int W_LumpNameHash(const char *s);
 
 void W_ReleaseLumpNum(lumpindex_t lump);
-void W_ReleaseLumpName(char *name);
+void W_ReleaseLumpName(const char *name);
 
 #endif
--- a/src/z_native.c
+++ b/src/z_native.c
@@ -442,7 +442,7 @@
 // Z_ChangeTag
 //
 
-void Z_ChangeTag2(void *ptr, int tag, char *file, int line)
+void Z_ChangeTag2(void *ptr, int tag, const char *file, int line)
 {
     memblock_t*	block;
 	
--- a/src/z_zone.c
+++ b/src/z_zone.c
@@ -490,7 +490,7 @@
 //
 // Z_ChangeTag
 //
-void Z_ChangeTag2(void *ptr, int tag, char *file, int line)
+void Z_ChangeTag2(void *ptr, int tag, const char *file, int line)
 {
     memblock_t*	block;
 	
--- a/src/z_zone.h
+++ b/src/z_zone.h
@@ -57,7 +57,7 @@
 void    Z_DumpHeap (int lowtag, int hightag);
 void    Z_FileDumpHeap (FILE *f);
 void    Z_CheckHeap (void);
-void    Z_ChangeTag2 (void *ptr, int tag, char *file, int line);
+void    Z_ChangeTag2 (void *ptr, int tag, const char *file, int line);
 void    Z_ChangeUser(void *ptr, void **user);
 int     Z_FreeMemory (void);
 unsigned int Z_ZoneSize(void);
--- a/textscreen/txt_button.c
+++ b/textscreen/txt_button.c
@@ -93,13 +93,13 @@
     NULL,
 };
 
-void TXT_SetButtonLabel(txt_button_t *button, char *label)
+void TXT_SetButtonLabel(txt_button_t *button, const char *label)
 {
     free(button->label);
     button->label = strdup(label);
 }
 
-txt_button_t *TXT_NewButton(char *label)
+txt_button_t *TXT_NewButton(const char *label)
 {
     txt_button_t *button;
 
@@ -113,7 +113,7 @@
 
 // Button with a callback set automatically
 
-txt_button_t *TXT_NewButton2(char *label, TxtWidgetSignalFunc func,
+txt_button_t *TXT_NewButton2(const char *label, TxtWidgetSignalFunc func,
                              void *user_data)
 {
     txt_button_t *button;
--- a/textscreen/txt_button.h
+++ b/textscreen/txt_button.h
@@ -45,7 +45,7 @@
  * @return             Pointer to the new button widget.
  */
 
-txt_button_t *TXT_NewButton(char *label);
+txt_button_t *TXT_NewButton(const char *label);
 
 /**
  * Create a new button widget, binding the "pressed" signal to a
@@ -57,7 +57,7 @@
  * @return             Pointer to the new button widget.
  */
 
-txt_button_t *TXT_NewButton2(char *label, TxtWidgetSignalFunc func,
+txt_button_t *TXT_NewButton2(const char *label, TxtWidgetSignalFunc func,
                              void *user_data);
 
 /**
@@ -67,7 +67,7 @@
  * @param label        The new label (UTF-8 format).
  */
 
-void TXT_SetButtonLabel(txt_button_t *button, char *label);
+void TXT_SetButtonLabel(txt_button_t *button, const char *label);
 
 #endif /* #ifndef TXT_BUTTON_H */
 
--- a/textscreen/txt_checkbox.c
+++ b/textscreen/txt_checkbox.c
@@ -116,7 +116,7 @@
     NULL,
 };
 
-txt_checkbox_t *TXT_NewCheckBox(char *label, int *variable)
+txt_checkbox_t *TXT_NewCheckBox(const char *label, int *variable)
 {
     txt_checkbox_t *checkbox;
 
@@ -130,7 +130,7 @@
     return checkbox;
 }
 
-txt_checkbox_t *TXT_NewInvertedCheckBox(char *label, int *variable)
+txt_checkbox_t *TXT_NewInvertedCheckBox(const char *label, int *variable)
 {
     txt_checkbox_t *result;
 
--- a/textscreen/txt_checkbox.h
+++ b/textscreen/txt_checkbox.h
@@ -55,7 +55,7 @@
  * @return              Pointer to the new checkbox.
  */
 
-txt_checkbox_t *TXT_NewCheckBox(char *label, int *variable);
+txt_checkbox_t *TXT_NewCheckBox(const char *label, int *variable);
 
 /**
  * Create a new inverted checkbox.
@@ -69,7 +69,7 @@
  * @return              Pointer to the new checkbox.
  */
 
-txt_checkbox_t *TXT_NewInvertedCheckBox(char *label, int *variable);
+txt_checkbox_t *TXT_NewInvertedCheckBox(const char *label, int *variable);
 
 #endif /* #ifndef TXT_CHECKBOX_H */
 
--- a/textscreen/txt_desktop.c
+++ b/textscreen/txt_desktop.c
@@ -220,7 +220,7 @@
     TXT_DrawString("=Help ");
 }
 
-void TXT_SetDesktopTitle(char *title)
+void TXT_SetDesktopTitle(const char *title)
 {
     free(desktop_title);
     desktop_title = strdup(title);
--- a/textscreen/txt_desktop.h
+++ b/textscreen/txt_desktop.h
@@ -39,7 +39,7 @@
  * @param title         The title to display (UTF-8 format).
  */
 
-void TXT_SetDesktopTitle(char *title);
+void TXT_SetDesktopTitle(const char *title);
 
 /**
  * Exit the currently-running main loop and return from the
--- a/textscreen/txt_fileselect.c
+++ b/textscreen/txt_fileselect.c
@@ -155,7 +155,7 @@
     return 0;
 }
 
-char *TXT_SelectFile(char *window_title, char **extensions)
+char *TXT_SelectFile(const char *window_title, char **extensions)
 {
     return NULL;
 }
@@ -517,7 +517,7 @@
 // return a pointer to a string that is a case-insensitive
 // pattern representation (like [Ww][Aa][Dd])
 //
-static char *ExpandExtension(char *orig)
+static char *ExpandExtension(const char *orig)
 {
     int oldlen, newlen, i;
     char *c, *newext = NULL;
@@ -550,7 +550,7 @@
     return newext;
 }
 
-char *TXT_SelectFile(char *window_title, char **extensions)
+char *TXT_SelectFile(const char *window_title, char **extensions)
 {
     unsigned int i;
     size_t len;
--- a/textscreen/txt_fileselect.h
+++ b/textscreen/txt_fileselect.h
@@ -50,7 +50,7 @@
  *                    to select directories.
  */
 
-char *TXT_SelectFile(char *prompt, char **extensions);
+char *TXT_SelectFile(const char *prompt, char **extensions);
 
 /**
  * Create a new txt_fileselect_t widget.
--- a/textscreen/txt_label.c
+++ b/textscreen/txt_label.c
@@ -113,7 +113,7 @@
     NULL,
 };
 
-void TXT_SetLabel(txt_label_t *label, char *value)
+void TXT_SetLabel(txt_label_t *label, const char *value)
 {
     char *p;
     unsigned int y;
@@ -131,7 +131,7 @@
 
     label->h = 1;
 
-    for (p = value; *p != '\0'; ++p)
+    for (p = label->label; *p != '\0'; ++p)
     {
         if (*p == '\n')
         {
@@ -168,7 +168,7 @@
     }
 }
 
-txt_label_t *TXT_NewLabel(char *text)
+txt_label_t *TXT_NewLabel(const char *text)
 {
     txt_label_t *label;
 
--- a/textscreen/txt_label.h
+++ b/textscreen/txt_label.h
@@ -49,7 +49,7 @@
  * @return              Pointer to the new label widget.
  */
 
-txt_label_t *TXT_NewLabel(char *label);
+txt_label_t *TXT_NewLabel(const char *label);
 
 /**
  * Set the string displayed in a label widget.
@@ -58,7 +58,7 @@
  * @param value         The string to display (UTF-8 format).
  */
 
-void TXT_SetLabel(txt_label_t *label, char *value);
+void TXT_SetLabel(txt_label_t *label, const char *value);
 
 /**
  * Set the background color of a label widget.
--- a/textscreen/txt_main.h
+++ b/textscreen/txt_main.h
@@ -180,7 +180,7 @@
 void TXT_SetInputMode(txt_input_mode_t mode);
 
 // Set the window title of the window containing the text mode screen
-void TXT_SetWindowTitle(char *title);
+void TXT_SetWindowTitle(const char *title);
 
 // Safe string copy.
 void TXT_StringCopy(char *dest, const char *src, size_t dest_len);
--- a/textscreen/txt_radiobutton.c
+++ b/textscreen/txt_radiobutton.c
@@ -121,7 +121,7 @@
     NULL,
 };
 
-txt_radiobutton_t *TXT_NewRadioButton(char *label, int *variable, int value)
+txt_radiobutton_t *TXT_NewRadioButton(const char *label, int *variable, int value)
 {
     txt_radiobutton_t *radiobutton;
 
@@ -135,7 +135,7 @@
     return radiobutton;
 }
 
-void TXT_SetRadioButtonLabel(txt_radiobutton_t *radiobutton, char *value)
+void TXT_SetRadioButtonLabel(txt_radiobutton_t *radiobutton, const char *value)
 {
     free(radiobutton->label);
     radiobutton->label = strdup(value);
--- a/textscreen/txt_radiobutton.h
+++ b/textscreen/txt_radiobutton.h
@@ -63,7 +63,7 @@
  * @return               Pointer to the new radio button widget.
  */
 
-txt_radiobutton_t *TXT_NewRadioButton(char *label, int *variable, int value);
+txt_radiobutton_t *TXT_NewRadioButton(const char *label, int *variable, int value);
 
 /**
  * Set the label on a radio button.
@@ -72,7 +72,7 @@
  * @param value          The new label (UTF-8 format).
  */
 
-void TXT_SetRadioButtonLabel(txt_radiobutton_t *radiobutton, char *value);
+void TXT_SetRadioButtonLabel(txt_radiobutton_t *radiobutton, const char *value);
 
 #endif /* #ifndef TXT_RADIOBUTTON_H */
 
--- a/textscreen/txt_sdl.c
+++ b/textscreen/txt_sdl.c
@@ -34,7 +34,7 @@
 
 typedef struct
 {
-    char *name;
+    const char *name;
     const uint8_t *data;
     unsigned int w;
     unsigned int h;
@@ -133,7 +133,7 @@
 
 #endif
 
-static const txt_font_t *FontForName(char *name)
+static const txt_font_t *FontForName(const char *name)
 {
     int i;
     const txt_font_t *fonts[] =
@@ -518,7 +518,7 @@
     }
 }
 
-static int TranslateKeysym(SDL_Keysym *sym)
+static int TranslateKeysym(const SDL_Keysym *sym)
 {
     int translated;
 
@@ -558,7 +558,7 @@
 
 // Convert an SDL wheel motion to a textscreen button index.
 
-static int SDLWheelToTXTButton(SDL_MouseWheelEvent *wheel)
+static int SDLWheelToTXTButton(const SDL_MouseWheelEvent *wheel)
 {
     if (wheel->y <= 0)
     {
@@ -890,7 +890,7 @@
     input_mode = mode;
 }
 
-void TXT_SetWindowTitle(char *title)
+void TXT_SetWindowTitle(const char *title)
 {
     SDL_SetWindowTitle(TXT_SDLWindow, title);
 }
--- a/textscreen/txt_separator.c
+++ b/textscreen/txt_separator.c
@@ -73,7 +73,7 @@
     free(separator->label);
 }
 
-void TXT_SetSeparatorLabel(txt_separator_t *separator, char *label)
+void TXT_SetSeparatorLabel(txt_separator_t *separator, const char *label)
 {
     free(separator->label);
 
@@ -98,7 +98,7 @@
     NULL,
 };
 
-txt_separator_t *TXT_NewSeparator(char *label)
+txt_separator_t *TXT_NewSeparator(const char *label)
 {
     txt_separator_t *separator;
 
--- a/textscreen/txt_separator.h
+++ b/textscreen/txt_separator.h
@@ -50,7 +50,7 @@
  * @return              The new separator widget.
  */
 
-txt_separator_t *TXT_NewSeparator(char *label);
+txt_separator_t *TXT_NewSeparator(const char *label);
 
 /**
  * Change the label on a separator.
@@ -59,7 +59,7 @@
  * @param label         The new label (UTF-8 format).
  */
 
-void TXT_SetSeparatorLabel(txt_separator_t *separator, char *label);
+void TXT_SetSeparatorLabel(txt_separator_t *separator, const char *label);
 
 #endif /* #ifndef TXT_SEPARATOR_H */
 
--- a/textscreen/txt_window.c
+++ b/textscreen/txt_window.c
@@ -52,7 +52,7 @@
     }
 }
 
-txt_window_t *TXT_NewWindow(char *title)
+txt_window_t *TXT_NewWindow(const char *title)
 {
     int i;
 
@@ -508,7 +508,7 @@
     TXT_SetWidgetFocus(window, focused);
 }
 
-void TXT_SetWindowHelpURL(txt_window_t *window, char *help_url)
+void TXT_SetWindowHelpURL(txt_window_t *window, const char *help_url)
 {
     window->help_url = help_url;
 }
@@ -515,7 +515,7 @@
 
 #ifdef _WIN32
 
-void TXT_OpenURL(char *url)
+void TXT_OpenURL(const char *url)
 {
     ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
 }
@@ -522,7 +522,7 @@
 
 #else
 
-void TXT_OpenURL(char *url)
+void TXT_OpenURL(const char *url)
 {
     char *cmd;
     size_t cmd_len;
@@ -566,7 +566,7 @@
     }
 }
 
-txt_window_t *TXT_MessageBox(char *title, char *message, ...)
+txt_window_t *TXT_MessageBox(const char *title, const char *message, ...)
 {
     txt_window_t *window;
     char buf[256];
--- a/textscreen/txt_window.h
+++ b/textscreen/txt_window.h
@@ -88,7 +88,7 @@
 
     // URL of a webpage with help about this window. If set, a help key
     // indicator is shown while this window is active.
-    char *help_url;
+    const char *help_url;
 };
 
 /**
@@ -100,7 +100,7 @@
  *                     representing the new window.
  */
 
-txt_window_t *TXT_NewWindow(char *title);
+txt_window_t *TXT_NewWindow(const char *title);
 
 /**
  * Close a window.
@@ -197,7 +197,7 @@
  * @return                The new window.
  */
 
-txt_window_t *TXT_MessageBox(char *title, char *message, ...);
+txt_window_t *TXT_MessageBox(const char *title, const char *message, ...);
 
 /**
  * Set the help URL for the given window.
@@ -207,7 +207,7 @@
  *                        window, or NULL to set no help for this window.
  */
 
-void TXT_SetWindowHelpURL(txt_window_t *window, char *help_url);
+void TXT_SetWindowHelpURL(txt_window_t *window, const char *help_url);
 
 /**
  * Open the help URL for the given window, if one is set.