OSDN Git Service

Avoided compiler warnings about a 32-bit integer being passed to a %ld or %lu format...
authorEric Branlund <ebranlund@fastmail.com>
Sat, 4 Apr 2020 19:13:07 +0000 (12:13 -0700)
committerEric Branlund <ebranlund@fastmail.com>
Sat, 4 Apr 2020 19:13:07 +0000 (12:13 -0700)
src/bldg.c
src/cmd3.c
src/cmd4.c
src/files.c
src/spells2.c
src/wizard1.c
src/wizard2.c

index ef40e4f..99effc2 100644 (file)
@@ -132,9 +132,9 @@ static void show_building(building_type* bldg)
                                {
                                        action_color = TERM_YELLOW;
 #ifdef JP
-sprintf(buff, "($%ld)", bldg->member_costs[i]);
+                                       sprintf(buff, "($%ld)", (long int)bldg->member_costs[i]);
 #else
-                                       sprintf(buff, "(%ldgp)", bldg->member_costs[i]);
+                                       sprintf(buff, "(%ldgp)", (long int)bldg->member_costs[i]);
 #endif
 
                                }
@@ -142,9 +142,9 @@ sprintf(buff, "($%ld)", bldg->member_costs[i]);
                                {
                                        action_color = TERM_YELLOW;
 #ifdef JP
-sprintf(buff, "($%ld)", bldg->other_costs[i]);
+                                       sprintf(buff, "($%ld)", (long int)bldg->other_costs[i]);
 #else
-                                       sprintf(buff, "(%ldgp)", bldg->other_costs[i]);
+                                       sprintf(buff, "(%ldgp)", (long int)bldg->other_costs[i]);
 #endif
 
                                }
@@ -171,9 +171,9 @@ strcpy(buff, "(
                                {
                                        action_color = TERM_YELLOW;
 #ifdef JP
-sprintf(buff, "($%ld)", bldg->member_costs[i]);
+                                       sprintf(buff, "($%ld)", (long int)bldg->member_costs[i]);
 #else
-                                       sprintf(buff, "(%ldgp)", bldg->member_costs[i]);
+                                       sprintf(buff, "(%ldgp)", (long int)bldg->member_costs[i]);
 #endif
 
                                }
@@ -181,9 +181,9 @@ sprintf(buff, "($%ld)", bldg->member_costs[i]);
                                {
                                        action_color = TERM_YELLOW;
 #ifdef JP
-sprintf(buff, "($%ld)", bldg->other_costs[i]);
+                                       sprintf(buff, "($%ld)", (long int)bldg->other_costs[i]);
 #else
-                                       sprintf(buff, "(%ldgp)", bldg->other_costs[i]);
+                                       sprintf(buff, "(%ldgp)", (long int)bldg->other_costs[i]);
 #endif
 
                                }
@@ -204,9 +204,9 @@ strcpy(buff, "(
                                {
                                        action_color = TERM_YELLOW;
 #ifdef JP
-sprintf(buff, "($%ld)", bldg->member_costs[i]);
+                                       sprintf(buff, "($%ld)", (long int)bldg->member_costs[i]);
 #else
-                                       sprintf(buff, "(%ldgp)", bldg->member_costs[i]);
+                                       sprintf(buff, "(%ldgp)", (long int)bldg->member_costs[i]);
 #endif
 
                                }
@@ -1267,9 +1267,9 @@ static bool gamble_comm(int cmd)
                /* Get the wager */
                strcpy(out_val, "");
 #ifdef JP
-sprintf(tmp_str,"ÅÒ¤±¶â (1-%ld)¡©", maxbet);
+               sprintf(tmp_str,"ÅÒ¤±¶â (1-%ld)¡©", (long int)maxbet);
 #else
-               sprintf(tmp_str,"Your wager (1-%ld) ? ", maxbet);
+               sprintf(tmp_str,"Your wager (1-%ld) ? ", (long int)maxbet);
 #endif
 
 
@@ -1324,17 +1324,17 @@ msg_print("
                        oldgold = p_ptr->au;
 
 #ifdef JP
-sprintf(tmp_str, "¥²¡¼¥àÁ°¤Î½ê»ý¶â: %9ld", oldgold);
+                       sprintf(tmp_str, "¥²¡¼¥àÁ°¤Î½ê»ý¶â: %9ld", (long int)oldgold);
 #else
-                       sprintf(tmp_str, "Gold before game: %9ld", oldgold);
+                       sprintf(tmp_str, "Gold before game: %9ld", (long int)oldgold);
 #endif
 
                        prt(tmp_str, 20, 2);
 
 #ifdef JP
-sprintf(tmp_str, "¸½ºß¤Î³Ý¤±¶â:     %9ld", wager);
+                       sprintf(tmp_str, "¸½ºß¤Î³Ý¤±¶â:     %9ld", (long int)wager);
 #else
-                       sprintf(tmp_str, "Current Wager:    %9ld", wager);
+                       sprintf(tmp_str, "Current Wager:    %9ld", (long int)wager);
 #endif
 
                        prt(tmp_str, 21, 2);
@@ -1603,9 +1603,9 @@ prt("
                                        prt("", 17, 37);
                                }
 #ifdef JP
-sprintf(tmp_str, "¸½ºß¤Î½ê»ý¶â:     %9ld", p_ptr->au);
+                               sprintf(tmp_str, "¸½ºß¤Î½ê»ý¶â:     %9ld", (long int)p_ptr->au);
 #else
-                               sprintf(tmp_str, "Current Gold:     %9ld", p_ptr->au);
+                               sprintf(tmp_str, "Current Gold:     %9ld", (long int)p_ptr->au);
 #endif
 
                                prt(tmp_str, 22, 2);
@@ -1957,9 +1957,9 @@ static bool kakutoujou(void)
                        monster_race *r_ptr = &r_info[battle_mon[i]];
 
 #ifdef JP
-                       sprintf(buf,"%d) %-58s  %4ld.%02ldÇÜ", i+1, format("%s%s",r_name + r_ptr->name, (r_ptr->flags1 & RF1_UNIQUE) ? "¤â¤É¤­" : "      "), mon_odds[i]/100, mon_odds[i]%100);
+                       sprintf(buf,"%d) %-58s  %4ld.%02ldÇÜ", i+1, format("%s%s",r_name + r_ptr->name, (r_ptr->flags1 & RF1_UNIQUE) ? "¤â¤É¤­" : "      "), (long int)mon_odds[i]/100, (long int)mon_odds[i]%100);
 #else
-                       sprintf(buf,"%d) %-58s  %4ld.%02ld", i+1, format("%s%s", (r_ptr->flags1 & RF1_UNIQUE) ? "Fake " : "", r_name + r_ptr->name), mon_odds[i]/100, mon_odds[i]%100);
+                       sprintf(buf,"%d) %-58s  %4ld.%02ld", i+1, format("%s%s", (r_ptr->flags1 & RF1_UNIQUE) ? "Fake " : "", r_name + r_ptr->name), (long int)mon_odds[i]/100, (long int)mon_odds[i]%100);
 #endif
                        prt(buf, 5+i, 1);
                }
@@ -1999,9 +1999,9 @@ static bool kakutoujou(void)
                /* Get the wager */
                strcpy(out_val, "");
 #ifdef JP
-sprintf(tmp_str,"ÅÒ¤±¶â (1-%ld)¡©", maxbet);
+               sprintf(tmp_str,"ÅÒ¤±¶â (1-%ld)¡©", (long int)maxbet);
 #else
-               sprintf(tmp_str,"Your wager (1-%ld) ? ", maxbet);
+               sprintf(tmp_str,"Your wager (1-%ld) ? ", (long int)maxbet);
 #endif
 
 
index e9b19f9..ec784a5 100644 (file)
@@ -47,12 +47,11 @@ void do_cmd_inven(void)
 #ifdef JP
        sprintf(out_val, "»ý¤Áʪ¡§ ¹ç·× %3d.%1d kg (¸Â³¦¤Î%ld%%) ¥³¥Þ¥ó¥É: ",
            lbtokg1(p_ptr->total_weight) , lbtokg2(p_ptr->total_weight) ,
-           (p_ptr->total_weight * 100) / ((adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) 
-/ 2));
+           ((long int)p_ptr->total_weight * 100) / ((adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) / 2));
 #else
        sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
            (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
-           (p_ptr->total_weight * 100) / ((adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) / 2));
+           ((long int)p_ptr->total_weight * 100) / ((adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) / 2));
 #endif
 
 
@@ -122,12 +121,11 @@ void do_cmd_equip(void)
 #ifdef JP
        sprintf(out_val, "ÁõÈ÷¡§ ¹ç·× %3d.%1d kg (¸Â³¦¤Î%ld%%) ¥³¥Þ¥ó¥É: ",
            lbtokg1(p_ptr->total_weight) , lbtokg2(p_ptr->total_weight) ,
-           (p_ptr->total_weight * 100) / ((adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) 
-/ 2));
+           ((long int)p_ptr->total_weight * 100) / ((adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) / 2));
 #else
        sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
            (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
-           (p_ptr->total_weight * 100) / ((adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) / 2));
+           ((long int)p_ptr->total_weight * 100) / ((adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) / 2));
 #endif
 
 
index 9fa04a3..d6a9606 100644 (file)
@@ -7021,7 +7021,7 @@ static void do_cmd_knowledge_kill_count(void)
 
        char file_name[1024];
 
-       s32b Total = 0;
+       long Total = 0;
 
 
        /* Open a new file */
index 77422cf..5b5a8e2 100644 (file)
@@ -4546,7 +4546,7 @@ errr make_character_dump(FILE *fff)
        /* Monsters slain */
        {
                int k;
-               s32b Total = 0;
+               long Total = 0;
 
                for (k = 1; k < max_r_idx; k++)
                {
@@ -4586,9 +4586,9 @@ errr make_character_dump(FILE *fff)
 
                else
 #ifdef JP
-                       fprintf(fff,"\n %lu ÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", Total);
+                       fprintf(fff,"\n %ld ÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", Total);
 #else
-                       fprintf(fff,"\n You have defeated %lu enemies.\n", Total);
+                       fprintf(fff,"\n You have defeated %ld enemies.\n", Total);
 #endif
 
        }
index e2b71e5..ac3fb0f 100644 (file)
@@ -109,9 +109,9 @@ sprintf(Dummy, "
        info[i++] = "";
 
 #ifdef JP
-       sprintf(Dummy, "¸½ºß¤Î°À­ : %s(%ld)", your_alignment(), p_ptr->align);
+       sprintf(Dummy, "¸½ºß¤Î°À­ : %s(%ld)", your_alignment(), (long int)p_ptr->align);
 #else
-       sprintf(Dummy, "Your alighnment : %s(%ld)", your_alignment(), p_ptr->align);
+       sprintf(Dummy, "Your alighnment : %s(%ld)", your_alignment(), (long int)p_ptr->align);
 #endif
        strcpy(buf[1], Dummy);
        info[i++] = buf[1];
index 48e0ea4..131245e 100644 (file)
@@ -1316,11 +1316,11 @@ static void analyze_misc(object_type *o_ptr, char *misc_desc)
 #ifdef JP
        sprintf(misc_desc, "¥ì¥Ù¥ë %u, ´õ¾¯ÅÙ %u, %d.%d kg, ¡ð%ld",
                a_ptr->level, a_ptr->rarity,
-               lbtokg1(a_ptr->weight), lbtokg2(a_ptr->weight), a_ptr->cost);
+               lbtokg1(a_ptr->weight), lbtokg2(a_ptr->weight), (long int)a_ptr->cost);
 #else
        sprintf(misc_desc, "Level %u, Rarity %u, %d.%d lbs, %ld Gold",
                a_ptr->level, a_ptr->rarity,
-               a_ptr->weight / 10, a_ptr->weight % 10, a_ptr->cost);
+               a_ptr->weight / 10, a_ptr->weight % 10, (long int)a_ptr->cost);
 #endif
 }
 
index dc6d8e2..d6239c4 100644 (file)
@@ -1049,7 +1049,7 @@ static void wiz_statistics(object_type *o_ptr)
                        break;
                }
 
-               sprintf(tmp_val, "%ld", test_roll);
+               sprintf(tmp_val, "%ld", (long int)test_roll);
                if (get_string(p, tmp_val, 10)) test_roll = atol(tmp_val);
                test_roll = MAX(1, test_roll);