From 0376e364459cc52fd417eeda5d071a012bb10ee7 Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Mon, 4 Oct 2010 22:05:04 +0000 Subject: Add DCHECK for misused string resources. When replacing a placeholder in a localized string, make sure the correct number of placeholders were found (i.e. the same number of strings that the calling code passed). BUG=none TEST=running/testing the browser in debug doesn't cause errors Review URL: http://codereview.chromium.org/3396025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61420 0039d316-1c4b-4281-b951-d872f2087c98 --- base/string_util.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'base') diff --git a/base/string_util.cc b/base/string_util.cc index c7268dc..83ba148 100644 --- a/base/string_util.cc +++ b/base/string_util.cc @@ -902,7 +902,7 @@ OutStringType DoReplaceStringPlaceholders(const FormatStringType& format_string, size_t sub_length = 0; for (typename std::vector::const_iterator iter = subst.begin(); iter != subst.end(); ++iter) { - sub_length += (*iter).length(); + sub_length += iter->length(); } OutStringType formatted; @@ -927,9 +927,10 @@ OutStringType DoReplaceStringPlaceholders(const FormatStringType& format_string, ReplacementOffset r_offset(index, static_cast(formatted.size())); r_offsets.insert(std::lower_bound(r_offsets.begin(), - r_offsets.end(), r_offset, - &CompareParameter), - r_offset); + r_offsets.end(), + r_offset, + &CompareParameter), + r_offset); } if (index < substitutions) formatted.append(subst.at(index)); @@ -941,7 +942,7 @@ OutStringType DoReplaceStringPlaceholders(const FormatStringType& format_string, } if (offsets) { for (std::vector::const_iterator i = r_offsets.begin(); - i != r_offsets.end(); ++i) { + i != r_offsets.end(); ++i) { offsets->push_back(i->offset); } } -- cgit v1.1