OSDN Git Service

strchr_j()を英語版の含めて、my_strchr()にまとめた。strstr_j()についても同じく。
authormogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 23 Oct 2003 17:59:23 +0000 (17:59 +0000)
committermogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 23 Oct 2003 17:59:23 +0000 (17:59 +0000)
26 files changed:
src/autopick.c
src/birth.c
src/bldg.c
src/cmd1.c
src/cmd3.c
src/cmd4.c
src/cmd5.c
src/cmd6.c
src/dungeon.c
src/effects.c
src/externs.h
src/files.c
src/flavor.c
src/init1.c
src/japanese.c
src/main-win.c
src/main.c
src/monster2.c
src/object1.c
src/report.c
src/rooms.c
src/spells1.c
src/spells2.c
src/store.c
src/util.c
src/xtra1.c

index 7cde2f5..9a358c2 100644 (file)
@@ -626,7 +626,7 @@ static void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr)
                ADD_FLG(FLG_UNIQUE);
        }
 
-       if (o_ptr->tval == TV_CORPSE && strchr("pht", r_info[o_ptr->pval].d_char))
+       if (o_ptr->tval == TV_CORPSE && my_strchr("pht", r_info[o_ptr->pval].d_char))
        {
                ADD_FLG(FLG_HUMAN);
        }
@@ -1108,7 +1108,7 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_nam
        /*** Human corpse/skeletons (for Daemon magic) ***/
        if (IS_FLG(FLG_HUMAN) &&
            (o_ptr->tval != TV_CORPSE ||
-            !strchr("pht", r_info[o_ptr->pval].d_char)))
+            !my_strchr("pht", r_info[o_ptr->pval].d_char)))
                return FALSE;
 
        /*** Unreadable spellbooks ***/
@@ -1266,11 +1266,7 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_nam
        }
        else
        {
-#ifdef JP
-               if (!strstr_j(o_name, ptr)) return FALSE;
-#else
-               if (!strstr(o_name, ptr)) return FALSE;
-#endif
+               if (!my_strstr(o_name, ptr)) return FALSE;
        }
 
        /* TRUE when it need not to be 'collecting' */
@@ -1378,7 +1374,7 @@ static bool is_opt_confirm_destroy(object_type *o_ptr)
                {
                        if (o_ptr->tval == TV_CORPSE &&
                            o_ptr->sval == SV_CORPSE &&
-                           strchr("pht", r_info[o_ptr->pval].d_char))
+                           my_strchr("pht", r_info[o_ptr->pval].d_char))
                                return FALSE;
                }
 
@@ -2253,13 +2249,13 @@ static void describe_autopick(char *buff, autopick_type *entry)
        {
                strncat(buff, format("¤Ë¡Ö%s¡×", insc), 80);
 
-               if (strstr(insc, "%%all"))
+               if (my_strstr(insc, "%%all"))
                        strcat(buff, "(%%all¤ÏÁ´Ç½ÎϤòɽ¤¹±Ñ»ú¤Îµ­¹æ¤ÇÃÖ´¹)");
-               else if (strstr(insc, "%all"))
+               else if (my_strstr(insc, "%all"))
                        strcat(buff, "(%all¤ÏÁ´Ç½ÎϤòɽ¤¹µ­¹æ¤ÇÃÖ´¹)");
-               else if (strstr(insc, "%%"))
+               else if (my_strstr(insc, "%%"))
                        strcat(buff, "(%%¤ÏÄɲÃǽÎϤòɽ¤¹±Ñ»ú¤Îµ­¹æ¤ÇÃÖ´¹)");
-               else if (strstr(insc, "%"))
+               else if (my_strstr(insc, "%"))
                        strcat(buff, "(%¤ÏÄɲÃǽÎϤòɽ¤¹µ­¹æ¤ÇÃÖ´¹)");
 
                strcat(buff, "¤È¹ï¤ó¤Ç");
@@ -2515,9 +2511,9 @@ static void describe_autopick(char *buff, autopick_type *entry)
        {
                strncat(buff, format("and inscribe \"%s\"", insc), 80);
 
-               if (strstr(insc, "%all"))
+               if (my_strstr(insc, "%all"))
                        strcat(buff, ", replacing %all with code string representing all abilities,");
-               else if (strstr(insc, "%"))
+               else if (my_strstr(insc, "%"))
                        strcat(buff, ", replacing % with code string representing extra random abilities,");
 
                strcat(buff, " on ");
@@ -3464,11 +3460,7 @@ static void search_for_string(text_body_type *tb, cptr search_str, bool forward)
                }
 
                /* Look for the string pattern */
-#ifdef JP
-               pos = strstr_j(tb->lines_list[i], search_str);
-#else
-               pos = strstr(tb->lines_list[i], search_str);
-#endif
+               pos = my_strstr(tb->lines_list[i], search_str);
 
                /* Not found! */
                if (!pos) continue;
index a3829f9..4a5e3fc 100644 (file)
@@ -3720,7 +3720,7 @@ static bool monster_hook_human(int r_idx)
 
        if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
 
-       if (strchr("pht", r_ptr->d_char)) return TRUE;
+       if (my_strchr("pht", r_ptr->d_char)) return TRUE;
 
        return FALSE;
 }
index 9fdfbbb..4c2e7ee 100644 (file)
@@ -4444,9 +4444,9 @@ sprintf(buf, "%c - %s", sym, "̵
                                if (isupper(temp2[xx])) temp2[xx] = tolower(temp2[xx]);
 
 #ifdef JP
-                       if (strstr(temp2, temp) || strstr_j(r_name + r_ptr->name, temp))
+                       if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
 #else
-                       if (strstr(temp2, temp))
+                       if (my_strstr(temp2, temp))
 #endif
                                who[n++] = i;
                }
index ce3f7f9..ddf1d95 100644 (file)
@@ -2295,7 +2295,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                else if (ma_ptr->effect == MA_SLOW)
                                {
                                        if (!((r_ptr->flags1 & RF1_NEVER_MOVE) ||
-                                           strchr("~#{}.UjmeEv$,DdsbBFIJQSXclnw!=?", r_ptr->d_char)))
+                                           my_strchr("~#{}.UjmeEv$,DdsbBFIJQSXclnw!=?", r_ptr->d_char)))
                                        {
 #ifdef JP
                                                msg_format("%s¤Î­¼ó¤Ë´ØÀá½³¤ê¤ò¤¯¤é¤ï¤·¤¿¡ª", m_name);
index ebee3d3..8b5075b 100644 (file)
@@ -2045,9 +2045,9 @@ void do_cmd_query_symbol(void)
                    if (isupper(temp2[xx])) temp2[xx]=tolower(temp2[xx]);
   
 #ifdef JP
-                 if (strstr(temp2, temp) || strstr_j(r_name + r_ptr->name, temp) )
+                 if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp) )
 #else
-                 if (strstr(temp2, temp))
+                 if (my_strstr(temp2, temp))
 #endif
                          who[n++]=i;
                }
index a529d90..3f71fc0 100644 (file)
@@ -1343,7 +1343,7 @@ void do_cmd_messages(int num_now)
                                cptr str = msg;
 
                                /* Display matches */
-                               while ((str = strstr(str, shower)) != NULL)
+                               while ((str = my_strstr(str, shower)) != NULL)
                                {
                                        int len = strlen(shower);
 
@@ -1433,7 +1433,7 @@ void do_cmd_messages(int num_now)
                                cptr msg = message_str(z);
 
                                /* Search for it */
-                               if (strstr(msg, finder))
+                               if (my_strstr(msg, finder))
                                {
                                        /* New location */
                                        i = z;
@@ -5194,7 +5194,7 @@ static int collect_monsters(int grp_cur, s16b mon_idx[], byte mode)
                else
                {
                        /* Check for race in the group */
-                       if (!strchr(group_char, r_ptr->d_char)) continue;
+                       if (!my_strchr(group_char, r_ptr->d_char)) continue;
                }
 
                /* Add the race */
@@ -6799,25 +6799,25 @@ void plural_aux(char *Name)
 {
        int NameLen = strlen(Name);
 
-       if (strstr(Name, "Disembodied hand"))
+       if (my_strstr(Name, "Disembodied hand"))
        {
                strcpy(Name, "Disembodied hands that strangled people");
        }
-       else if (strstr(Name, "Colour out of space"))
+       else if (my_strstr(Name, "Colour out of space"))
        {
                strcpy(Name, "Colours out of space");
        }
-       else if (strstr(Name, "stairway to hell"))
+       else if (my_strstr(Name, "stairway to hell"))
        {
                strcpy(Name, "stairways to hell");
        }
-       else if (strstr(Name, "Dweller on the threshold"))
+       else if (my_strstr(Name, "Dweller on the threshold"))
        {
                strcpy(Name, "Dwellers on the threshold");
        }
-       else if (strstr(Name, " of "))
+       else if (my_strstr(Name, " of "))
        {
-               cptr aider = strstr(Name, " of ");
+               cptr aider = my_strstr(Name, " of ");
                char dummy[80];
                int i = 0;
                cptr ctr = Name;
@@ -6841,7 +6841,7 @@ void plural_aux(char *Name)
                strcpy(&(dummy[i+1]), aider);
                strcpy(Name, dummy);
        }
-       else if (strstr(Name, "coins"))
+       else if (my_strstr(Name, "coins"))
        {
                char dummy[80];
                strcpy(dummy, "piles of ");
@@ -6849,7 +6849,7 @@ void plural_aux(char *Name)
                strcpy(Name, dummy);
                return;
        }
-       else if (strstr(Name, "Manes"))
+       else if (my_strstr(Name, "Manes"))
        {
                return;
        }
@@ -7117,14 +7117,14 @@ static void do_cmd_knowledge_kill_count(void)
                        {
 #ifdef JP
                                /* p,t¤Ï¿Í¤È¿ô¤¨¤ë by ita*/
-                               if(strchr("pt",r_ptr->d_char))
+                               if(my_strchr("pt",r_ptr->d_char))
                                        fprintf(fff, "     %3d ¿Í¤Î %s\n", This, r_name + r_ptr->name);
                                else
                                        fprintf(fff, "     %3d É¤¤Î %s\n", This, r_name + r_ptr->name);
 #else
                                if (This < 2)
                                {
-                                       if (strstr(r_name + r_ptr->name, "coins"))
+                                       if (my_strstr(r_name + r_ptr->name, "coins"))
                                        {
                                                fprintf(fff, "     1 pile of %s\n", (r_name + r_ptr->name));
                                        }
index 8290af8..22ffd2d 100644 (file)
@@ -3592,7 +3592,7 @@ static bool item_tester_offer(object_type *o_ptr)
 
        if (o_ptr->sval != SV_CORPSE) return (FALSE);
 
-       if (strchr("pht", r_info[o_ptr->pval].d_char)) return (TRUE);
+       if (my_strchr("pht", r_info[o_ptr->pval].d_char)) return (TRUE);
 
        /* Assume not okay */
        return (FALSE);
index 0508926..fd2534f 100644 (file)
@@ -523,7 +523,7 @@ msg_print("
        else if ((prace_is_(RACE_DEMON) ||
                 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) &&
                 (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_CORPSE &&
-                 strchr("pht", r_info[o_ptr->pval].d_char)))
+                 my_strchr("pht", r_info[o_ptr->pval].d_char)))
        {
                /* Drain vitality of humanoids */
                char o_name[MAX_NLEN];
@@ -657,7 +657,7 @@ static bool item_tester_hook_eatable(object_type *o_ptr)
        {
                if (o_ptr->tval == TV_CORPSE &&
                    o_ptr->sval == SV_CORPSE &&
-                   strchr("pht", r_info[o_ptr->pval].d_char))
+                   my_strchr("pht", r_info[o_ptr->pval].d_char))
                        return TRUE;
        }
 
index 99ee2fc..0917e13 100644 (file)
@@ -1744,11 +1744,7 @@ static void recharged_notice(object_type *o_ptr)
        if (!o_ptr->inscription) return;
 
        /* Find a '!' */
-#ifdef JP
-       s = strchr_j(quark_str(o_ptr->inscription), '!');
-#else
-       s = strchr(quark_str(o_ptr->inscription), '!');
-#endif
+       s = my_strchr(quark_str(o_ptr->inscription), '!');
 
        /* Process notification request. */
        while (s)
@@ -1776,11 +1772,7 @@ static void recharged_notice(object_type *o_ptr)
                }
 
                /* Keep looking for '!'s */
-#ifdef JP
-               s = strchr_j(s + 1, '!');
-#else
-               s = strchr(s + 1, '!');
-#endif
+               s = my_strchr(s + 1, '!');
        }
 }
 
@@ -5447,7 +5439,7 @@ static bool monster_tsuri(int r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
-       if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && strchr("Jjlw", r_ptr->d_char))
+       if ((r_ptr->flags7 & RF7_AQUATIC) && !(r_ptr->flags1 & RF1_UNIQUE) && my_strchr("Jjlw", r_ptr->d_char))
                return TRUE;
        else
                return FALSE;
index 6c43bb7..24cd8e9 100644 (file)
@@ -5278,13 +5278,13 @@ get_rnd_line("death_j.txt", 0, death_message);
                                  str = death_message;
                                  if (strncmp(str, "¡Ö", 2) == 0) str += 2;
 
-                                 str2 = strstr_j(str, "¡×");
+                                 str2 = my_strstr(str, "¡×");
                                  if (str2 != NULL) *str2 = '\0';
 
                                  i = 0;
                                  while (i < 9)
                                  {
-                                   str2 = strstr_j(str, " ");
+                                   str2 = my_strstr(str, " ");
                                    if (str2 == NULL) len = strlen(str);
                                    else len = str2 - str;
 
index 13dda3b..eb354be 100644 (file)
@@ -1227,6 +1227,8 @@ extern void build_gamma_table(int gamma);
 
 extern size_t my_strcpy(char *buf, const char *src, size_t bufsize);
 extern size_t my_strcat(char *buf, const char *src, size_t bufsize);
+extern char *my_strstr(const char *haystack, const char *needle);
+extern char *my_strchr(const char *ptr, char ch);
 extern int inkey_special(void);
 
 
@@ -1541,8 +1543,6 @@ extern void jverb1( const char *in , char *out);
 extern void jverb2( const char *in , char *out);
 extern void jverb3( const char *in , char *out);
 extern void jverb( const char *in , char *out , int flag);
-extern char* strstr_j(cptr str1, cptr str2);
-extern char *strchr_j(const char *ptr, char ch);
 extern void sjis2euc(char *str);
 extern void euc2sjis(char *str);
 extern byte codeconv(char *str);
index 42d83a7..63a249d 100644 (file)
@@ -624,7 +624,7 @@ errr process_pref_file_command(char *buf)
        case 'Z':
        {
                /* Find the colon */
-               char *t = strchr(buf + 2, ':');
+               char *t = my_strchr(buf + 2, ':');
 
                /* Oops */
                if (!t) return 1;
@@ -923,7 +923,7 @@ cptr process_pref_file_expr(cptr *sp, char *fp)
                int i;
 
                /* Accept all printables except spaces and brackets */
-               for (i = 0; isprint(*s) && !strchr(" []", *s); i++)
+               for (i = 0; isprint(*s) && !my_strchr(" []", *s); i++)
                        b[i] = *s++;
 
                /* Terminate */
@@ -5382,7 +5382,7 @@ msg_format("'%s'
                        }
 
                        /* Hack -- keep searching */
-                       if (find && !i && !strstr(lc_buf, find)) continue;
+                       if (find && !i && !my_strstr(lc_buf, find)) continue;
 
                        /* Hack -- stop searching */
                        find = NULL;
@@ -5431,7 +5431,7 @@ msg_format("'%s'
                                cptr s2 = lc_buf;
 
                                /* Display matches */
-                               while ((s2 = strstr(s2, shower)) != NULL)
+                               while ((s2 = my_strstr(s2, shower)) != NULL)
                                {
                                        int len = strlen(shower);
 
@@ -5884,7 +5884,7 @@ quit_fmt("'%s' 
                }
 #ifdef MSDOS
                /* Convert space, dot, and underscore to underscore */
-               else if (strchr(". _", c)) player_base[k++] = '_';
+               else if (my_strchr(". _", c)) player_base[k++] = '_';
 #endif
                else if (isprint(c)) player_base[k++] = c;
        }
@@ -5919,7 +5919,7 @@ quit_fmt("'%s' 
                while (1)
                {
                        cptr t;
-                       t = strstr(s, PATH_SEP);
+                       t = my_strstr(s, PATH_SEP);
                        if (!t)
                                break;
                        s = t+1;
index 2ed4e98..8fcae76 100644 (file)
@@ -1614,12 +1614,6 @@ static void get_inscription(char *buff, object_type *o_ptr)
 }
 
 
-#ifdef JP
-#undef strchr
-#define strchr strchr_j
-#endif
-
-
 /*
  * Creates a description of the item "o_ptr", and stores it in "out_val".
  *
@@ -2551,7 +2545,7 @@ void object_desc(char *buf, object_type *o_ptr, int pref, int mode)
                        if (*str)
                        {
                                /* Find the '#' */
-                               cptr str = strchr(quark_str(o_ptr->inscription), '#');
+                               cptr str = my_strchr(quark_str(o_ptr->inscription), '#');
 
                                /* Add the false name */
                                t = object_desc_str(t,"¡Ø");
@@ -2596,10 +2590,10 @@ void object_desc(char *buf, object_type *o_ptr, int pref, int mode)
                                t = object_desc_str(t, e_name + e_ptr->name);
                        }
 
-                       if (o_ptr->inscription && strchr(quark_str(o_ptr->inscription), '#'))
+                       if (o_ptr->inscription && my_strchr(quark_str(o_ptr->inscription), '#'))
                        {
                                /* Find the '#' */
-                               cptr str = strchr(quark_str(o_ptr->inscription), '#');
+                               cptr str = my_strchr(quark_str(o_ptr->inscription), '#');
 
                                /* Add the false name */
                                t = object_desc_chr(t, ' ');
@@ -3192,7 +3186,7 @@ void object_desc(char *buf, object_type *o_ptr, int pref, int mode)
 
        if ((abbrev_extra || abbrev_all) && (o_ptr->ident & IDENT_MENTAL))
        {
-               if (!o_ptr->inscription || !strchr(quark_str(o_ptr->inscription), '%'))
+               if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '%'))
                {
                        bool kanji, all;
                        char buf[1024];
index f629e74..b2cec41 100644 (file)
 #include "angband.h"
 
 
-#ifdef JP
-#undef strchr
-#define strchr strchr_j
-#endif
 /*
  * This file is used to initialize various variables and arrays for the
  * Angband game.  Note the use of "fd_read()" and "fd_write()" to bypass
@@ -906,7 +902,7 @@ errr parse_v_info(char *buf, header *head)
        if (buf[0] == 'N')
        {
                /* Find the colon before the name */
-               s = strchr(buf+2, ':');
+               s = my_strchr(buf+2, ':');
 
                /* Verify that colon */
                if (!s) return (1);
@@ -1100,7 +1096,7 @@ errr parse_m_info(char *buf, header *head)
                int xtra, type, first, weight;
 
                /* Find the colon before the name */
-               s = strchr(buf+2, ':');
+               s = my_strchr(buf+2, ':');
 
                /* Verify that colon */
                if (!s) return (1);
@@ -1120,7 +1116,7 @@ errr parse_m_info(char *buf, header *head)
                stat = s;
 
                /* Find the colon before the name */
-               s = strchr(s, ':');
+               s = my_strchr(s, ':');
 
                /* Verify that colon */
                if (!s) return (1);
@@ -1200,7 +1196,7 @@ errr parse_f_info(char *buf, header *head)
        if (buf[0] == 'N')
        {
                /* Find the colon before the name */
-               s = strchr(buf+2, ':');
+               s = my_strchr(buf+2, ':');
 
                        /* Verify that colon */
                if (!s) return (1);
@@ -1360,7 +1356,7 @@ errr parse_k_info(char *buf, header *head)
        if (buf[0] == 'N')
        {
                /* Find the colon before the name */
-               s = strchr(buf+2, ':');
+               s = my_strchr(buf+2, ':');
 
                        /* Verify that colon */
                if (!s) return (1);
@@ -1506,10 +1502,10 @@ errr parse_k_info(char *buf, header *head)
                        k_ptr->locale[i] = atoi(s+1);
 
                                /* Find the slash */
-                       t = strchr(s+1, '/');
+                       t = my_strchr(s+1, '/');
 
                                /* Find the next colon */
-                       s = strchr(s+1, ':');
+                       s = my_strchr(s+1, ':');
 
                                /* If the slash is "nearby", use it */
                        if (t && (!s || t < s))
@@ -1630,7 +1626,7 @@ errr parse_a_info(char *buf, header *head)
        if (buf[0] == 'N')
        {
                /* Find the colon before the name */
-               s = strchr(buf+2, ':');
+               s = my_strchr(buf+2, ':');
 
                        /* Verify that colon */
                if (!s) return (1);
@@ -1858,7 +1854,7 @@ errr parse_e_info(char *buf, header *head)
        if (buf[0] == 'N')
        {
                /* Find the colon before the name */
-               s = strchr(buf+2, ':');
+               s = my_strchr(buf+2, ':');
 
                        /* Verify that colon */
                if (!s) return (1);
@@ -2161,7 +2157,7 @@ errr parse_r_info(char *buf, header *head)
        if (buf[0] == 'N')
        {
                /* Find the colon before the name */
-               s = strchr(buf+2, ':');
+               s = my_strchr(buf+2, ':');
 
                        /* Verify that colon */
                if (!s) return (1);
@@ -2609,7 +2605,7 @@ errr parse_d_info(char *buf, header *head)
        if (buf[0] == 'N')
        {
                /* Find the colon before the name */
-               s = strchr(buf+2, ':');
+               s = my_strchr(buf+2, ':');
 
                /* Verify that colon */
                if (!s) return (1);
@@ -3127,7 +3123,7 @@ static errr parse_line_building(char *buf)
        index = atoi(s);
 
        /* Find the colon after the building number */
-       s = strchr(s, ':');
+       s = my_strchr(s, ':');
 
        /* Verify that colon */
        if (!s) return (1);
@@ -3858,7 +3854,7 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
        else
        {
                /* Accept all printables except spaces and brackets */
-               while (isprint(*s) && !strchr(" []", *s)) ++s;
+               while (isprint(*s) && !my_strchr(" []", *s)) ++s;
 
                /* Extract final and Terminate */
                if ((f = *s) != '\0') *s++ = '\0';
index 523b881..e864d84 100644 (file)
@@ -124,35 +124,6 @@ void jverb( const char *in , char *out , int flag){
   }
 }
 
-char* strstr_j(const char* s, const char* t)
-{
-       int i, l1, l2;
-
-       l1 = strlen(s);
-       l2 = strlen(t);
-       if (l1 >= l2) {
-               for(i = 0; i <= l1 - l2; i++) {
-                       if(!strncmp(s + i, t, l2))
-                               return (char *)s + i;
-                       if (iskanji(*(s + i)))
-                               i++;
-               }
-       }
-       return NULL;
-}
-
-
-char *strchr_j(const char *ptr, char ch)
-{
-       for ( ; *ptr != '\0'; ++ptr)
-       {
-               if (*ptr == ch) return (char *)ptr;
-               if (iskanji(*ptr)) ++ptr;
-       }
-
-       return NULL;
-}
-
 
 /*
  * Convert SJIS string to EUC string
index df8303a..2c10844 100644 (file)
@@ -849,7 +849,7 @@ static char *analyze_font(char *path, int *wp, int *hp)
        }
 
        /* Find first 'X' */
-       s = strchr(p, 'X');
+       s = my_strchr(p, 'X');
 
        /* Extract font width */
        wid = atoi(p);
index 3ea3b3a..d115fb0 100644 (file)
@@ -161,7 +161,7 @@ static void change_path(cptr info)
        cptr s;
 
        /* Find equal sign */
-       s = strchr(info, '=');
+       s = my_strchr(info, '=');
 
        /* Verify equal sign */
        if (!s) quit_fmt("Try '-d<what>=<path>' not '-d%s'", info);
index 7055f77..c4ddc64 100644 (file)
@@ -768,7 +768,7 @@ static bool summon_specific_aux(int r_idx)
                case SUMMON_ANIMAL_RANGER:
                {
                        okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
-                              (strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
+                              (my_strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
                               !(r_ptr->flags3 & (RF3_DRAGON)) &&
                               !(r_ptr->flags3 & (RF3_EVIL)) &&
                               !(r_ptr->flags3 & (RF3_UNDEAD)) &&
@@ -4107,7 +4107,7 @@ void message_pain(int m_idx, int dam)
 
 
        /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
-       if (strchr(",ejmvwQ", r_ptr->d_char))
+       if (my_strchr(",ejmvwQ", r_ptr->d_char))
        {
 #ifdef JP
                if (percentage > 95)
@@ -4145,7 +4145,7 @@ void message_pain(int m_idx, int dam)
 
 
        /* Fish */
-       else if (strchr("l", r_ptr->d_char))
+       else if (my_strchr("l", r_ptr->d_char))
        {
                if (percentage > 95)
 #ifdef JP
@@ -4193,7 +4193,7 @@ msg_format("%^s
 
 
        /* Golems, Walls, Doors, Stairs */
-       else if (strchr("g#+<>", r_ptr->d_char))
+       else if (my_strchr("g#+<>", r_ptr->d_char))
        {
                if (percentage > 95)
 #ifdef JP
@@ -4241,7 +4241,7 @@ msg_format("%^s
 
 
        /* Snakes, Hydrae, Reptiles, Mimics */
-       else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
+       else if (my_strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
        {
                if (percentage > 95)
 #ifdef JP
@@ -4289,7 +4289,7 @@ msg_format("%^s
 
 
        /* Felines */
-       else if (strchr("f", r_ptr->d_char))
+       else if (my_strchr("f", r_ptr->d_char))
        {
                if (percentage > 95)
 #ifdef JP
@@ -4337,7 +4337,7 @@ msg_format("%s
 
 
        /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
-       else if (strchr("acFIKS", r_ptr->d_char))
+       else if (my_strchr("acFIKS", r_ptr->d_char))
        {
                if (percentage > 95)
 #ifdef JP
@@ -4391,7 +4391,7 @@ msg_format("%^s
 
 
        /* Birds */
-       else if (strchr("B", r_ptr->d_char))
+       else if (my_strchr("B", r_ptr->d_char))
        {
                if (percentage > 95)
 #ifdef JP
@@ -4446,7 +4446,7 @@ msg_format("%^s
 
 
        /* Dragons, Demons, High Undead */
-       else if (strchr("duDLUW", r_ptr->d_char))
+       else if (my_strchr("duDLUW", r_ptr->d_char))
        {
                if (percentage > 95)
 #ifdef JP
@@ -4501,7 +4501,7 @@ msg_format("%^s
 
 
        /* Skeletons */
-       else if (strchr("s", r_ptr->d_char))
+       else if (my_strchr("s", r_ptr->d_char))
        {
                if (percentage > 95)
 #ifdef JP
@@ -4556,7 +4556,7 @@ msg_format("%^s
 
 
        /* Zombies */
-       else if (strchr("z", r_ptr->d_char))
+       else if (my_strchr("z", r_ptr->d_char))
        {
                if (percentage > 95)
 #ifdef JP
@@ -4611,7 +4611,7 @@ msg_format("%^s
 
 
        /* Ghosts */
-       else if (strchr("G", r_ptr->d_char))
+       else if (my_strchr("G", r_ptr->d_char))
 
        {
                if (percentage > 95)
@@ -4667,7 +4667,7 @@ msg_format("%^s
 
 
        /* Dogs and Hounds */
-       else if (strchr("CZ", r_ptr->d_char))
+       else if (my_strchr("CZ", r_ptr->d_char))
        {
 #ifdef JP
                if (percentage > 95)
@@ -4704,7 +4704,7 @@ msg_format("%^s
        }
 
        /* One type of monsters (ignore,squeal,shriek) */
-       else if (strchr("Xbilqrt", r_ptr->d_char))
+       else if (my_strchr("Xbilqrt", r_ptr->d_char))
        {
 #ifdef JP
                if (percentage > 95)
index d2a4a69..4b9ea21 100644 (file)
@@ -4605,12 +4605,6 @@ void display_equip(void)
 }
 
 
-#ifdef JP
-#undef strchr
-#define strchr strchr_j
-#endif
-
-
 /*
  * Find the "first" inventory object with the given "tag".
  *
@@ -4660,7 +4654,7 @@ static bool get_tag(int *cp, char tag, int mode)
                if (!item_tester_okay(o_ptr)) continue;
 
                /* Find a '@' */
-               s = strchr(quark_str(o_ptr->inscription), '@');
+               s = my_strchr(quark_str(o_ptr->inscription), '@');
 
                /* Process all tags */
                while (s)
@@ -4676,7 +4670,7 @@ static bool get_tag(int *cp, char tag, int mode)
                        }
 
                        /* Find another '@' */
-                       s = strchr(s + 1, '@');
+                       s = my_strchr(s + 1, '@');
                }
        }
 
@@ -4705,7 +4699,7 @@ static bool get_tag(int *cp, char tag, int mode)
                if (!item_tester_okay(o_ptr)) continue;
 
                /* Find a '@' */
-               s = strchr(quark_str(o_ptr->inscription), '@');
+               s = my_strchr(quark_str(o_ptr->inscription), '@');
 
                /* Process all tags */
                while (s)
@@ -4721,7 +4715,7 @@ static bool get_tag(int *cp, char tag, int mode)
                        }
 
                        /* Find another '@' */
-                       s = strchr(s + 1, '@');
+                       s = my_strchr(s + 1, '@');
                }
        }
 
@@ -4756,7 +4750,7 @@ static bool get_tag_floor(int *cp, char tag, int floor_list[], int floor_num)
                if (!o_ptr->inscription) continue;
 
                /* Find a '@' */
-               s = strchr(quark_str(o_ptr->inscription), '@');
+               s = my_strchr(quark_str(o_ptr->inscription), '@');
 
                /* Process all tags */
                while (s)
@@ -4772,7 +4766,7 @@ static bool get_tag_floor(int *cp, char tag, int floor_list[], int floor_num)
                        }
 
                        /* Find another '@' */
-                       s = strchr(s + 1, '@');
+                       s = my_strchr(s + 1, '@');
                }
        }
 
@@ -4795,7 +4789,7 @@ static bool get_tag_floor(int *cp, char tag, int floor_list[], int floor_num)
                if (!o_ptr->inscription) continue;
 
                /* Find a '@' */
-               s = strchr(quark_str(o_ptr->inscription), '@');
+               s = my_strchr(quark_str(o_ptr->inscription), '@');
 
                /* Process all tags */
                while (s)
@@ -4811,7 +4805,7 @@ static bool get_tag_floor(int *cp, char tag, int floor_list[], int floor_num)
                        }
 
                        /* Find another '@' */
-                       s = strchr(s + 1, '@');
+                       s = my_strchr(s + 1, '@');
                }
        }
 
@@ -5379,7 +5373,7 @@ static bool get_item_allow(int item)
        if (!o_ptr->inscription) return (TRUE);
 
        /* Find a '!' */
-       s = strchr(quark_str(o_ptr->inscription), '!');
+       s = my_strchr(quark_str(o_ptr->inscription), '!');
 
        /* Process preventions */
        while (s)
@@ -5397,7 +5391,7 @@ if (!verify("
                }
 
                /* Find another '!' */
-               s = strchr(s + 1, '!');
+               s = my_strchr(s + 1, '!');
        }
 
        /* Allow it */
index f5a502e..6a6aa0c 100644 (file)
@@ -170,7 +170,7 @@ static int buf_search(BUF *buf, const char *str)
 {
        char *ret;
 
-       ret = strstr(buf->data, str);
+       ret = my_strstr(buf->data, str);
 
        if (!ret) return -1;
 
index eb0c17c..c9e7a37 100644 (file)
@@ -1371,7 +1371,7 @@ static bool vault_aux_jelly(int r_idx)
        if (r_ptr->flags3 & (RF3_EVIL)) return (FALSE);
 
        /* Require icky thing, jelly, mold, or mushroom */
-       if (!strchr("ijm,", r_ptr->d_char)) return (FALSE);
+       if (!my_strchr("ijm,", r_ptr->d_char)) return (FALSE);
 
        /* Okay */
        return (TRUE);
@@ -1457,7 +1457,7 @@ static bool vault_aux_kennel(int r_idx)
        if (!vault_monster_okay(r_idx)) return (FALSE);
 
        /* Require a Zephyr Hound or a dog */
-       if (!strchr("CZ", r_ptr->d_char)) return (FALSE);
+       if (!my_strchr("CZ", r_ptr->d_char)) return (FALSE);
   
        /* Okay */
        return (TRUE);
@@ -1475,7 +1475,7 @@ static bool vault_aux_mimic(int r_idx)
        if (!vault_monster_okay(r_idx)) return (FALSE);
   
        /* Require mimic */
-       if (!strchr("!|$?=", r_ptr->d_char)) return (FALSE);
+       if (!my_strchr("!|$?=", r_ptr->d_char)) return (FALSE);
 
        /* Okay */
        return (TRUE);
index 8c0de46..c64a45b 100644 (file)
@@ -180,7 +180,7 @@ static byte spell_color(int type)
                c = s[randint0(strlen(s))];
 
                /* Lookup this color */
-               a = strchr(color_char, c) - color_char;
+               a = my_strchr(color_char, c) - color_char;
 
                /* Invalid color (note check for < 0 removed, gave a silly
                 * warning because bytes are always >= 0 -- RG) */
index 7a058a8..89daafa 100644 (file)
@@ -4363,7 +4363,7 @@ bool detect_monsters_string(int range, cptr Match)
                if (distance(py, px, y, x) > range) continue;
 
                /* Detect monsters with the same symbol */
-               if (strchr(Match, r_ptr->d_char))
+               if (my_strchr(Match, r_ptr->d_char))
                {
                        /* Update monster recall window */
                        if (p_ptr->monster_race_idx == m_ptr->r_idx)
index 5415e49..c1b1601 100644 (file)
@@ -1421,7 +1421,7 @@ static bool store_will_buy(object_type *o_ptr)
                                                if (r_ptr->flags3 & RF3_ANIMAL) break;
 
                                                /* Accept mimics */
-                                               if (strchr("?!", r_ptr->d_char)) break;
+                                               if (my_strchr("?!", r_ptr->d_char)) break;
                                        }
                                }
                                case TV_POLEARM:
index 2b88479..029bf43 100644 (file)
@@ -215,7 +215,7 @@ errr path_parse(char *buf, int max, cptr file)
        u = file+1;
 
        /* Look for non-user portion of the file */
-       s = strstr(u, PATH_SEP);
+       s = my_strstr(u, PATH_SEP);
 
        /* Hack -- no long user names */
        if (s && (s >= u + sizeof(user))) return (1);
@@ -364,7 +364,7 @@ FILE *my_fopen(cptr file, cptr mode)
        if (path_parse(buf, 1024, file)) return (NULL);
 
 #if defined(MACINTOSH) && defined(MAC_MPW)
-       if (strchr(mode, 'w'))
+       if (my_strchr(mode, 'w'))
        {
                /* setting file type/creator */
                tempfff = fopen(buf, mode);
@@ -1106,7 +1106,7 @@ static void trigger_text_to_ascii(char **bufptr, cptr *strptr)
        /* Invalid trigger name? */
        if (i == max_macrotrigger)
        {
-               str = strchr(str, ']');
+               str = my_strchr(str, ']');
                if (str)
                {
                        *s++ = (char)31;
@@ -1308,7 +1308,7 @@ static bool trigger_ascii_to_text(char **bufptr, cptr *strptr)
                switch(ch)
                {
                case '&':
-                       while ((tmp = strchr(macro_modifier_chr, *str)))
+                       while ((tmp = my_strchr(macro_modifier_chr, *str)))
                        {
                                j = (int)(tmp - macro_modifier_chr);
                                tmp = macro_modifier_name[j];
@@ -4437,7 +4437,7 @@ prt(format("
        if (always_repeat && (command_arg <= 0))
        {
                /* Hack -- auto repeat certain commands */
-               if (strchr("TBDoc+", command_cmd))
+               if (my_strchr("TBDoc+", command_cmd))
                {
                        /* Repeat 99 times */
                        command_arg = 99;
@@ -4478,11 +4478,6 @@ prt(format("
                caretcmd = command_cmd;
 #endif
 
-#ifdef JP
-#undef strchr
-#define strchr strchr_j
-#endif
-
        /* Hack -- Scan equipment */
        for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
        {
@@ -4500,7 +4495,7 @@ prt(format("
                s = quark_str(o_ptr->inscription);
 
                /* Find a '^' */
-               s = strchr(s, '^');
+               s = my_strchr(s, '^');
 
                /* Process preventions */
                while (s)
@@ -4527,7 +4522,7 @@ prt(format("
                        }
 
                        /* Find another '^' */
-                       s = strchr(s + 1, '^');
+                       s = my_strchr(s + 1, '^');
                }
        }
 
@@ -4579,7 +4574,7 @@ static bool insert_str(char *buf, cptr target, cptr insert)
        int                b_len, t_len, i_len;
 
        /* Attempt to find the target (modify "buf") */
-       buf = strstr(buf, target);
+       buf = my_strstr(buf, target);
 
        /* No target found */
        if (!buf) return (FALSE);
@@ -5220,6 +5215,54 @@ size_t my_strcat(char *buf, const char *src, size_t bufsize)
 
 
 /*
+ * A copy of ANSI strstr()
+ *
+ * my_strstr() can handle Kanji strings correctly.
+ */
+char *my_strstr(const char *haystack, const char *needle)
+{
+       int i;
+       int l1 = strlen(haystack);
+       int l2 = strlen(needle);
+
+       if (l1 >= l2)
+       {
+               for(i = 0; i <= l1 - l2; i++)
+               {
+                       if(!strncmp(haystack + i, needle, l2))
+                               return (char *)haystack + i;
+
+#ifdef JP
+                       if (iskanji(*(haystack + i))) i++;
+#endif
+               }
+       }
+
+       return NULL;
+}
+
+
+/*
+ * A copy of ANSI my_strchr()
+ *
+ * my_strchr() can handle Kanji strings correctly.
+ */
+char *my_strchr(const char *ptr, char ch)
+{
+       for ( ; *ptr != '\0'; ptr++)
+       {
+               if (*ptr == ch) return (char *)ptr;
+
+#ifdef JP
+               if (iskanji(*ptr)) ptr++;
+#endif
+       }
+
+       return NULL;
+}
+
+
+/*
  * Get a keypress from the user.
  * And interpret special keys as internal code.
  *
index 3cf7d0f..e82902d 100644 (file)
@@ -2901,12 +2901,6 @@ bool buki_motteruka(int i)
 }
 
 
-#ifdef JP
-#undef strchr
-#define strchr strchr_j
-#endif
-
-
 /*
  * Calculate the players current "state", taking into account
  * not only race/class intrinsics, but also objects being worn
@@ -3880,7 +3874,7 @@ void calc_bonuses(void)
                if (have_flag(flgs, TR_FREE_ACT))    p_ptr->free_act = TRUE;
                if (have_flag(flgs, TR_HOLD_LIFE))   p_ptr->hold_life = TRUE;
                if (have_flag(flgs, TR_WARNING)){
-                       if (!o_ptr->inscription || !(strchr(quark_str(o_ptr->inscription),'$')))
+                       if (!o_ptr->inscription || !(my_strchr(quark_str(o_ptr->inscription),'$')))
                          p_ptr->warning = TRUE;
                }
 
@@ -3892,7 +3886,7 @@ void calc_bonuses(void)
                                cptr insc = quark_str(o_ptr->inscription);
 
                                if (o_ptr->inscription &&
-                                   (strchr(insc, '.') || strchr(insc, '%')))
+                                   (my_strchr(insc, '.') || my_strchr(insc, '%')))
                                {
                                        /*
                                         * {.} will stop random teleportation.