OSDN Git Service

[fix] gccの警告に従い修正
authorHabu <habu@users.sourceforge.jp>
Mon, 20 Apr 2020 14:51:20 +0000 (23:51 +0900)
committerHabu <habu@users.sourceforge.jp>
Mon, 20 Apr 2020 14:51:20 +0000 (23:51 +0900)
以下の細々とした警告に対応:
 - switch-case文でbreakが無い(その前の関数の中でプログラムが終了するが、一応付加しておく)
 - 他ファイルに移した未使用のstatic関数
 - 変数の型の誤り
 - 符号付き変数と符号無し変数の比較
 - strlenにNULLが渡される可能性
 - 未使用変数の存在
 - 構造体の初期化メンバの不足
 - for と同じ行に2つ以上の文がある

12 files changed:
src/birth.c
src/cmd/cmd-dump.c
src/cmd/cmd-smith.c
src/combat/melee1.c
src/core/show-file.c
src/japanese.c
src/main-gcu.c
src/main.c
src/mspells4.c
src/player/process-name.c
src/spells-object.c
src/view-mainwindow.c

index e0201c6..3e1a0d3 100644 (file)
@@ -3147,6 +3147,7 @@ static bool get_stat_limits(player_type *creature_ptr)
                switch (c) {
                case 'Q':
                        birth_quit();
+                       break;
                case 'S':
                        return FALSE;
                case ESCAPE:
@@ -3385,6 +3386,7 @@ static bool get_chara_limits(player_type *creature_ptr)
                switch (c) {
                case 'Q':
                        birth_quit();
+                       break;
                case 'S':
                        return FALSE;
                case ESCAPE:
index f5567b8..9fdce4a 100644 (file)
@@ -82,225 +82,6 @@ static SYMBOL_CODE char_idx_feat[F_LIT_MAX];
 // Encode the screen colors
 static char hack[17] = "dwsorgbuDWvyRGBU";
 
-/*!
- * @brief prefファイルを選択して処理する /
- * Ask for a "user pref line" and process it
- * @brief prf出力内容を消去する /
- * Remove old lines automatically generated before.
- * @param orig_file 消去を行うファイル名
- */
-static void remove_auto_dump(concptr orig_file, concptr auto_dump_mark)
-{
-       FILE *tmp_fff, *orig_fff;
-       char tmp_file[1024];
-       char buf[1024];
-       bool between_mark = FALSE;
-       bool changed = FALSE;
-       int line_num = 0;
-       long header_location = 0;
-       char header_mark_str[80];
-       char footer_mark_str[80];
-
-       sprintf(header_mark_str, auto_dump_header, auto_dump_mark);
-       sprintf(footer_mark_str, auto_dump_footer, auto_dump_mark);
-       size_t mark_len = strlen(footer_mark_str);
-       orig_fff = my_fopen(orig_file, "r");
-       if (!orig_fff) return;
-
-       tmp_fff = my_fopen_temp(tmp_file, 1024);
-       if (!tmp_fff)
-       {
-               msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), tmp_file);
-               msg_print(NULL);
-               return;
-       }
-
-       while (TRUE)
-       {
-               if (my_fgets(orig_fff, buf, sizeof(buf)))
-               {
-                       if (between_mark)
-                       {
-                               fseek(orig_fff, header_location, SEEK_SET);
-                               between_mark = FALSE;
-                               continue;
-                       }
-                       else
-                       {
-                               break;
-                       }
-               }
-
-               if (!between_mark)
-               {
-                       if (!strcmp(buf, header_mark_str))
-                       {
-                               header_location = ftell(orig_fff);
-                               line_num = 0;
-                               between_mark = TRUE;
-                               changed = TRUE;
-                       }
-                       else
-                       {
-                               fprintf(tmp_fff, "%s\n", buf);
-                       }
-
-                       continue;
-               }
-
-               if (!strncmp(buf, footer_mark_str, mark_len))
-               {
-                       int tmp;
-                       if (!sscanf(buf + mark_len, " (%d)", &tmp)
-                               || tmp != line_num)
-                       {
-                               fseek(orig_fff, header_location, SEEK_SET);
-                       }
-
-                       between_mark = FALSE;
-                       continue;
-               }
-
-               line_num++;
-       }
-
-       my_fclose(orig_fff);
-       my_fclose(tmp_fff);
-
-       if (changed)
-       {
-               tmp_fff = my_fopen(tmp_file, "r");
-               orig_fff = my_fopen(orig_file, "w");
-               while (!my_fgets(tmp_fff, buf, sizeof(buf)))
-                       fprintf(orig_fff, "%s\n", buf);
-
-               my_fclose(orig_fff);
-               my_fclose(tmp_fff);
-       }
-
-       fd_kill(tmp_file);
-}
-
-
-#ifdef JP
-#else
-/*!
- * @brief Return suffix of ordinal number
- * @param num number
- * @return pointer of suffix string.
- */
-concptr get_ordinal_number_suffix(int num)
-{
-       num = ABS(num) % 100;
-       switch (num % 10)
-       {
-       case 1:
-               return (num == 11) ? "th" : "st";
-       case 2:
-               return (num == 12) ? "th" : "nd";
-       case 3:
-               return (num == 13) ? "th" : "rd";
-       default:
-               return "th";
-       }
-}
-#endif
-
-
-/*!
- * @brief 日記のタイトル表記と内容出力
- * @param creature_ptr プレーヤーへの参照ポインタ
- * @return なし
- */
-static void display_diary(player_type *creature_ptr)
-{
-       char diary_title[256];
-       GAME_TEXT file_name[MAX_NLEN];
-       char buf[1024];
-       char tmp[80];
-       sprintf(file_name, _("playrecord-%s.txt", "playrec-%s.txt"), savefile_base);
-       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
-
-       if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_SAMURAI || creature_ptr->pclass == CLASS_BERSERKER)
-               strcpy(tmp, subtitle[randint0(MAX_SUBTITLE - 1)]);
-       else if (IS_WIZARD_CLASS(creature_ptr))
-               strcpy(tmp, subtitle[randint0(MAX_SUBTITLE - 1) + 1]);
-       else strcpy(tmp, subtitle[randint0(MAX_SUBTITLE - 2) + 1]);
-
-#ifdef JP
-       sprintf(diary_title, "「%s%s%sの伝説 -%s-」", ap_ptr->title, ap_ptr->no ? "の" : "", creature_ptr->name, tmp);
-#else
-       sprintf(diary_title, "Legend of %s %s '%s'", ap_ptr->title, creature_ptr->name, tmp);
-#endif
-
-       (void)show_file(creature_ptr, FALSE, buf, diary_title, -1, 0);
-}
-
-
-/*!
- * @brief 日記に任意の内容を表記するコマンドのメインルーチン /
- * @return なし
- */
-static void add_diary_note(player_type *creature_ptr)
-{
-       char tmp[80] = "\0";
-       char bunshou[80] = "\0";
-       if (get_string(_("内容: ", "diary note: "), tmp, 79))
-       {
-               strcpy(bunshou, tmp);
-               exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, bunshou);
-       }
-}
-
-/*!
- * @brief 最後に取得したアイテムの情報を日記に追加するメインルーチン /
- * @return なし
- */
-static void do_cmd_last_get(player_type *creaute_ptr)
-{
-       if (record_o_name[0] == '\0') return;
-
-       char buf[256];
-       sprintf(buf, _("%sの入手を記録します。", "Do you really want to record getting %s? "), record_o_name);
-       if (!get_check(buf)) return;
-
-       GAME_TURN turn_tmp = current_world_ptr->game_turn;
-       current_world_ptr->game_turn = record_turn;
-       sprintf(buf, _("%sを手に入れた。", "discovered %s."), record_o_name);
-       exe_write_diary(creaute_ptr, DIARY_DESCRIPTION, 0, buf);
-       current_world_ptr->game_turn = turn_tmp;
-}
-
-
-/*!
- * @brief ファイル中の全日記記録を消去する /
- * @return なし
- */
-static void do_cmd_erase_diary(void)
-{
-       GAME_TEXT file_name[MAX_NLEN];
-       char buf[256];
-       FILE *fff = NULL;
-
-       if (!get_check(_("本当に記録を消去しますか?", "Do you really want to delete all your record? "))) return;
-       sprintf(file_name, _("playrecord-%s.txt", "playrec-%s.txt"), savefile_base);
-       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
-       fd_kill(buf);
-
-       fff = my_fopen(buf, "w");
-       if (fff)
-       {
-               my_fclose(fff);
-               msg_format(_("記録を消去しました。", "deleted record."));
-       }
-       else
-       {
-               msg_format(_("%s の消去に失敗しました。", "failed to delete %s."), buf);
-       }
-
-       msg_print(NULL);
-}
-
 
 /*!
  * @brief 画面を再描画するコマンドのメインルーチン
@@ -1849,8 +1630,8 @@ static void display_visual_list(int col, int row, int height, int width, TERM_CO
                        TERM_LEN y = row + i;
                        if (use_bigtile) x += j;
 
-                       TERM_COLOR ia = attr_top + i;
-                       SYMBOL_CODE ic = char_left + j;
+                       int ia = attr_top + i;
+                       int ic = char_left + j;
                        if (ia > 0x7f || ic > 0xff || ic < ' ' ||
                                (!use_graphics && ic > 0x7f))
                                continue;
@@ -1982,7 +1763,7 @@ static bool visual_mode_command(char ch, bool *visual_list_ptr,
                        if ((a == 0) && (ddy[d] < 0)) d = 0;
                        if ((c == 0) && (ddx[d] < 0)) d = 0;
                        if ((a == 0x7f) && (ddy[d] > 0)) d = 0;
-                       if ((c == 0xff) && (ddx[d] > 0)) d = 0;
+                       if (((byte)c == 0xff) && (ddx[d] > 0)) d = 0;
 
                        a += (TERM_COLOR)ddy[d];
                        c += (SYMBOL_CODE)ddx[d];
index e71e816..c7efe50 100644 (file)
@@ -517,7 +517,7 @@ static void display_essence(player_type *creature_ptr)
 static void drain_essence(player_type *creature_ptr)
 {
        int drain_value[sizeof(creature_ptr->magic_num1) / sizeof(s32b)];
-       int i;
+       size_t i;
        OBJECT_IDX item;
        int dec = 4;
        bool observe = FALSE;
index 603f4c8..05d92a4 100644 (file)
@@ -569,7 +569,7 @@ static MULTIPLY mult_slaying(player_type *player_ptr, MULTIPLY mult, const BIT_F
        };
 
        monster_race* r_ptr = &r_info[m_ptr->r_idx];
-       for (int i = 0; i < sizeof(slay_table) / sizeof(slay_table[0]); ++i)
+       for (size_t i = 0; i < sizeof(slay_table) / sizeof(slay_table[0]); ++i)
        {
                const struct slay_table_t* p = &slay_table[i];
 
@@ -612,7 +612,7 @@ static MULTIPLY mult_brand(player_type *player_ptr, MULTIPLY mult, const BIT_FLA
        };
 
        monster_race* r_ptr = &r_info[m_ptr->r_idx];
-       for (int i = 0; i < sizeof(brand_table) / sizeof(brand_table[0]); ++i)
+       for (size_t i = 0; i < sizeof(brand_table) / sizeof(brand_table[0]); ++i)
        {
                const struct brand_table_t* p = &brand_table[i];
 
index 0c23f19..bc64fbf 100644 (file)
@@ -57,7 +57,7 @@ static void show_file_aux_line(concptr str, int cy, concptr shower)
                cx += endcol;
                i += endcol;
 
-               if (endcol == showercol)
+               if (shower && endcol == showercol)
                {
                        int showerlen = strlen(shower);
                        Term_addstr(showerlen, TERM_YELLOW, &str[i]);
index 86df622..f09c4fa 100644 (file)
@@ -393,7 +393,8 @@ bool iskanji2(concptr s, int x)
 static bool is_ascii_str(concptr str)
 {
        for (;*str; str++) {
-               if (!(0x00 < *str && *str <= 0x7f))
+               int ch = *str;
+               if (!(0x00 < ch && ch <= 0x7f))
                        return FALSE;
        }
        return TRUE;
@@ -449,7 +450,7 @@ static void ms_to_jis_unicode(char* str)
 
                if ((*p & 0xe0) == 0xc0) subseq_num = 1;
                if ((*p & 0xf0) == 0xe0) {
-                       int i;
+                       size_t i;
                        for (i = 0; i < sizeof(ms_to_jis_unicode_conv) / sizeof(ms_to_jis_unicode_conv[0]); ++ i) {
                                const struct ms_to_jis_unicode_conv_t *c = &ms_to_jis_unicode_conv[i];
                                if (memcmp(p, c->from, 3) == 0) {
index 788d98b..6af86a4 100644 (file)
@@ -1040,7 +1040,8 @@ static errr Term_text_gcu(int x, int y, int n, byte a, concptr s)
 #endif
 
    /* Obtain a copy of the text */
-   for (i = 0; i < n; i++) text[i] = s[i];    text[n] = 0;
+   for (i = 0; i < n; i++) text[i] = s[i];
+   text[n] = 0;
 
    /* Move the cursor and dump the string */
    wmove(td->win, y, x);
@@ -1333,5 +1334,3 @@ errr init_gcu(int argc, char *argv[])
 
 
 #endif /* USE_GCU */
-
-
index dbf86be..ac0ab28 100644 (file)
@@ -17,6 +17,7 @@
 #include "init.h"
 #include "scores.h"
 #include "gameterm.h"
+#include "player/process-name.h"
 #include "chuukei.h"
 
 /*
index beca2f2..c820048 100644 (file)
@@ -177,9 +177,6 @@ void simple_monspell_message(player_type *target_ptr, MONSTER_IDX m_idx, MONSTER
  */
 void spell_RF4_SHRIEK(MONSTER_IDX m_idx, player_type *target_ptr, MONSTER_IDX t_idx, int TARGET_TYPE)
 {
-       // temporary unused
-       (target_ptr);
-
        simple_monspell_message(target_ptr, m_idx, t_idx,
                _("%^sがかん高い金切り声をあげた。", "%^s makes a high pitched shriek."),
                _("%^sが%sに向かって叫んだ。", "%^s shrieks at %s."),
index 30cd90c..0f33b63 100644 (file)
@@ -50,7 +50,7 @@ void process_player_name(player_type *creature_ptr, bool sf)
 
 #ifdef JP
                if (iskanji(c)) {
-                       if (k + 2 >= sizeof(creature_ptr->base_name) || !creature_ptr->name[i + 1])
+                       if (k + 2 >= (int)sizeof(creature_ptr->base_name) || !creature_ptr->name[i + 1])
                                break;
 
                        creature_ptr->base_name[k++] = c;
index 08fb7f5..0d56b7b 100644 (file)
@@ -74,7 +74,7 @@ static amuse_type amuse_info[] =
        { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
        { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
 
-       { 0, 0, 0 }
+       { 0, 0, 0, 0 }
 };
 
 /*!
index 8e37103..31e7230 100644 (file)
@@ -3766,10 +3766,10 @@ void print_path(player_type *player_ptr, POSITION y, POSITION x)
                if (panel_contains(ny, nx))
                {
                        TERM_COLOR a = default_color;
-                       char c;
+                       SYMBOL_CODE c;
 
                        TERM_COLOR ta = default_color;
-                       char tc = '*';
+                       SYMBOL_CODE tc = '*';
 
                        if (g_ptr->m_idx && floor_ptr->m_list[g_ptr->m_idx].ml)
                        {