From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/libbash:master commit in: src/core/, src/core/tests/
Date: Mon, 4 Apr 2011 16:09:43 +0000 (UTC) [thread overview]
Message-ID: <2d27dd160050b05cb4309a7eeec4bde936079033.betelgeuse@gentoo> (raw)
commit: 2d27dd160050b05cb4309a7eeec4bde936079033
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 4 08:53:30 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon Apr 4 15:57:03 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=2d27dd16
Fix a bug in resolving non-exist symbols
We should return an empty shared_ptr if the symbol doesn't exist.
---
src/core/symbols.hpp | 3 ++-
src/core/tests/symbols_test.cpp | 1 +
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/core/symbols.hpp b/src/core/symbols.hpp
index a4ae514..8734548 100644
--- a/src/core/symbols.hpp
+++ b/src/core/symbols.hpp
@@ -252,7 +252,8 @@ public:
/// \return target symbol passed by reference
std::shared_ptr<symbol> resolve(const std::string& name)
{
- return members[name];
+ auto iter = members.find(name);
+ return (iter == members.end()? std::shared_ptr<symbol>() : iter->second);
}
protected:
/// \var protected::member
diff --git a/src/core/tests/symbols_test.cpp b/src/core/tests/symbols_test.cpp
index 7620be0..73a6a9c 100644
--- a/src/core/tests/symbols_test.cpp
+++ b/src/core/tests/symbols_test.cpp
@@ -80,4 +80,5 @@ TEST(scope_test, define_resolve)
auto an_int = shared_ptr<variable>(new variable("integer_symbol", 100));
members.define(an_int);
EXPECT_EQ(an_int, members.resolve("integer_symbol"));
+ EXPECT_FALSE(members.resolve("not exist"));
}
next reply other threads:[~2011-04-04 16:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-04 16:09 Petteri Räty [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-05-27 23:03 [gentoo-commits] proj/libbash:master commit in: src/core/, src/core/tests/ Petteri Räty
2011-05-25 19:42 Petteri Räty
2011-05-23 14:34 Petteri Räty
2011-05-23 14:34 Petteri Räty
2011-05-08 13:07 Petteri Räty
2011-04-27 15:11 Petteri Räty
2011-04-14 4:50 Petteri Räty
2011-04-14 4:50 Petteri Räty
2011-04-12 18:29 Petteri Räty
2011-04-12 18:29 Petteri Räty
2011-04-12 18:29 Petteri Räty
2011-04-06 7:43 Petteri Räty
2011-04-04 15:52 Petteri Räty
2011-04-04 15:52 Petteri Räty
2011-03-30 12:48 Petteri Räty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2d27dd160050b05cb4309a7eeec4bde936079033.betelgeuse@gentoo \
--to=betelgeuse@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox