Add helper functions to get last path segment

This commit is contained in:
Jonathan G Rennison
2024-01-05 22:13:17 +00:00
parent 7fdcbced09
commit 0ab4b8ea31
5 changed files with 22 additions and 15 deletions

View File

@@ -2268,7 +2268,7 @@ bool ReadLanguagePack(const LanguageMetadata *lang)
_current_language = lang;
const TextDirection old_text_dir = _current_text_dir;
_current_text_dir = (TextDirection)_current_language->text_dir;
const char *c_file = strrchr(_current_language->file, PATHSEPCHAR) + 1;
const char *c_file = StrLastPathSegment(_current_language->file);
_config_language_file = c_file;
SetCurrentGrfLangID(_current_language->newgrflangid);
@@ -2444,7 +2444,7 @@ void InitializeLanguagePacks()
/* We are trying to find a default language. The priority is by
* configuration file, local environment and last, if nothing found,
* English. */
const char *lang_file = strrchr(lng.file, PATHSEPCHAR) + 1;
const char *lang_file = StrLastPathSegment(lng.file);
if (_config_language_file == lang_file) {
chosen_language = &lng;
break;