diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-04 22:05:04 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-04 22:05:04 +0000 |
commit | 0376e364459cc52fd417eeda5d071a012bb10ee7 (patch) | |
tree | 470f61a8620dc1922cca95a7bb56fcac7b518236 /base | |
parent | a7552342506985bc90b33ab54cb62df1bfb190a6 (diff) | |
download | chromium_src-0376e364459cc52fd417eeda5d071a012bb10ee7.zip chromium_src-0376e364459cc52fd417eeda5d071a012bb10ee7.tar.gz chromium_src-0376e364459cc52fd417eeda5d071a012bb10ee7.tar.bz2 |
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
Diffstat (limited to 'base')
-rw-r--r-- | base/string_util.cc | 11 |
1 files changed, 6 insertions, 5 deletions
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<OutStringType>::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<int>(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<ReplacementOffset>::const_iterator i = r_offsets.begin(); - i != r_offsets.end(); ++i) { + i != r_offsets.end(); ++i) { offsets->push_back(i->offset); } } |