diff options
-rw-r--r-- | src/externs.h | 5 | ||||
-rw-r--r-- | src/h-config.h | 18 | ||||
-rw-r--r-- | src/init1.cc | 20 | ||||
-rw-r--r-- | src/skills.cc | 4 | ||||
-rw-r--r-- | src/util.cc | 75 | ||||
-rw-r--r-- | src/xtra2.cc | 8 |
6 files changed, 30 insertions, 100 deletions
diff --git a/src/externs.h b/src/externs.h index 135fe073..93120286 100644 --- a/src/externs.h +++ b/src/externs.h @@ -2178,11 +2178,6 @@ extern void automatizer_load(cptr file_name); extern void user_name(char *buf, int id); #endif -#ifndef HAS_STRICMP -/* util.c */ -extern int stricmp(cptr a, cptr b); -#endif - #ifndef HAS_USLEEP /* util.c */ extern int usleep(huge usecs); diff --git a/src/h-config.h b/src/h-config.h index a6462b36..aa323e72 100644 --- a/src/h-config.h +++ b/src/h-config.h @@ -105,24 +105,6 @@ extern "C" { /* - * OPTION: Define "HAS_STRICMP" only if "stricmp()" exists. - * Note that "stricmp()" is not actually used by Angband. - */ -/* #define HAS_STRICMP */ - -/* - * Linux has "stricmp()" with a different name - */ -/* -#if defined(linux) -# define HAS_STRICMP -# define stricmp strcasecmp -#endif -*/ - - - -/* * OPTION: Define "HAS_USLEEP" only if "usleep()" exists. * Note that this is only relevant for "SET_UID" machines */ diff --git a/src/init1.cc b/src/init1.cc index 7730467a..8dd0fa62 100644 --- a/src/init1.cc +++ b/src/init1.cc @@ -4,6 +4,10 @@ #include "angband.h" +#include <boost/algorithm/string/predicate.hpp> + +using boost::algorithm::iequals; + /* * This file is used to initialize various variables and arrays for the @@ -2049,7 +2053,7 @@ errr init_player_info_txt(FILE *fp, char *buf) /* Find it in the list */ for (i = 0; i < POWER_MAX; i++) { - if (!stricmp(s, powers_type[i].name)) break; + if (iequals(s, powers_type[i].name)) break; } if (i == POWER_MAX) return (6); @@ -2427,7 +2431,7 @@ errr init_player_info_txt(FILE *fp, char *buf) /* Find it in the list */ for (i = 0; i < POWER_MAX; i++) { - if (!stricmp(s, powers_type[i].name)) break; + if (iequals(s, powers_type[i].name)) break; } if (i == POWER_MAX) return (6); @@ -2950,7 +2954,7 @@ errr init_player_info_txt(FILE *fp, char *buf) /* Find it in the list */ for (i = 0; i < POWER_MAX; i++) { - if (!stricmp(s, powers_type[i].name)) break; + if (iequals(s, powers_type[i].name)) break; } if (i == POWER_MAX) return (6); @@ -3373,7 +3377,7 @@ errr init_player_info_txt(FILE *fp, char *buf) /* Find it in the list */ for (i = 0; i < max_c_idx; i++) { - if (!stricmp(s, class_info[i].title + c_name)) break; + if (iequals(s, class_info[i].title + c_name)) break; } if (i == max_c_idx) return (6); @@ -4354,7 +4358,7 @@ errr init_k_info_txt(FILE *fp, char *buf) /* Find it in the list */ for (i = 0; i < POWER_MAX; i++) { - if (!stricmp(s, powers_type[i].name)) break; + if (iequals(s, powers_type[i].name)) break; } if (i == POWER_MAX) return (6); @@ -5247,7 +5251,7 @@ errr init_a_info_txt(FILE *fp, char *buf) /* Find it in the list */ for (i = 0; i < POWER_MAX; i++) { - if (!stricmp(s, powers_type[i].name)) break; + if (iequals(s, powers_type[i].name)) break; } if (i == POWER_MAX) return (6); @@ -6782,7 +6786,7 @@ errr init_e_info_txt(FILE *fp, char *buf) /* Find it in the list */ for (i = 0; i < POWER_MAX; i++) { - if (!stricmp(s, powers_type[i].name)) break; + if (iequals(s, powers_type[i].name)) break; } if (i == POWER_MAX) return (6); @@ -7271,7 +7275,7 @@ errr init_ra_info_txt(FILE *fp, char *buf) /* Find it in the list */ for (i = 0; i < POWER_MAX; i++) { - if (!stricmp(s, powers_type[i].name)) break; + if (iequals(s, powers_type[i].name)) break; } if (i == POWER_MAX) return (6); diff --git a/src/skills.cc b/src/skills.cc index 27741dc5..12c1fb3d 100644 --- a/src/skills.cc +++ b/src/skills.cc @@ -16,12 +16,14 @@ #include "util.hpp" #include <algorithm> +#include <boost/algorithm/string/predicate.hpp> #include <cassert> #include <cmath> #include <memory> #include <vector> #include <tuple> +using boost::algorithm::iequals; /* * Advance the skill point of the skill specified by i and @@ -119,7 +121,7 @@ s16b find_skill_i(cptr name) { /* The name matches */ if (s_info[i].name > 0) { - if (0 == stricmp(s_info[i].name + s_name, name)) return (i); + if (iequals(s_info[i].name + s_name, name)) return (i); } } diff --git a/src/util.cc b/src/util.cc index 9d65ee38..13a19ba2 100644 --- a/src/util.cc +++ b/src/util.cc @@ -7,31 +7,9 @@ #include "messages.h" #include "quark.h" +#include <boost/algorithm/string/predicate.hpp> -#ifndef HAS_STRICMP - -/* -* For those systems that don't have "stricmp()" -* -* Compare the two strings "a" and "b" ala "strcmp()" ignoring case. -*/ -int stricmp(cptr a, cptr b) -{ - cptr s1, s2; - char z1, z2; - - /* Scan the strings */ - for (s1 = a, s2 = b; TRUE; s1++, s2++) - { - z1 = FORCEUPPER(*s1); - z2 = FORCEUPPER(*s2); - if (z1 < z2) return ( -1); - if (z1 > z2) return (1); - if (!z1) return (0); - } -} - -#endif +using boost::algorithm::iequals; #ifdef SET_UID @@ -758,40 +736,6 @@ static int dehex(char c) } -static int my_stricmp(cptr a, cptr b) -{ - cptr s1, s2; - char z1, z2; - - /* Scan the strings */ - for (s1 = a, s2 = b; TRUE; s1++, s2++) - { - z1 = FORCEUPPER(*s1); - z2 = FORCEUPPER(*s2); - if (z1 < z2) return ( -1); - if (z1 > z2) return (1); - if (!z1) return (0); - } -} - -static int my_strnicmp(cptr a, cptr b, int n) -{ - cptr s1, s2; - char z1, z2; - - /* Scan the strings */ - for (s1 = a, s2 = b; n > 0; s1++, s2++, n--) - { - z1 = FORCEUPPER(*s1); - z2 = FORCEUPPER(*s2); - if (z1 < z2) return ( -1); - if (z1 > z2) return (1); - if (!z1) return (0); - } - return 0; -} - - static void trigger_text_to_ascii(char **bufptr, cptr *strptr) { char *s = *bufptr; @@ -815,8 +759,7 @@ static void trigger_text_to_ascii(char **bufptr, cptr *strptr) for (i = 0; macro_modifier_chr[i]; i++) { len = strlen(macro_modifier_name[i]); - - if (!my_strnicmp(str, macro_modifier_name[i], len)) + if (iequals(str, macro_modifier_name[i])) break; } if (!macro_modifier_chr[i]) break; @@ -828,7 +771,7 @@ static void trigger_text_to_ascii(char **bufptr, cptr *strptr) for (i = 0; i < max_macrotrigger; i++) { len = strlen(macro_trigger_name[i]); - if (!my_strnicmp(str, macro_trigger_name[i], len) && ']' == str[len]) + if (iequals(str, macro_trigger_name[i]) && ']' == str[len]) { /* a trigger name found */ break; @@ -1060,8 +1003,8 @@ bool_ trigger_ascii_to_text(char **bufptr, cptr *strptr) for (i = 0; i < max_macrotrigger; i++) { - if (!my_stricmp(key_code, macro_trigger_keycode[0][i]) - || !my_stricmp(key_code, macro_trigger_keycode[1][i])) + if (iequals(key_code, macro_trigger_keycode[0][i]) + || iequals(key_code, macro_trigger_keycode[1][i])) break; } if (i == max_macrotrigger) @@ -3480,7 +3423,7 @@ int test_monster_name(cptr name) { monster_race *r_ptr = &r_info[i]; cptr mon_name = r_name + r_ptr->name; - if (stricmp(name, mon_name) == 0) return (i); + if (iequals(name, mon_name)) return (i); } return (0); } @@ -3493,7 +3436,7 @@ int test_mego_name(cptr name) { monster_ego *re_ptr = &re_info[i]; cptr mon_name = re_name + re_ptr->name; - if (stricmp(name, mon_name) == 0) return (i); + if (iequals(name, mon_name)) return (i); } return (0); } @@ -3514,7 +3457,7 @@ int test_item_name(cptr name) object_kind *k_ptr = &k_info[i]; cptr obj_name = k_name + k_ptr->name; /* If name matches, give us the number */ - if (stricmp(name, obj_name) == 0) return (i); + if (iequals(name, obj_name)) return (i); } return (0); } diff --git a/src/xtra2.cc b/src/xtra2.cc index dd9b788a..397ca133 100644 --- a/src/xtra2.cc +++ b/src/xtra2.cc @@ -18,6 +18,10 @@ #include "quark.h" #include "hooks.h" +#include <boost/algorithm/string/predicate.hpp> + +using boost::algorithm::iequals; + /* * Invoke The Rush */ @@ -5572,7 +5576,7 @@ bool_ test_object_wish(char *name, object_type *o_ptr, object_type *forge, const object_desc(buf, o_ptr, FALSE, 0); strlower(buf); - if (!stricmp(buf, name)) + if (iequals(buf, name)) { /* Don't search any more */ return TRUE; @@ -5720,7 +5724,7 @@ void make_wish(void) } strlower(buf); - if (!stricmp(mname, buf)) + if (iequals(mname, buf)) { int wy = p_ptr->py, wx = p_ptr->px; int attempts = 100; |