shithub: choc

Download patch

ref: bb9207f9fad7b1ec72860a240454a46042f29f89
parent: 293b22549c00c996f3c88e00365c78a4ad980b64
author: mfrancis95 <[email protected]>
date: Sat Jun 27 09:55:11 EDT 2020

Move M_NormalizeSlashes from strife/m_saves to m_misc

--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -661,3 +661,36 @@
 
 #endif
 
+//
+// M_NormalizeSlashes
+//
+// Remove trailing slashes, translate backslashes to slashes
+// The string to normalize is passed and returned in str
+//
+// killough 11/98: rewritten
+//
+// [STRIFE] - haleyjd 20110210: Borrowed from Eternity and adapted to respect
+// the DIR_SEPARATOR define used by Choco Doom. This routine originated in
+// BOOM.
+//
+void M_NormalizeSlashes(char *str)
+{
+    char *p;
+
+    // Convert all slashes/backslashes to DIR_SEPARATOR
+    for(p = str; *p; p++)
+    {
+        if((*p == '/' || *p == '\\') && *p != DIR_SEPARATOR)
+            *p = DIR_SEPARATOR;
+    }
+
+    // Remove trailing slashes
+    while(p > str && *--p == DIR_SEPARATOR)
+        *p = 0;
+
+    // Collapse multiple slashes
+    for(p = str; (*str++ = *p); )
+        if(*p++ == DIR_SEPARATOR)
+            while(*p == DIR_SEPARATOR)
+                p++;
+}
\ No newline at end of file
--- a/src/m_misc.h
+++ b/src/m_misc.h
@@ -50,6 +50,7 @@
 int M_vsnprintf(char *buf, size_t buf_len, const char *s, va_list args);
 int M_snprintf(char *buf, size_t buf_len, const char *s, ...) PRINTF_ATTR(3, 4);
 char *M_OEMToUTF8(const char *ansi);
+void M_NormalizeSlashes(char *str);
 
 #endif
 
--- a/src/strife/m_saves.c
+++ b/src/strife/m_saves.c
@@ -362,40 +362,6 @@
 }
 
 //
-// M_NormalizeSlashes
-//
-// Remove trailing slashes, translate backslashes to slashes
-// The string to normalize is passed and returned in str
-//
-// killough 11/98: rewritten
-//
-// [STRIFE] - haleyjd 20110210: Borrowed from Eternity and adapted to respect 
-// the DIR_SEPARATOR define used by Choco Doom. This routine originated in
-// BOOM.
-//
-void M_NormalizeSlashes(char *str)
-{
-    char *p;
-   
-    // Convert all slashes/backslashes to DIR_SEPARATOR
-    for(p = str; *p; p++)
-    {
-        if((*p == '/' || *p == '\\') && *p != DIR_SEPARATOR)
-            *p = DIR_SEPARATOR;
-    }
-
-    // Remove trailing slashes
-    while(p > str && *--p == DIR_SEPARATOR)
-        *p = 0;
-
-    // Collapse multiple slashes
-    for(p = str; (*str++ = *p); )
-        if(*p++ == DIR_SEPARATOR)
-            while(*p == DIR_SEPARATOR)
-                p++;
-}
-
-//
 // M_SafeFilePath
 //
 // haleyjd 20110210 - original routine.
--- a/src/strife/m_saves.h
+++ b/src/strife/m_saves.h
@@ -42,7 +42,6 @@
 
 // Custom Utilities for Filepath Handling
 void *M_Calloc(size_t n1, size_t n2);
-void  M_NormalizeSlashes(char *str);
 int   M_StringAlloc(char **str, int numstrs, size_t extra, const char *str1, ...);
 char *M_SafeFilePath(const char *basepath, const char *newcomponent);
 char  M_GetFilePath(const char *fn, char *dest, size_t len);