summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2015-12-21 17:17:34 +0100
committerEthan Yonker <dees_troy@teamw.in>2015-12-21 17:18:03 +0100
commitab7955d87427b93ca6f64a8127d854ed96dcc9b0 (patch)
treeca0b2ea8b86cbd64ec6cf31d2756157fa48e3a57
parenttwmsg: fix notfound detection (diff)
downloadandroid_bootable_recovery-ab7955d87427b93ca6f64a8127d854ed96dcc9b0.tar
android_bootable_recovery-ab7955d87427b93ca6f64a8127d854ed96dcc9b0.tar.gz
android_bootable_recovery-ab7955d87427b93ca6f64a8127d854ed96dcc9b0.tar.bz2
android_bootable_recovery-ab7955d87427b93ca6f64a8127d854ed96dcc9b0.tar.lz
android_bootable_recovery-ab7955d87427b93ca6f64a8127d854ed96dcc9b0.tar.xz
android_bootable_recovery-ab7955d87427b93ca6f64a8127d854ed96dcc9b0.tar.zst
android_bootable_recovery-ab7955d87427b93ca6f64a8127d854ed96dcc9b0.zip
Diffstat (limited to '')
-rw-r--r--gui/twmsg.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/gui/twmsg.cpp b/gui/twmsg.cpp
index 6c3bad4ae..9fe9e5a94 100644
--- a/gui/twmsg.cpp
+++ b/gui/twmsg.cpp
@@ -25,19 +25,7 @@
std::string Message::GetFormatString(const std::string& name) const
{
- std::string resname;
- size_t pos = name.find('=');
- if (pos == std::string::npos)
- resname = name;
- else
- resname = name.substr(0, pos);
-
- std::string formatstr = resourceLookup(resname);
- bool notfound = formatstr.empty() || formatstr.substr(0, 2) == "{@"; // HACK: TODO: integrate this with resource-not-found logic
- if (notfound && pos != std::string::npos)
- // resource not found - use the default format string specified after "="
- formatstr = name.substr(pos + 1);
- return formatstr;
+ return resourceLookup(name);
}
// Look up in local replacement vars first, if not found then use outer lookup object
@@ -91,9 +79,25 @@ class ResourceLookup : public StringLookup
public:
virtual std::string operator()(const std::string& name) const
{
+ std::string resname;
+ std::string default_value;
+
+ size_t pos = name.find('=');
+ if (pos == std::string::npos) {
+ resname = name;
+ } else {
+ resname = name.substr(0, pos);
+ default_value = name.substr(pos + 1);
+ }
const ResourceManager* res = PageManager::GetResources();
- if (res)
- return res->FindString(name);
+ if (res) {
+ if (default_value.empty())
+ return res->FindString(resname);
+ else
+ return res->FindString(resname, default_value);
+ } else if (!default_value.empty()) {
+ return default_value;
+ }
return name;
}
};