summaryrefslogtreecommitdiff
path: root/fileio.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-07-31 22:11:34 +0000
committerDarkvater <darkvater@openttd.org>2006-07-31 22:11:34 +0000
commitcef563141a3f1bfe8d8f2bf5211598df57e4ec0f (patch)
tree324b4fc0d30866882b6415c8accf29bf57ca9be6 /fileio.c
parent17dc89880501bcd0fc341db033596cfd066d4eaf (diff)
downloadopenttd-cef563141a3f1bfe8d8f2bf5211598df57e4ec0f.tar.xz
(svn r5684) - Codechange: create an strtolower() function that uses tolower() on a whole string and apply it in the places this was used.
Diffstat (limited to 'fileio.c')
-rw-r--r--fileio.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/fileio.c b/fileio.c
index 338c7f50a..4d2e800cc 100644
--- a/fileio.c
+++ b/fileio.c
@@ -4,11 +4,9 @@
#include "openttd.h"
#include "fileio.h"
#include "functions.h"
+#include "string.h"
#include "macros.h"
#include "variables.h"
-#if defined(UNIX) || defined(__OS2__)
-#include <ctype.h> // required for tolower()
-#endif
/*************************************************/
/* FILE IO ROUTINES ******************************/
@@ -114,20 +112,16 @@ bool FiosCheckFileExists(const char *filename)
f = fopen(buf, "rb");
#if !defined(WIN32)
- if (f == NULL) {
- char *s;
- // Make lower case and try again
- for (s = buf + strlen(_path.data_dir) - 1; *s != 0; s++)
- *s = tolower(*s);
+ if (f == NULL) { // Make lower case and try again
+ strtolower(buf + strlen(_path.data_dir) - 1);
f = fopen(buf, "rb");
#if defined SECOND_DATA_DIR
- // tries in the 2nd data directory
+ // tries in the 2nd data directory
if (f == NULL) {
sprintf(buf, "%s%s", _path.second_data_dir, filename);
- for (s = buf + strlen(_path.second_data_dir) - 1; *s != 0; s++)
- *s = tolower(*s);
- f = fopen(buf, "rb");
+ strtolower(buf + strlen(_path.second_data_dir) - 1);
+ f = fopen(buf, "rb");
}
#endif
}
@@ -151,18 +145,14 @@ FILE *FioFOpenFile(const char *filename)
f = fopen(buf, "rb");
#if !defined(WIN32)
if (f == NULL) {
- char *s;
- // Make lower case and try again
- for (s = buf + strlen(_path.data_dir) - 1; *s != 0; s++)
- *s = tolower(*s);
+ strtolower(buf + strlen(_path.data_dir) - 1);
f = fopen(buf, "rb");
#if defined SECOND_DATA_DIR
// tries in the 2nd data directory
if (f == NULL) {
sprintf(buf, "%s%s", _path.second_data_dir, filename);
- for (s = buf + strlen(_path.second_data_dir) - 1; *s != 0; s++)
- *s = tolower(*s);
+ strtolower(buf + strlen(_path.second_data_dir) - 1);
f = fopen(buf, "rb");
}
#endif
@@ -182,19 +172,15 @@ void FioOpenFile(int slot, const char *filename)
f = fopen(buf, "rb");
#if !defined(WIN32)
if (f == NULL) {
- char *s;
- // Make lower case and try again
- for (s = buf + strlen(_path.data_dir) - 1; *s != 0; s++)
- *s = tolower(*s);
+ strtolower(buf + strlen(_path.data_dir) - 1);
f = fopen(buf, "rb");
#if defined SECOND_DATA_DIR
// tries in the 2nd data directory
if (f == NULL) {
sprintf(buf, "%s%s", _path.second_data_dir, filename);
- for (s = buf + strlen(_path.second_data_dir) - 1; *s != 0; s++)
- *s = tolower(*s);
- f = fopen(buf, "rb");
+ strtolower(buf + strlen(_path.second_data_dir) - 1);
+ f = fopen(buf, "rb");
}
if (f == NULL)