shithub: choc

Download patch

ref: 63df9283035b7f221dcef0cd5d1e488da3af12b6
parent: 4ee95eb27f4a71f78450d492a62e5abcd881c5c4
author: Simon Howard <fraggle@soulsphere.org>
date: Fri May 1 19:23:03 EDT 2015

Perform case-insensitive check for .lmp extension.

When using the -playdemo parameter, we support a convenience feature
where the .lmp extension is not appended if it is already part of the
filename. This makes tab completion much nicer. But if the .lmp file
has a filename that is in all-caps (.LMP) we were still appending the
extension because the check was case sensitive. Change the check to
be case insensitive.

This fixes #501 (thanks Ioan Chera).

--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -1475,9 +1475,12 @@
 
     if (p)
     {
+        char *uc_filename = strdup(myargv[p + 1]);
+        M_ForceUppercase(uc_filename);
+
         // With Vanilla you have to specify the file without extension,
         // but make that optional.
-        if (M_StringEndsWith(myargv[p + 1], ".lmp"))
+        if (M_StringEndsWith(uc_filename, ".LMP"))
         {
             M_StringCopy(file, myargv[p + 1], sizeof(file));
         }
@@ -1485,6 +1488,8 @@
         {
             DEH_snprintf(file, sizeof(file), "%s.lmp", myargv[p+1]);
         }
+
+        free(uc_filename);
 
         if (D_AddFile(file))
         {
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -1001,9 +1001,12 @@
 
     if (p)
     {
+        char *uc_filename = strdup(myargv[p + 1]);
+        M_ForceUppercase(uc_filename);
+
         // In Vanilla, the filename must be specified without .lmp,
         // but make that optional.
-        if (M_StringEndsWith(myargv[p + 1], ".lmp"))
+        if (M_StringEndsWith(uc_filename, ".LMP"))
         {
             M_StringCopy(file, myargv[p + 1], sizeof(file));
         }
@@ -1011,6 +1014,8 @@
         {
             DEH_snprintf(file, sizeof(file), "%s.lmp", myargv[p + 1]);
         }
+
+        free(uc_filename);
 
         if (D_AddFile(file))
         {
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -623,6 +623,7 @@
 
     if (p)
     {
+        char *uc_filename;
         char file[256];
 
         M_StringCopy(file, myargv[p+1], sizeof(file));
@@ -629,10 +630,15 @@
 
         // With Vanilla Hexen you have to specify the file without
         // extension, but make that optional.
-        if (!M_StringEndsWith(myargv[p+1], ".lmp"))
+        uc_filename = strdup(myargv[p + 1]);
+        M_ForceUppercase(uc_filename);
+
+        if (!M_StringEndsWith(uc_filename, ".LMP"))
         {
             M_StringConcat(file, ".lmp", sizeof(file));
         }
+
+        free(uc_filename);
 
         if (W_AddFile(file) != NULL)
         {
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -1611,9 +1611,12 @@
 
     if (p)
     {
+        char *uc_filename = strdup(myargv[p + 1]);
+        M_ForceUppercase(uc_filename);
+
         // With Vanilla you have to specify the file without extension,
         // but make that optional.
-        if (M_StringEndsWith(myargv[p + 1], ".lmp"))
+        if (M_StringEndsWith(uc_filename, ".LMP"))
         {
             M_StringCopy(file, myargv[p + 1], sizeof(file));
         }
@@ -1621,6 +1624,8 @@
         {
             DEH_snprintf(file, sizeof(file), "%s.lmp", myargv[p+1]);
         }
+
+        free(uc_filename);
 
         if (D_AddFile (file))
         {