From 1ab177757bec9eb28482785f75fd8a4fb8a1313c Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Thu, 17 Dec 2009 12:48:02 +0100 Subject: Replace static snprintf() with make_sprintf() where the result is immediately cast to std::string. --- crawl-ref/source/stash.cc | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'crawl-ref/source/stash.cc') diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index cb3a461b61..147dbc67d8 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -887,21 +887,15 @@ void ShopInfo::add_item(const item_def &sitem, unsigned price) std::string ShopInfo::shop_item_name(const shop_item &si) const { - char shopitem[ITEMNAME_SIZE * 2]; - const unsigned long oldflags = si.item.flags; if (shoptype_identifies_stock(static_cast(this->shoptype))) const_cast(si).item.flags |= ISFLAG_IDENT_MASK; - const std::string itemname = Stash::stash_item_name(si.item); - snprintf(shopitem, sizeof shopitem, "%s (%u gold)", - itemname.c_str(), si.price); - if (oldflags != si.item.flags) const_cast(si).item.flags = oldflags; - return shopitem; + return make_stringf("%s (%u gold)", Stash::stash_item_name(si.item).c_str(), si.price); } std::string ShopInfo::shop_item_desc(const shop_item &si) const @@ -1871,12 +1865,9 @@ void StashSearchMenu::draw_title() title->quantity > 1? "es" : "", sort_style); - char buf[200]; - snprintf(buf, 200, + draw_title_suffix(formatted_string::parse_string(make_stringf( " [a-z: %s ?/!: change action /: change sort]", - menu_action == ACT_EXECUTE ? "travel" : "examine"); - - draw_title_suffix(formatted_string::parse_string(buf), false); + menu_action == ACT_EXECUTE ? "travel" : "examine")), false); } } -- cgit v1.2.3-54-g00ecf