OSDN Git Service

前回のstrncpyがらみの修正に対し、で英語の方の書き方を日本語の方にあわせた。
authorhenkma <henkma@0568b783-4c39-0410-ac80-bf13821ea2a2>
Tue, 29 Jan 2002 12:51:16 +0000 (12:51 +0000)
committerhenkma <henkma@0568b783-4c39-0410-ac80-bf13821ea2a2>
Tue, 29 Jan 2002 12:51:16 +0000 (12:51 +0000)
ついでに用意されたバッファをちゃんと全部使うように修正。

src/util.c

index 9f41209..1625c19 100644 (file)
@@ -3305,10 +3305,6 @@ bool get_check_strict(cptr prompt, int mode)
        int i;
        char buf[80];
 
-       /* "strncpy" sometimes fails to set '\0' to the end of the 
-          given string. So "memset" is necessary! -- henkma       */
-       memset(buf, 0, 80);
-
        if (auto_more)
        {
                p_ptr->window |= PW_MESSAGE;
@@ -3322,22 +3318,30 @@ bool get_check_strict(cptr prompt, int mode)
        if (!rogue_like_commands)
                mode &= ~1;
 
+
        /* Hack -- Build a "useful" prompt */
        if (mode & 1)
        {
 #ifdef JP
-               mb_strlcpy(buf, prompt, 78-8);
+               /* (79-8)¥Ð¥¤¥È¤Î»ØÄê, prompt¤¬Ä¹¤«¤Ã¤¿¾ì¹ç, 
+                  (79-9)ʸ»ú¤Î¸å½ªÃ¼Ê¸»ú¤¬½ñ¤­¹þ¤Þ¤ì¤ë.     
+                  ±Ñ¸ì¤ÎÊý¤Îstrncpy¤È¤Ï°ã¤¦¤Î¤ÇÃí°Õ.
+                  else¤ÎÊý¤Îʬ´ô¤âƱÍÍ. --henkma
+               */
+               mb_strlcpy(buf, prompt, 80-8);
 #else
-               strncpy(buf, prompt, 78-8);
+               strncpy(buf, prompt, 79-8);
+               buf[79-8]='\0';
 #endif
                strcat(buf, "[yes/no]");
        }
        else
        {
 #ifdef JP
-               mb_strlcpy(buf, prompt, 78-5);
+               mb_strlcpy(buf, prompt, 80-5);
 #else
-               strncpy(buf, prompt, 78-5);
+               strncpy(buf, prompt, 79-5);
+               buf[79-5]='\0';
 #endif
                strcat(buf, "[y/n]");
        }