OSDN Git Service

SJIS環境で, 例として{八咫}と刻んだアイテムを鑑定の巻物や杖で鑑定しよ
authornothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 15 Sep 2003 07:16:01 +0000 (07:16 +0000)
committernothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 15 Sep 2003 07:16:01 +0000 (07:16 +0000)
うとすると選択肢の文字が指定していない文字に変わっていた. これはSJIS
では "八咫" の文字コードが0x94, 0xAA, 0x9A, 0x40であるため, この銘は
{(文字列)@'\0'} とみなされていた. 2回目以降のアイテム選択では
command_cmd = 0としたため, '@' の次である '\0' がマッチし, 文字列の次
にあるゴミを選択肢として使ってしまい, 場合によっては配列外アクセスも
起こす可能性があった. このバグに対処するため, init1.cにある_strchr()
をjapanese.cに移転し, strchr_j()と変更. アイテムの銘を始めとして日本
語文字列からstrchr()する場合に限りstrchr_j()を適切に#defineでかぶせて
使うようにした.

src/dungeon.c
src/externs.h
src/flavor.c
src/init1.c
src/japanese.c
src/object1.c
src/util.c
src/xtra1.c

index 1da6b29..abd9d2e 100644 (file)
@@ -1755,7 +1755,11 @@ 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
 
        /* Process notification request. */
        while (s)
@@ -1783,7 +1787,11 @@ 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
        }
 }
 
index fbedd5b..5b14393 100644 (file)
@@ -1541,6 +1541,7 @@ 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 ba1a0ea..312c7ef 100644 (file)
@@ -1605,6 +1605,11 @@ 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".
index ca6abe9..b710f77 100644 (file)
 
 #ifdef JP
 #undef strchr
-static char *_strchr(const char *ptr, char ch)
-{
-       for ( ; *ptr != '\0'; ++ptr)
-       {
-               if (*ptr == ch) return (char *)ptr;
-               if (iskanji(*ptr)) ++ptr;
-       }
-
-       return NULL;
-}
-#define strchr _strchr
+#define strchr strchr_j
 #endif
 /*
  * This file is used to initialize various variables and arrays for the
index cfdb037..523b881 100644 (file)
@@ -142,6 +142,18 @@ char* strstr_j(const char* s, const char* t)
 }
 
 
+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 18a0bf2..d2a4a69 100644 (file)
@@ -4605,6 +4605,12 @@ void display_equip(void)
 }
 
 
+#ifdef JP
+#undef strchr
+#define strchr strchr_j
+#endif
+
+
 /*
  * Find the "first" inventory object with the given "tag".
  *
index a051408..b602a08 100644 (file)
@@ -4347,6 +4347,12 @@ prt(format("
        if (!caretcmd)
                caretcmd = command_cmd;
 #endif
+
+#ifdef JP
+#undef strchr
+#define strchr strchr_j
+#endif
+
        /* Hack -- Scan equipment */
        for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
        {
index 76bde25..62c3c26 100644 (file)
@@ -2888,6 +2888,13 @@ bool buki_motteruka(int i)
        return ((inventory[i].k_idx && inventory[i].tval >= TV_DIGGING && inventory[i].tval <= TV_SWORD) ? TRUE : FALSE);
 }
 
+
+#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