• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisãoa3acbf8a2cccd7e706f7c336964eaa79506a443e (tree)
Hora2020-04-20 23:51:20
AutorHabu <habu@user...>
CommiterHabu

Mensagem de Log

[fix] gccの警告に従い修正

以下の細々とした警告に対応:

- switch-case文でbreakが無い(その前の関数の中でプログラムが終了するが、一応付加しておく)
- 他ファイルに移した未使用のstatic関数
- 変数の型の誤り
- 符号付き変数と符号無し変数の比較
- strlenにNULLが渡される可能性
- 未使用変数の存在
- 構造体の初期化メンバの不足
- for と同じ行に2つ以上の文がある

Mudança Sumário

Diff

--- a/src/birth.c
+++ b/src/birth.c
@@ -3147,6 +3147,7 @@ static bool get_stat_limits(player_type *creature_ptr)
31473147 switch (c) {
31483148 case 'Q':
31493149 birth_quit();
3150+ break;
31503151 case 'S':
31513152 return FALSE;
31523153 case ESCAPE:
@@ -3385,6 +3386,7 @@ static bool get_chara_limits(player_type *creature_ptr)
33853386 switch (c) {
33863387 case 'Q':
33873388 birth_quit();
3389+ break;
33883390 case 'S':
33893391 return FALSE;
33903392 case ESCAPE:
--- a/src/cmd/cmd-dump.c
+++ b/src/cmd/cmd-dump.c
@@ -82,225 +82,6 @@ static SYMBOL_CODE char_idx_feat[F_LIT_MAX];
8282 // Encode the screen colors
8383 static char hack[17] = "dwsorgbuDWvyRGBU";
8484
85-/*!
86- * @brief prefファイルを選択して処理する /
87- * Ask for a "user pref line" and process it
88- * @brief prf出力内容を消去する /
89- * Remove old lines automatically generated before.
90- * @param orig_file 消去を行うファイル名
91- */
92-static void remove_auto_dump(concptr orig_file, concptr auto_dump_mark)
93-{
94- FILE *tmp_fff, *orig_fff;
95- char tmp_file[1024];
96- char buf[1024];
97- bool between_mark = FALSE;
98- bool changed = FALSE;
99- int line_num = 0;
100- long header_location = 0;
101- char header_mark_str[80];
102- char footer_mark_str[80];
103-
104- sprintf(header_mark_str, auto_dump_header, auto_dump_mark);
105- sprintf(footer_mark_str, auto_dump_footer, auto_dump_mark);
106- size_t mark_len = strlen(footer_mark_str);
107- orig_fff = my_fopen(orig_file, "r");
108- if (!orig_fff) return;
109-
110- tmp_fff = my_fopen_temp(tmp_file, 1024);
111- if (!tmp_fff)
112- {
113- msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), tmp_file);
114- msg_print(NULL);
115- return;
116- }
117-
118- while (TRUE)
119- {
120- if (my_fgets(orig_fff, buf, sizeof(buf)))
121- {
122- if (between_mark)
123- {
124- fseek(orig_fff, header_location, SEEK_SET);
125- between_mark = FALSE;
126- continue;
127- }
128- else
129- {
130- break;
131- }
132- }
133-
134- if (!between_mark)
135- {
136- if (!strcmp(buf, header_mark_str))
137- {
138- header_location = ftell(orig_fff);
139- line_num = 0;
140- between_mark = TRUE;
141- changed = TRUE;
142- }
143- else
144- {
145- fprintf(tmp_fff, "%s\n", buf);
146- }
147-
148- continue;
149- }
150-
151- if (!strncmp(buf, footer_mark_str, mark_len))
152- {
153- int tmp;
154- if (!sscanf(buf + mark_len, " (%d)", &tmp)
155- || tmp != line_num)
156- {
157- fseek(orig_fff, header_location, SEEK_SET);
158- }
159-
160- between_mark = FALSE;
161- continue;
162- }
163-
164- line_num++;
165- }
166-
167- my_fclose(orig_fff);
168- my_fclose(tmp_fff);
169-
170- if (changed)
171- {
172- tmp_fff = my_fopen(tmp_file, "r");
173- orig_fff = my_fopen(orig_file, "w");
174- while (!my_fgets(tmp_fff, buf, sizeof(buf)))
175- fprintf(orig_fff, "%s\n", buf);
176-
177- my_fclose(orig_fff);
178- my_fclose(tmp_fff);
179- }
180-
181- fd_kill(tmp_file);
182-}
183-
184-
185-#ifdef JP
186-#else
187-/*!
188- * @brief Return suffix of ordinal number
189- * @param num number
190- * @return pointer of suffix string.
191- */
192-concptr get_ordinal_number_suffix(int num)
193-{
194- num = ABS(num) % 100;
195- switch (num % 10)
196- {
197- case 1:
198- return (num == 11) ? "th" : "st";
199- case 2:
200- return (num == 12) ? "th" : "nd";
201- case 3:
202- return (num == 13) ? "th" : "rd";
203- default:
204- return "th";
205- }
206-}
207-#endif
208-
209-
210-/*!
211- * @brief 日記のタイトル表記と内容出力
212- * @param creature_ptr プレーヤーへの参照ポインタ
213- * @return なし
214- */
215-static void display_diary(player_type *creature_ptr)
216-{
217- char diary_title[256];
218- GAME_TEXT file_name[MAX_NLEN];
219- char buf[1024];
220- char tmp[80];
221- sprintf(file_name, _("playrecord-%s.txt", "playrec-%s.txt"), savefile_base);
222- path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
223-
224- if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_SAMURAI || creature_ptr->pclass == CLASS_BERSERKER)
225- strcpy(tmp, subtitle[randint0(MAX_SUBTITLE - 1)]);
226- else if (IS_WIZARD_CLASS(creature_ptr))
227- strcpy(tmp, subtitle[randint0(MAX_SUBTITLE - 1) + 1]);
228- else strcpy(tmp, subtitle[randint0(MAX_SUBTITLE - 2) + 1]);
229-
230-#ifdef JP
231- sprintf(diary_title, "「%s%s%sの伝説 -%s-」", ap_ptr->title, ap_ptr->no ? "の" : "", creature_ptr->name, tmp);
232-#else
233- sprintf(diary_title, "Legend of %s %s '%s'", ap_ptr->title, creature_ptr->name, tmp);
234-#endif
235-
236- (void)show_file(creature_ptr, FALSE, buf, diary_title, -1, 0);
237-}
238-
239-
240-/*!
241- * @brief 日記に任意の内容を表記するコマンドのメインルーチン /
242- * @return なし
243- */
244-static void add_diary_note(player_type *creature_ptr)
245-{
246- char tmp[80] = "\0";
247- char bunshou[80] = "\0";
248- if (get_string(_("内容: ", "diary note: "), tmp, 79))
249- {
250- strcpy(bunshou, tmp);
251- exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, bunshou);
252- }
253-}
254-
255-/*!
256- * @brief 最後に取得したアイテムの情報を日記に追加するメインルーチン /
257- * @return なし
258- */
259-static void do_cmd_last_get(player_type *creaute_ptr)
260-{
261- if (record_o_name[0] == '\0') return;
262-
263- char buf[256];
264- sprintf(buf, _("%sの入手を記録します。", "Do you really want to record getting %s? "), record_o_name);
265- if (!get_check(buf)) return;
266-
267- GAME_TURN turn_tmp = current_world_ptr->game_turn;
268- current_world_ptr->game_turn = record_turn;
269- sprintf(buf, _("%sを手に入れた。", "discovered %s."), record_o_name);
270- exe_write_diary(creaute_ptr, DIARY_DESCRIPTION, 0, buf);
271- current_world_ptr->game_turn = turn_tmp;
272-}
273-
274-
275-/*!
276- * @brief ファイル中の全日記記録を消去する /
277- * @return なし
278- */
279-static void do_cmd_erase_diary(void)
280-{
281- GAME_TEXT file_name[MAX_NLEN];
282- char buf[256];
283- FILE *fff = NULL;
284-
285- if (!get_check(_("本当に記録を消去しますか?", "Do you really want to delete all your record? "))) return;
286- sprintf(file_name, _("playrecord-%s.txt", "playrec-%s.txt"), savefile_base);
287- path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
288- fd_kill(buf);
289-
290- fff = my_fopen(buf, "w");
291- if (fff)
292- {
293- my_fclose(fff);
294- msg_format(_("記録を消去しました。", "deleted record."));
295- }
296- else
297- {
298- msg_format(_("%s の消去に失敗しました。", "failed to delete %s."), buf);
299- }
300-
301- msg_print(NULL);
302-}
303-
30485
30586 /*!
30687 * @brief 画面を再描画するコマンドのメインルーチン
@@ -1849,8 +1630,8 @@ static void display_visual_list(int col, int row, int height, int width, TERM_CO
18491630 TERM_LEN y = row + i;
18501631 if (use_bigtile) x += j;
18511632
1852- TERM_COLOR ia = attr_top + i;
1853- SYMBOL_CODE ic = char_left + j;
1633+ int ia = attr_top + i;
1634+ int ic = char_left + j;
18541635 if (ia > 0x7f || ic > 0xff || ic < ' ' ||
18551636 (!use_graphics && ic > 0x7f))
18561637 continue;
@@ -1982,7 +1763,7 @@ static bool visual_mode_command(char ch, bool *visual_list_ptr,
19821763 if ((a == 0) && (ddy[d] < 0)) d = 0;
19831764 if ((c == 0) && (ddx[d] < 0)) d = 0;
19841765 if ((a == 0x7f) && (ddy[d] > 0)) d = 0;
1985- if ((c == 0xff) && (ddx[d] > 0)) d = 0;
1766+ if (((byte)c == 0xff) && (ddx[d] > 0)) d = 0;
19861767
19871768 a += (TERM_COLOR)ddy[d];
19881769 c += (SYMBOL_CODE)ddx[d];
--- a/src/cmd/cmd-smith.c
+++ b/src/cmd/cmd-smith.c
@@ -517,7 +517,7 @@ static void display_essence(player_type *creature_ptr)
517517 static void drain_essence(player_type *creature_ptr)
518518 {
519519 int drain_value[sizeof(creature_ptr->magic_num1) / sizeof(s32b)];
520- int i;
520+ size_t i;
521521 OBJECT_IDX item;
522522 int dec = 4;
523523 bool observe = FALSE;
--- a/src/combat/melee1.c
+++ b/src/combat/melee1.c
@@ -569,7 +569,7 @@ static MULTIPLY mult_slaying(player_type *player_ptr, MULTIPLY mult, const BIT_F
569569 };
570570
571571 monster_race* r_ptr = &r_info[m_ptr->r_idx];
572- for (int i = 0; i < sizeof(slay_table) / sizeof(slay_table[0]); ++i)
572+ for (size_t i = 0; i < sizeof(slay_table) / sizeof(slay_table[0]); ++i)
573573 {
574574 const struct slay_table_t* p = &slay_table[i];
575575
@@ -612,7 +612,7 @@ static MULTIPLY mult_brand(player_type *player_ptr, MULTIPLY mult, const BIT_FLA
612612 };
613613
614614 monster_race* r_ptr = &r_info[m_ptr->r_idx];
615- for (int i = 0; i < sizeof(brand_table) / sizeof(brand_table[0]); ++i)
615+ for (size_t i = 0; i < sizeof(brand_table) / sizeof(brand_table[0]); ++i)
616616 {
617617 const struct brand_table_t* p = &brand_table[i];
618618
--- a/src/core/show-file.c
+++ b/src/core/show-file.c
@@ -57,7 +57,7 @@ static void show_file_aux_line(concptr str, int cy, concptr shower)
5757 cx += endcol;
5858 i += endcol;
5959
60- if (endcol == showercol)
60+ if (shower && endcol == showercol)
6161 {
6262 int showerlen = strlen(shower);
6363 Term_addstr(showerlen, TERM_YELLOW, &str[i]);
--- a/src/japanese.c
+++ b/src/japanese.c
@@ -393,7 +393,8 @@ bool iskanji2(concptr s, int x)
393393 static bool is_ascii_str(concptr str)
394394 {
395395 for (;*str; str++) {
396- if (!(0x00 < *str && *str <= 0x7f))
396+ int ch = *str;
397+ if (!(0x00 < ch && ch <= 0x7f))
397398 return FALSE;
398399 }
399400 return TRUE;
@@ -449,7 +450,7 @@ static void ms_to_jis_unicode(char* str)
449450
450451 if ((*p & 0xe0) == 0xc0) subseq_num = 1;
451452 if ((*p & 0xf0) == 0xe0) {
452- int i;
453+ size_t i;
453454 for (i = 0; i < sizeof(ms_to_jis_unicode_conv) / sizeof(ms_to_jis_unicode_conv[0]); ++ i) {
454455 const struct ms_to_jis_unicode_conv_t *c = &ms_to_jis_unicode_conv[i];
455456 if (memcmp(p, c->from, 3) == 0) {
--- a/src/main-gcu.c
+++ b/src/main-gcu.c
@@ -1040,7 +1040,8 @@ static errr Term_text_gcu(int x, int y, int n, byte a, concptr s)
10401040 #endif
10411041
10421042 /* Obtain a copy of the text */
1043- for (i = 0; i < n; i++) text[i] = s[i]; text[n] = 0;
1043+ for (i = 0; i < n; i++) text[i] = s[i];
1044+ text[n] = 0;
10441045
10451046 /* Move the cursor and dump the string */
10461047 wmove(td->win, y, x);
@@ -1333,5 +1334,3 @@ errr init_gcu(int argc, char *argv[])
13331334
13341335
13351336 #endif /* USE_GCU */
1336-
1337-
--- a/src/main.c
+++ b/src/main.c
@@ -17,6 +17,7 @@
1717 #include "init.h"
1818 #include "scores.h"
1919 #include "gameterm.h"
20+#include "player/process-name.h"
2021 #include "chuukei.h"
2122
2223 /*
--- a/src/mspells4.c
+++ b/src/mspells4.c
@@ -177,9 +177,6 @@ void simple_monspell_message(player_type *target_ptr, MONSTER_IDX m_idx, MONSTER
177177 */
178178 void spell_RF4_SHRIEK(MONSTER_IDX m_idx, player_type *target_ptr, MONSTER_IDX t_idx, int TARGET_TYPE)
179179 {
180- // temporary unused
181- (target_ptr);
182-
183180 simple_monspell_message(target_ptr, m_idx, t_idx,
184181 _("%^sがかん高い金切り声をあげた。", "%^s makes a high pitched shriek."),
185182 _("%^sが%sに向かって叫んだ。", "%^s shrieks at %s."),
--- a/src/player/process-name.c
+++ b/src/player/process-name.c
@@ -50,7 +50,7 @@ void process_player_name(player_type *creature_ptr, bool sf)
5050
5151 #ifdef JP
5252 if (iskanji(c)) {
53- if (k + 2 >= sizeof(creature_ptr->base_name) || !creature_ptr->name[i + 1])
53+ if (k + 2 >= (int)sizeof(creature_ptr->base_name) || !creature_ptr->name[i + 1])
5454 break;
5555
5656 creature_ptr->base_name[k++] = c;
--- a/src/spells-object.c
+++ b/src/spells-object.c
@@ -74,7 +74,7 @@ static amuse_type amuse_info[] =
7474 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
7575 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
7676
77- { 0, 0, 0 }
77+ { 0, 0, 0, 0 }
7878 };
7979
8080 /*!
--- a/src/view-mainwindow.c
+++ b/src/view-mainwindow.c
@@ -3766,10 +3766,10 @@ void print_path(player_type *player_ptr, POSITION y, POSITION x)
37663766 if (panel_contains(ny, nx))
37673767 {
37683768 TERM_COLOR a = default_color;
3769- char c;
3769+ SYMBOL_CODE c;
37703770
37713771 TERM_COLOR ta = default_color;
3772- char tc = '*';
3772+ SYMBOL_CODE tc = '*';
37733773
37743774 if (g_ptr->m_idx && floor_ptr->m_list[g_ptr->m_idx].ml)
37753775 {
Show on old repository browser