mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r22669) -Codechange: For non-windows, only test for file existence again if strtolower actually changed the name.
This commit is contained in:
parent
20c2b5fdde
commit
d55b380b69
|
@ -320,8 +320,7 @@ char *FioFindFullPath(char *buf, size_t buflen, Subdirectory subdir, const char
|
||||||
/* Be, as opening files, aware that sometimes the filename
|
/* Be, as opening files, aware that sometimes the filename
|
||||||
* might be in uppercase when it is in lowercase on the
|
* might be in uppercase when it is in lowercase on the
|
||||||
* disk. Ofcourse Windows doesn't care about casing. */
|
* disk. Ofcourse Windows doesn't care about casing. */
|
||||||
strtolower(buf + strlen(_searchpaths[sp]) - 1);
|
if (strtolower(buf + strlen(_searchpaths[sp]) - 1) && FileExists(buf)) return buf;
|
||||||
if (FileExists(buf)) return buf;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,8 +377,7 @@ static FILE *FioFOpenFileSp(const char *filename, const char *mode, Searchpath s
|
||||||
|
|
||||||
f = fopen(buf, mode);
|
f = fopen(buf, mode);
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
if (f == NULL) {
|
if (f == NULL && strtolower(buf + ((subdir == NO_DIRECTORY) ? 0 : strlen(_searchpaths[sp]) - 1))) {
|
||||||
strtolower(buf + ((subdir == NO_DIRECTORY) ? 0 : strlen(_searchpaths[sp]) - 1));
|
|
||||||
f = fopen(buf, mode);
|
f = fopen(buf, mode);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -319,10 +319,17 @@ size_t Utf8StringLength(const char *s)
|
||||||
* using certain locales: eg in Turkish the uppercase 'I' was converted to
|
* using certain locales: eg in Turkish the uppercase 'I' was converted to
|
||||||
* '?', so just revert to the old functionality
|
* '?', so just revert to the old functionality
|
||||||
* @param str string to convert
|
* @param str string to convert
|
||||||
|
* @return String has changed.
|
||||||
*/
|
*/
|
||||||
void strtolower(char *str)
|
bool strtolower(char *str)
|
||||||
{
|
{
|
||||||
for (; *str != '\0'; str++) *str = tolower(*str);
|
bool changed = false;
|
||||||
|
for (; *str != '\0'; str++) {
|
||||||
|
char new_str = tolower(*str);
|
||||||
|
changed |= new_str != *str;
|
||||||
|
*str = new_str;
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,7 +41,7 @@ char *CDECL str_fmt(const char *str, ...) WARN_FORMAT(1, 2);
|
||||||
|
|
||||||
void str_validate(char *str, const char *last, bool allow_newlines = false, bool ignore = false);
|
void str_validate(char *str, const char *last, bool allow_newlines = false, bool ignore = false);
|
||||||
void str_strip_colours(char *str);
|
void str_strip_colours(char *str);
|
||||||
void strtolower(char *str);
|
bool strtolower(char *str);
|
||||||
|
|
||||||
bool StrValid(const char *str, const char *last);
|
bool StrValid(const char *str, const char *last);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue