Codechange: introduce StrEqualsIgnoreCase/StrCompareIgnoreCase to replace strcasecmp
This commit is contained in:
@@ -1868,7 +1868,7 @@ static ContentType StringToContentType(const char *str)
|
||||
{
|
||||
static const char * const inv_lookup[] = { "", "base", "newgrf", "ai", "ailib", "scenario", "heightmap" };
|
||||
for (uint i = 1 /* there is no type 0 */; i < lengthof(inv_lookup); i++) {
|
||||
if (strcasecmp(str, inv_lookup[i]) == 0) return (ContentType)i;
|
||||
if (StrEqualsIgnoreCase(str, inv_lookup[i])) return (ContentType)i;
|
||||
}
|
||||
return CONTENT_TYPE_END;
|
||||
}
|
||||
@@ -1926,17 +1926,17 @@ DEF_CONSOLE_CMD(ConContent)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "update") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "update")) {
|
||||
_network_content_client.RequestContentList((argc > 2) ? StringToContentType(argv[2]) : CONTENT_TYPE_END);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "upgrade") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "upgrade")) {
|
||||
_network_content_client.SelectUpgrade();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "select") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "select")) {
|
||||
if (argc <= 2) {
|
||||
/* List selected content */
|
||||
IConsolePrint(CC_WHITE, "id, type, state, name");
|
||||
@@ -1944,7 +1944,7 @@ DEF_CONSOLE_CMD(ConContent)
|
||||
if ((*iter)->state != ContentInfo::SELECTED && (*iter)->state != ContentInfo::AUTOSELECTED) continue;
|
||||
OutputContentState(*iter);
|
||||
}
|
||||
} else if (strcasecmp(argv[2], "all") == 0) {
|
||||
} else if (StrEqualsIgnoreCase(argv[2], "all")) {
|
||||
/* The intention of this function was that you could download
|
||||
* everything after a filter was applied; but this never really
|
||||
* took off. Instead, a select few people used this functionality
|
||||
@@ -1958,12 +1958,12 @@ DEF_CONSOLE_CMD(ConContent)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "unselect") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "unselect")) {
|
||||
if (argc <= 2) {
|
||||
IConsolePrint(CC_ERROR, "You must enter the id.");
|
||||
return false;
|
||||
}
|
||||
if (strcasecmp(argv[2], "all") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[2], "all")) {
|
||||
_network_content_client.UnselectAll();
|
||||
} else {
|
||||
_network_content_client.Unselect((ContentID)atoi(argv[2]));
|
||||
@@ -1971,7 +1971,7 @@ DEF_CONSOLE_CMD(ConContent)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "state") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "state")) {
|
||||
IConsolePrint(CC_WHITE, "id, type, state, name");
|
||||
for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
|
||||
if (argc > 2 && strcasestr((*iter)->name.c_str(), argv[2]) == nullptr) continue;
|
||||
@@ -1980,7 +1980,7 @@ DEF_CONSOLE_CMD(ConContent)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "download") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "download")) {
|
||||
uint files;
|
||||
uint bytes;
|
||||
_network_content_client.DownloadSelectedContent(files, bytes);
|
||||
@@ -2007,7 +2007,7 @@ DEF_CONSOLE_CMD(ConFont)
|
||||
|
||||
FontSize argfs;
|
||||
for (argfs = FS_BEGIN; argfs < FS_END; argfs++) {
|
||||
if (argc > 1 && strcasecmp(argv[1], FontSizeToName(argfs)) == 0) break;
|
||||
if (argc > 1 && StrEqualsIgnoreCase(argv[1], FontSizeToName(argfs))) break;
|
||||
}
|
||||
|
||||
/* First argument must be a FontSize. */
|
||||
@@ -2021,7 +2021,7 @@ DEF_CONSOLE_CMD(ConFont)
|
||||
|
||||
byte arg_index = 2;
|
||||
/* We may encounter "aa" or "noaa" but it must be the last argument. */
|
||||
if (strcasecmp(argv[arg_index], "aa") == 0 || strcasecmp(argv[arg_index], "noaa") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[arg_index], "aa") || StrEqualsIgnoreCase(argv[arg_index], "noaa")) {
|
||||
aa = strncasecmp(argv[arg_index++], "no", 2) != 0;
|
||||
if (argc > arg_index) return false;
|
||||
} else {
|
||||
@@ -2043,7 +2043,7 @@ DEF_CONSOLE_CMD(ConFont)
|
||||
|
||||
if (argc > arg_index) {
|
||||
/* Last argument must be "aa" or "noaa". */
|
||||
if (strcasecmp(argv[arg_index], "aa") != 0 && strcasecmp(argv[arg_index], "noaa") != 0) return false;
|
||||
if (!StrEqualsIgnoreCase(argv[arg_index], "aa") && !StrEqualsIgnoreCase(argv[arg_index], "noaa")) return false;
|
||||
aa = strncasecmp(argv[arg_index++], "no", 2) != 0;
|
||||
if (argc > arg_index) return false;
|
||||
}
|
||||
@@ -2171,7 +2171,7 @@ DEF_CONSOLE_CMD(ConListDirs)
|
||||
|
||||
std::set<std::string> seen_dirs;
|
||||
for (const SubdirNameMap &sdn : subdir_name_map) {
|
||||
if (strcasecmp(argv[1], sdn.name) != 0) continue;
|
||||
if (!StrEqualsIgnoreCase(argv[1], sdn.name)) continue;
|
||||
bool found = false;
|
||||
for (Searchpath sp : _valid_searchpaths) {
|
||||
/* Get the directory */
|
||||
@@ -2256,7 +2256,7 @@ DEF_CONSOLE_CMD(ConNewGRFProfile)
|
||||
/* "unselect" sub-command */
|
||||
if (strncasecmp(argv[1], "uns", 3) == 0 && argc >= 3) {
|
||||
for (size_t argnum = 2; argnum < argc; ++argnum) {
|
||||
if (strcasecmp(argv[argnum], "all") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[argnum], "all")) {
|
||||
_newgrf_profilers.clear();
|
||||
break;
|
||||
}
|
||||
@@ -2501,17 +2501,17 @@ DEF_CONSOLE_CMD(ConDumpInfo)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "roadtypes") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "roadtypes")) {
|
||||
ConDumpRoadTypes();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "railtypes") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "railtypes")) {
|
||||
ConDumpRailTypes();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "cargotypes") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "cargotypes")) {
|
||||
ConDumpCargoTypes();
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user