From 8c2f676ff5f77fe4e89c783b04d7dc23f55cc6ed Mon Sep 17 00:00:00 2001 From: dark-ether Date: Wed, 20 Jul 2022 16:41:09 -0300 Subject: [PATCH 26/26] Change all occurences of strcasecmp() to fc_strcasecomp() Modified by Marko Lindqvist See osdn #45034 --- client/client_main.c | 6 +++--- common/ai.c | 2 +- dependencies/cvercmp/Makefile.am | 2 ++ dependencies/cvercmp/README.cvercmp | 3 ++- dependencies/cvercmp/cvercmp.c | 9 ++++++--- server/civserver.c | 6 +++--- server/savegame/savecompat.c | 4 ++-- server/savegame/savegame2.c | 6 +++--- tools/ruledit/effect_edit.cpp | 2 +- 9 files changed, 23 insertions(+), 17 deletions(-) diff --git a/client/client_main.c b/client/client_main.c index c2c2cb1942..b1cd561d52 100644 --- a/client/client_main.c +++ b/client/client_main.c @@ -557,12 +557,12 @@ int client_main(int argc, char *argv[], bool postpone_tileset) sz_strlcpy(forced_tileset_name, option); free(option); } else if ((option = get_option_malloc("--Announce", argv, &i, argc, FALSE))) { - if (!strcasecmp(option, "ipv4")) { + if (!fc_strcasecmp(option, "ipv4")) { announce = ANNOUNCE_IPV4; - } else if (!strcasecmp(option, "none")) { + } else if (!fc_strcasecmp(option, "none")) { announce = ANNOUNCE_NONE; #ifdef FREECIV_IPV6_SUPPORT - } else if (!strcasecmp(option, "ipv6")) { + } else if (!fc_strcasecmp(option, "ipv6")) { announce = ANNOUNCE_IPV6; #endif /* IPv6 support */ } else { diff --git a/common/ai.c b/common/ai.c index 3eee2ad5b3..5c8fe79e70 100644 --- a/common/ai.c +++ b/common/ai.c @@ -369,7 +369,7 @@ const char *ai_level_name_update_cb(const char *old) { #ifndef FREECIV_DEBUG /* No experimental level in !FREECIV_DEBUG build */ - if (!strcasecmp("Experimental", old)) { + if (!fc_strcasecmp("Experimental", old)) { /* Convert it to hard */ return ai_level_name(AI_LEVEL_HARD); } diff --git a/dependencies/cvercmp/Makefile.am b/dependencies/cvercmp/Makefile.am index 3472a133f9..2705241e56 100644 --- a/dependencies/cvercmp/Makefile.am +++ b/dependencies/cvercmp/Makefile.am @@ -10,6 +10,8 @@ noinst_LTLIBRARIES = libcvercmp.la +AM_CPPFLAGS = -I$(top_srcdir)/utility + libcvercmp_la_SOURCES = \ cvercmp.c \ cvercmp.h diff --git a/dependencies/cvercmp/README.cvercmp b/dependencies/cvercmp/README.cvercmp index 6026a32569..b9bb4c76b8 100644 --- a/dependencies/cvercmp/README.cvercmp +++ b/dependencies/cvercmp/README.cvercmp @@ -6,4 +6,5 @@ As the copyright holder, cazfi has granted freeciv project right to use the provided version under GPLv2+. Freeciv's current version is about the same as upstream release 1.0.4, -with some later modifications. +with some backports and other modifications, including: +- fc_strcasecmp() used instead of strcasecmp() diff --git a/dependencies/cvercmp/cvercmp.c b/dependencies/cvercmp/cvercmp.c index f2d5d6912a..fee3bc7590 100644 --- a/dependencies/cvercmp/cvercmp.c +++ b/dependencies/cvercmp/cvercmp.c @@ -18,6 +18,9 @@ #include #include +/* utility */ +#include "support.h" + #include "cvercmp.h" static char **cvercmp_ver_tokenize(const char *ver); @@ -134,7 +137,7 @@ static enum cvercmp_type cvercmp_tokens(const char *token1, const char *token2) solution = true; } } else { - int alphacmp = strcasecmp(t1[i], t2[i]); + int alphacmp = fc_strcasecmp(t1[i], t2[i]); if (alphacmp) { enum cvercmp_prever pre1 = cvercmp_parse_prever(t1[i]); @@ -200,7 +203,7 @@ enum cvercmp_type cvercmp_cmp(const char *ver1, const char *ver2) char **tokens2 = cvercmp_ver_tokenize(ver2); for (i = 0; (tokens1[i] != NULL && tokens2[i] != NULL) && !solution; i++) { - if (strcasecmp(tokens1[i], tokens2[i])) { + if (fc_strcasecmp(tokens1[i], tokens2[i])) { /* Parts are not equal */ result = cvercmp_tokens(tokens1[i], tokens2[i]); solution = true; @@ -323,7 +326,7 @@ static enum cvercmp_prever cvercmp_parse_prever(const char *ver) int i; for (i = 0; preverstrs[i].str != NULL; i++) { - if (!strcasecmp(ver, preverstrs[i].str)) { + if (!fc_strcasecmp(ver, preverstrs[i].str)) { return preverstrs[i].prever; } } diff --git a/server/civserver.c b/server/civserver.c index 1f9dd78619..f879e0e5a4 100644 --- a/server/civserver.c +++ b/server/civserver.c @@ -298,12 +298,12 @@ int main(int argc, char *argv[]) } else if (is_option("--version", argv[inx])) { showvers = TRUE; } else if ((option = get_option_malloc("--Announce", argv, &inx, argc, FALSE))) { - if (!strcasecmp(option, "ipv4")) { + if (!fc_strcasecmp(option, "ipv4")) { srvarg.announce = ANNOUNCE_IPV4; - } else if (!strcasecmp(option, "none")) { + } else if (!fc_strcasecmp(option, "none")) { srvarg.announce = ANNOUNCE_NONE; #ifdef FREECIV_IPV6_SUPPORT - } else if (!strcasecmp(option, "ipv6")) { + } else if (!fc_strcasecmp(option, "ipv6")) { srvarg.announce = ANNOUNCE_IPV6; #endif /* IPv6 support */ } else { diff --git a/server/savegame/savecompat.c b/server/savegame/savecompat.c index 29948a2d62..94ff0e2788 100644 --- a/server/savegame/savecompat.c +++ b/server/savegame/savecompat.c @@ -1580,7 +1580,7 @@ static void compat_load_030100(struct loaddata *loading, savemod = fc_calloc(action_count, sizeof(*savemod)); for (j = 0; j < action_count; j++) { - if (!strcasecmp("Recycle Unit", modname[j])) { + if (!fc_strcasecmp("Recycle Unit", modname[j])) { savemod[j] = dur_name; } else { savemod[j] = modname[j]; @@ -2211,7 +2211,7 @@ static void compat_load_dev(struct loaddata *loading) savemod = fc_calloc(action_count, sizeof(*savemod)); for (j = 0; j < action_count; j++) { - if (!strcasecmp("Recycle Unit", modname[j])) { + if (!fc_strcasecmp("Recycle Unit", modname[j])) { savemod[j] = dur_name; } else { savemod[j] = modname[j]; diff --git a/server/savegame/savegame2.c b/server/savegame/savegame2.c index 7efdab9d17..d31c017d43 100644 --- a/server/savegame/savegame2.c +++ b/server/savegame/savegame2.c @@ -1312,11 +1312,11 @@ static void sg_load_savefile(struct loaddata *loading) loading->special.order = fc_calloc(nmod, sizeof(*loading->special.order)); for (j = 0; j < loading->special.size; j++) { - if (!strcasecmp("Road", modname[j])) { + if (!fc_strcasecmp("Road", modname[j])) { loading->special.order[j] = S_OLD_ROAD; - } else if (!strcasecmp("Railroad", modname[j])) { + } else if (!fc_strcasecmp("Railroad", modname[j])) { loading->special.order[j] = S_OLD_RAILROAD; - } else if (!strcasecmp("River", modname[j])) { + } else if (!fc_strcasecmp("River", modname[j])) { loading->special.order[j] = S_OLD_RIVER; } else { loading->special.order[j] = special_by_rule_name(modname[j]); diff --git a/tools/ruledit/effect_edit.cpp b/tools/ruledit/effect_edit.cpp index 57e3cce30e..e727bfa520 100644 --- a/tools/ruledit/effect_edit.cpp +++ b/tools/ruledit/effect_edit.cpp @@ -359,7 +359,7 @@ void effect_edit::multiplier_menu(QAction *action) return; } - if (!strcasecmp(NO_MULTIPLIER_NAME, an_bytes)) { + if (!fc_strcasecmp(NO_MULTIPLIER_NAME, an_bytes)) { selected->multiplier = NULL; } else { selected->multiplier = multiplier_by_rule_name(an_bytes); -- 2.35.1