From b87eb07f1d5fe0bc3923868e2609b966a9c68a44 Mon Sep 17 00:00:00 2001 From: dis- Date: Sat, 8 Sep 2012 05:55:39 +0000 Subject: [PATCH] add type casting for fprintf --- src/bldg.c | 72 +++++++++++++++++++++++++++++------------------------------ src/cmd3.c | 10 ++++----- src/cmd4.c | 8 +++---- src/mind.c | 2 +- src/spells2.c | 4 ++-- src/wizard1.c | 2 +- src/wizard2.c | 2 +- src/xtra1.c | 8 +++---- src/xtra2.c | 2 +- 9 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/bldg.c b/src/bldg.c index 36819edf4..73175860d 100644 --- a/src/bldg.c +++ b/src/bldg.c @@ -129,9 +129,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 } @@ -139,9 +139,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 } @@ -168,9 +168,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 } @@ -178,9 +178,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 } @@ -201,9 +201,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 } @@ -1270,9 +1270,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 @@ -1303,9 +1303,9 @@ msg_print(" else if (wager > maxbet) { #ifdef JP -msg_format("%ld¥´¡¼¥ë¥É¤À¤±¼õ¤±¤è¤¦¡£»Ä¤ê¤Ï¼è¤Ã¤È¤­¤Ê¡£", maxbet); +msg_format("%ld¥´¡¼¥ë¥É¤À¤±¼õ¤±¤è¤¦¡£»Ä¤ê¤Ï¼è¤Ã¤È¤­¤Ê¡£", (long int)maxbet); #else - msg_format("I'll take %ld gold of that. Keep the rest.", maxbet); + msg_format("I'll take %ld gold of that. Keep the rest.", (long int)maxbet); #endif wager = maxbet; @@ -1327,17 +1327,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); @@ -1606,9 +1606,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); @@ -1960,9 +1960,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); } @@ -2002,9 +2002,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 @@ -2035,9 +2035,9 @@ msg_print(" else if (wager > maxbet) { #ifdef JP -msg_format("%ld¥´¡¼¥ë¥É¤À¤±¼õ¤±¤è¤¦¡£»Ä¤ê¤Ï¼è¤Ã¤È¤­¤Ê¡£", maxbet); +msg_format("%ld¥´¡¼¥ë¥É¤À¤±¼õ¤±¤è¤¦¡£»Ä¤ê¤Ï¼è¤Ã¤È¤­¤Ê¡£", (long int)maxbet); #else - msg_format("I'll take %ld gold of that. Keep the rest.", maxbet); + msg_format("I'll take %ld gold of that. Keep the rest.",(long int) maxbet); #endif wager = maxbet; @@ -2238,9 +2238,9 @@ static bool kankin(void) if (get_check(buf)) { #ifdef JP - msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", 1000000L * o_ptr->number); + msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (long int)(1000000L * o_ptr->number)); #else - msg_format("You get %ldgp.", 1000000L * o_ptr->number); + msg_format("You get %ldgp.", (long int)(1000000L * o_ptr->number)); #endif p_ptr->au += 1000000L * o_ptr->number; p_ptr->redraw |= (PR_GOLD); @@ -2269,9 +2269,9 @@ static bool kankin(void) if (get_check(buf)) { #ifdef JP - msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", 200000L * o_ptr->number); + msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (long int)(200000L * o_ptr->number)); #else - msg_format("You get %ldgp.", 200000L * o_ptr->number); + msg_format("You get %ldgp.", (long int)(200000L * o_ptr->number)); #endif p_ptr->au += 200000L * o_ptr->number; p_ptr->redraw |= (PR_GOLD); @@ -2300,9 +2300,9 @@ static bool kankin(void) if (get_check(buf)) { #ifdef JP - msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", 100000L * o_ptr->number); + msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (long int)(100000L * o_ptr->number)); #else - msg_format("You get %ldgp.", 100000L * o_ptr->number); + msg_format("You get %ldgp.", (long int)(100000L * o_ptr->number)); #endif p_ptr->au += 100000L * o_ptr->number; p_ptr->redraw |= (PR_GOLD); @@ -2329,9 +2329,9 @@ static bool kankin(void) if (get_check(buf)) { #ifdef JP - msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (r_info[today_mon].level * 50 + 100) * o_ptr->number); + msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (long int)((r_info[today_mon].level * 50 + 100) * o_ptr->number)); #else - msg_format("You get %ldgp.", (r_info[today_mon].level * 50 + 100) * o_ptr->number); + msg_format("You get %ldgp.", (long int)((r_info[today_mon].level * 50 + 100) * o_ptr->number)); #endif p_ptr->au += (r_info[today_mon].level * 50 + 100) * o_ptr->number; p_ptr->redraw |= (PR_GOLD); @@ -2359,9 +2359,9 @@ static bool kankin(void) if (get_check(buf)) { #ifdef JP - msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (r_info[today_mon].level * 30 + 60) * o_ptr->number); + msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (long int)((r_info[today_mon].level * 30 + 60) * o_ptr->number)); #else - msg_format("You get %ldgp.", (r_info[today_mon].level * 30 + 60) * o_ptr->number); + msg_format("You get %ldgp.", (long int)((r_info[today_mon].level * 30 + 60) * o_ptr->number)); #endif p_ptr->au += (r_info[today_mon].level * 30 + 60) * o_ptr->number; p_ptr->redraw |= (PR_GOLD); diff --git a/src/cmd3.c b/src/cmd3.c index e8ce3b195..7c325acc4 100644 --- a/src/cmd3.c +++ b/src/cmd3.c @@ -46,8 +46,8 @@ 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) / weight_limit()); + (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) , + (long int)((p_ptr->total_weight * 100) / weight_limit())); #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), @@ -120,12 +120,12 @@ void do_cmd_equip(void) /* Build a prompt */ #ifdef JP sprintf(out_val, "ÁõÈ÷¡§ ¹ç·× %3d.%1d kg (¸Â³¦¤Î%ld%%) ¥³¥Þ¥ó¥É: ", - lbtokg1(p_ptr->total_weight) , lbtokg2(p_ptr->total_weight) , - (p_ptr->total_weight * 100) / weight_limit()); + (int)lbtokg1(p_ptr->total_weight) , (int)lbtokg2(p_ptr->total_weight) , + (long int)((p_ptr->total_weight * 100) / weight_limit())); #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) / weight_limit()); + (long int)((p_ptr->total_weight * 100) / weight_limit())); #endif diff --git a/src/cmd4.c b/src/cmd4.c index d56d23927..f388fb06e 100644 --- a/src/cmd4.c +++ b/src/cmd4.c @@ -7347,9 +7347,9 @@ static void do_cmd_knowledge_kill_count(void) #endif else #ifdef JP - fprintf(fff,"¤¢¤Ê¤¿¤Ï%ldÂΤÎŨ¤òÅݤ·¤Æ¤¤¤ë¡£\n\n", Total); + fprintf(fff,"¤¢¤Ê¤¿¤Ï%ldÂΤÎŨ¤òÅݤ·¤Æ¤¤¤ë¡£\n\n", (long int)Total); #else - fprintf(fff,"You have defeated %ld %s.\n\n", Total, (Total == 1) ? "enemy" : "enemies"); + fprintf(fff,"You have defeated %ld %s.\n\n", (long int)Total, (Total == 1) ? "enemy" : "enemies"); #endif } @@ -7429,10 +7429,10 @@ static void do_cmd_knowledge_kill_count(void) fprintf(fff,"----------------------------------------------\n"); #ifdef JP - fprintf(fff," ¹ç·×: %lu ÂΤòÅݤ·¤¿¡£\n", Total); + fprintf(fff," ¹ç·×: %lu ÂΤòÅݤ·¤¿¡£\n", (unsigned long int)Total); #else fprintf(fff," Total: %lu creature%s killed.\n", - Total, (Total == 1 ? "" : "s")); + (unsigned long int)Total, (Total == 1 ? "" : "s")); #endif diff --git a/src/mind.c b/src/mind.c index 062fb58a1..33e9921c5 100644 --- a/src/mind.c +++ b/src/mind.c @@ -322,7 +322,7 @@ void mindcraft_info(char *p, int use_mind, int power) case 11: sprintf(p, " %s%dd6", s_dam, plev / 2); break; case 12: sprintf(p, " %sd%d+%d", s_dam, plev * 3, plev * 3); break; #ifdef JP - case 13: sprintf(p, " ¹ÔÆ°:%ld²ó", (p_ptr->csp + 100-p_ptr->energy_need - 50)/100); break; + case 13: sprintf(p, " ¹ÔÆ°:%ld²ó", (long int)(p_ptr->csp + 100-p_ptr->energy_need - 50)/100); break; #else case 13: sprintf(p, " %ld acts.", (p_ptr->csp + 100-p_ptr->energy_need - 50)/100); break; #endif diff --git a/src/spells2.c b/src/spells2.c index 830cdd1ca..23597225f 100644 --- a/src/spells2.c +++ b/src/spells2.c @@ -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]; diff --git a/src/wizard1.c b/src/wizard1.c index f5414cfc3..050f80a94 100644 --- a/src/wizard1.c +++ b/src/wizard1.c @@ -2402,7 +2402,7 @@ static void spoil_mon_evol(cptr fname) #endif for (n = 1; r_ptr->next_exp; n++) { - fprintf(fff, "%*s-(%ld)-> ", n * 2, "", r_ptr->next_exp); + fprintf(fff, "%*s-(%ld)-> ", n * 2, "", (long int)r_ptr->next_exp); fprintf(fff, "[%d]: ", r_ptr->next_r_idx); r_ptr = &r_info[r_ptr->next_r_idx]; #ifdef JP diff --git a/src/wizard2.c b/src/wizard2.c index 0a01936cb..31a7b2955 100644 --- a/src/wizard2.c +++ b/src/wizard2.c @@ -1040,7 +1040,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); diff --git a/src/xtra1.c b/src/xtra1.c index 12ec3fa47..39e13b660 100644 --- a/src/xtra1.c +++ b/src/xtra1.c @@ -932,7 +932,7 @@ static void prt_hp(void) put_str("HP", ROW_CURHP, COL_CURHP); /* ¸½ºß¤Î¥Ò¥Ã¥È¥Ý¥¤¥ó¥È */ - sprintf(tmp, "%4ld", p_ptr->chp); + sprintf(tmp, "%4ld", (long int)p_ptr->chp); if (p_ptr->chp >= p_ptr->mhp) { @@ -953,7 +953,7 @@ static void prt_hp(void) put_str( "/", ROW_CURHP, COL_CURHP + 7 ); /* ºÇÂç¥Ò¥Ã¥È¥Ý¥¤¥ó¥È */ - sprintf(tmp, "%4ld", p_ptr->mhp); + sprintf(tmp, "%4ld", (long int)p_ptr->mhp); color = TERM_L_GREEN; c_put_str(color, tmp, ROW_CURHP, COL_CURHP + 8 ); @@ -983,7 +983,7 @@ static void prt_sp(void) #endif /* ¸½ºß¤Î¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È */ - sprintf(tmp, "%4ld", p_ptr->csp); + sprintf(tmp, "%4ld", (long int)p_ptr->csp); if (p_ptr->csp >= p_ptr->msp) { @@ -1004,7 +1004,7 @@ static void prt_sp(void) put_str( "/", ROW_CURSP, COL_CURSP + 7 ); /* ºÇÂç¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È */ - sprintf(tmp, "%4ld", p_ptr->msp); + sprintf(tmp, "%4ld", (long int)p_ptr->msp); color = TERM_L_GREEN; c_put_str(color, tmp, ROW_CURSP, COL_CURSP + 8); diff --git a/src/xtra2.c b/src/xtra2.c index 82064683f..246306bc9 100644 --- a/src/xtra2.c +++ b/src/xtra2.c @@ -3088,7 +3088,7 @@ static void evaluate_monster_exp(char *buf, monster_type *m_ptr) num = MIN(999, exp_adv_frac); /* Display the number */ - sprintf(buf,"%03ld", num); + sprintf(buf,"%03ld", (long int)num); } -- 2.11.0