From a1753be2b21666440e247c62eee02e4d1f36bda8 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Fri, 15 Mar 2024 19:43:39 +0100 Subject: [PATCH] get rid of NormalizeSlashes() (#1593) --- src/d_main.c | 10 +--------- src/m_config.c | 3 --- src/m_misc.c | 47 ----------------------------------------------- src/m_misc.h | 1 - 4 files changed, 1 insertion(+), 60 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 5598bf3c..bf642fa2 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -764,14 +764,8 @@ static boolean D_AddZipFile(const char *file) void D_AddFile(const char *file) { - char *s = M_StringDuplicate(file); - - NormalizeSlashes(s); - // [FG] search for PWADs by their filename - char *path = D_TryFindWADByName(s); - - free(s); + char *path = D_TryFindWADByName(file); if (M_StringCaseEndsWith(path, ".kvx")) { @@ -2563,7 +2557,6 @@ void D_DoomMain(void) "savegames", NULL); free(oldsavegame); - NormalizeSlashes(basesavegame); M_MakeDirectory(basesavegame); oldsavegame = basesavegame; @@ -2571,7 +2564,6 @@ void D_DoomMain(void) M_BaseName(wadname), NULL); free(oldsavegame); - NormalizeSlashes(basesavegame); M_MakeDirectory(basesavegame); } } diff --git a/src/m_config.c b/src/m_config.c index 84d9592d..d3baa9ee 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -2906,7 +2906,6 @@ void M_SaveDefaults(void) tmpfile = M_StringJoin(D_DoomPrefDir(), DIR_SEPARATOR_S, "tmp", D_DoomExeName(), ".cfg", NULL); - NormalizeSlashes(tmpfile); errno = 0; if (!(f = M_fopen(tmpfile, "w"))) // killough 9/21/98 @@ -3383,8 +3382,6 @@ void M_LoadDefaults(void) } } - NormalizeSlashes(defaultfile); - // read the file in, overriding any set defaults // // killough 9/21/98: Print warning if file missing, and use fgets for diff --git a/src/m_misc.c b/src/m_misc.c index b46531e9..e4fbd952 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -497,53 +497,6 @@ char *AddDefaultExtension(char *path, const char *ext) return strcat(path, ext); } -// NormalizeSlashes -// -// Remove trailing slashes, translate backslashes to slashes -// The string to normalize is passed and returned in str -// -// killough 11/98: rewritten - -void 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; - } - -#if defined(_WIN32) - // Don't collapse leading slashes on Windows - if (*str == DIR_SEPARATOR) - { - str++; - } -#endif - - // Collapse multiple slashes - for (p = str; (*str++ = *p);) - { - if (*p++ == DIR_SEPARATOR) - { - while (*p == DIR_SEPARATOR) - { - p++; - } - } - } -} - // // M_WriteFile // diff --git a/src/m_misc.h b/src/m_misc.h index 725cba4f..8733ec57 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -45,7 +45,6 @@ int M_snprintf(char *buf, size_t buf_len, const char *s, ...) PRINTF_ATTR(3, 4); void M_CopyLumpName(char *dest, const char *src); char *AddDefaultExtension(char *path, const char *ext); -void NormalizeSlashes(char *str); boolean M_WriteFile(const char *name, void *source, int length); int M_ReadFile(const char *name, byte **buffer);