get rid of NormalizeSlashes() (#1593)

This commit is contained in:
Fabian Greffrath 2024-03-15 19:43:39 +01:00 committed by GitHub
parent 1dcef22726
commit a1753be2b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 1 additions and 60 deletions

View File

@ -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);
}
}

View File

@ -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

View File

@ -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
//

View File

@ -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);