diff options
author | peter1138 <peter1138@openttd.org> | 2008-04-23 11:57:58 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2008-04-23 11:57:58 +0000 |
commit | fff763b5ce3a2f15d4a49ae5d7dc5edb0cf195dd (patch) | |
tree | a351dda0036b304815eded76c0444e5588b4030a /src | |
parent | 39a715f1f339b388fae891c7b9180ddf66f59e16 (diff) | |
download | openttd-fff763b5ce3a2f15d4a49ae5d7dc5edb0cf195dd.tar.xz |
(svn r12847) -Cleanup: Identing and variable scope
Diffstat (limited to 'src')
-rw-r--r-- | src/fios.cpp | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/fios.cpp b/src/fios.cpp index b34939f32..f48ed1dcc 100644 --- a/src/fios.cpp +++ b/src/fios.cpp @@ -108,50 +108,50 @@ StringID FiosGetDescText(const char **path, uint32 *total_free) * @return a string if we have given a file as a target, otherwise NULL */ char *FiosBrowseTo(const FiosItem *item) { - char *s; char *path = _fios_path; switch (item->type) { #if defined(WINCE) - case FIOS_TYPE_DRIVE: sprintf(path, PATHSEP ""); break; + case FIOS_TYPE_DRIVE: sprintf(path, PATHSEP ""); break; #elif defined(WIN32) || defined(__OS2__) - case FIOS_TYPE_DRIVE: sprintf(path, "%c:" PATHSEP, item->title[0]); break; + case FIOS_TYPE_DRIVE: sprintf(path, "%c:" PATHSEP, item->title[0]); break; #endif - case FIOS_TYPE_PARENT: - /* Check for possible NULL ptr (not required for UNIXes, but AmigaOS-alikes) */ - s = strrchr(path, PATHSEPCHAR); - if (s != NULL && s != path) { - s[0] = '\0'; // Remove last path separator character, so we can go up one level. - } - s = strrchr(path, PATHSEPCHAR); - if (s != NULL) s[1] = '\0'; // go up a directory + case FIOS_TYPE_PARENT: { + /* Check for possible NULL ptr (not required for UNIXes, but AmigaOS-alikes) */ + char *s = strrchr(path, PATHSEPCHAR); + if (s != NULL && s != path) { + s[0] = '\0'; // Remove last path separator character, so we can go up one level. + } + s = strrchr(path, PATHSEPCHAR); + if (s != NULL) s[1] = '\0'; // go up a directory #if defined(__MORPHOS__) || defined(__AMIGAOS__) - /* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */ - else if ((s = strrchr(path, ':')) != NULL) s[1] = '\0'; + /* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */ + else if ((s = strrchr(path, ':')) != NULL) s[1] = '\0'; #endif - break; - - case FIOS_TYPE_DIR: - strcat(path, item->name); - strcat(path, PATHSEP); - break; - - case FIOS_TYPE_DIRECT: - sprintf(path, "%s", item->name); - break; - - case FIOS_TYPE_FILE: - case FIOS_TYPE_OLDFILE: - case FIOS_TYPE_SCENARIO: - case FIOS_TYPE_OLD_SCENARIO: - case FIOS_TYPE_PNG: - case FIOS_TYPE_BMP: - { - static char str_buffr[512]; - snprintf(str_buffr, lengthof(str_buffr), "%s%s", path, item->name); - return str_buffr; - } + break; + } + + case FIOS_TYPE_DIR: + strcat(path, item->name); + strcat(path, PATHSEP); + break; + + case FIOS_TYPE_DIRECT: + sprintf(path, "%s", item->name); + break; + + case FIOS_TYPE_FILE: + case FIOS_TYPE_OLDFILE: + case FIOS_TYPE_SCENARIO: + case FIOS_TYPE_OLD_SCENARIO: + case FIOS_TYPE_PNG: + case FIOS_TYPE_BMP: + { + static char str_buffr[512]; + snprintf(str_buffr, lengthof(str_buffr), "%s%s", path, item->name); + return str_buffr; + } } return NULL; |