From 088804995aa600392779555f9254d83269b2f7cb Mon Sep 17 00:00:00 2001 From: dark-ether Date: Wed, 20 Jul 2022 16:41:09 -0300 Subject: [PATCH 28/28] Change all occurences of strcasecmp() to fc_strcasecomp() Modified by Marko Lindqvist See osdn #45034 --- client/client_main.c | 6 +++--- dependencies/cvercmp/Makefile.am | 2 ++ dependencies/cvercmp/README.cvercmp | 3 ++- dependencies/cvercmp/cvercmp.c | 9 ++++++--- server/civserver.c | 6 +++--- server/legacysave.c | 10 +++++----- server/savegame2.c | 6 +++--- 7 files changed, 24 insertions(+), 18 deletions(-) diff --git a/client/client_main.c b/client/client_main.c index 283933aad4..792b0e34d0 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/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 83d1af28e8..565542965f 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/legacysave.c b/server/legacysave.c index b23b51f5ae..d7f89337b7 100644 --- a/server/legacysave.c +++ b/server/legacysave.c @@ -3286,15 +3286,15 @@ static void game_load_internal(struct section_file *file) nmod = num_special_types + (4 - (num_special_types % 4)); special_order = fc_calloc(nmod, sizeof(*special_order)); for (j = 0; j < num_special_types; j++) { - if (!strcasecmp("Road", modname[j])) { + if (!fc_strcasecmp("Road", modname[j])) { special_order[j] = S_OLD_ROAD; - } else if (!strcasecmp("Railroad", modname[j])) { + } else if (!fc_strcasecmp("Railroad", modname[j])) { special_order[j] = S_OLD_RAILROAD; - } else if (!strcasecmp("River", modname[j])) { + } else if (!fc_strcasecmp("River", modname[j])) { special_order[j] = S_OLD_RIVER; - } else if (!strcasecmp("Fortress", modname[j])) { + } else if (!fc_strcasecmp("Fortress", modname[j])) { special_order[j] = S_OLD_FORTRESS; - } else if (!strcasecmp("Airbase", modname[j])) { + } else if (!fc_strcasecmp("Airbase", modname[j])) { special_order[j] = S_OLD_AIRBASE; } else { special_order[j] = special_by_rule_name(modname[j]); diff --git a/server/savegame2.c b/server/savegame2.c index 8ff782035a..1afdb79978 100644 --- a/server/savegame2.c +++ b/server/savegame2.c @@ -1301,11 +1301,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]); -- 2.35.1