diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-04-20 00:50:22 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-04-20 00:50:22 +0000 |
| commit | 3505201f3333c937b5b870d70019d400c722a69f (patch) | |
| tree | def64ac6be50375e43da5e3e91eb443dd4c171fc /src/Netrc.cc | |
| parent | 99733a84e2102739ee7c9de08ffae9e9216b6003 (diff) | |
2008-04-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten SharedHandle. Now copy constructor taking raw pointer
has
keyword explicit and SharedHandle's default constructor
initializes
its internal obj to null, old implementation initializes it
using
obj's default constructor.
To assign null, write SharedHandle<T> x(...); x.reset();
TODO: test/SharedHandleTest.cc needs more tests.
* src/SharedHandle.h
Diffstat (limited to 'src/Netrc.cc')
| -rw-r--r-- | src/Netrc.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Netrc.cc b/src/Netrc.cc index 518be851..9c73fc66 100644 --- a/src/Netrc.cc +++ b/src/Netrc.cc @@ -69,16 +69,16 @@ void Netrc::parse(const std::string& path) throw new RecoverableException("File not found: %s", path.c_str()); } - AuthenticatorHandle authenticator = 0; + AuthenticatorHandle authenticator; std::string token; while(f >> token) { if(token == "machine") { storeAuthenticator(authenticator); - authenticator = new Authenticator(); + authenticator.reset(new Authenticator()); authenticator->setMachine(getRequiredNextToken(f)); } else if(token == "default") { storeAuthenticator(authenticator); - authenticator = new DefaultAuthenticator(); + authenticator.reset(new DefaultAuthenticator()); } else { if(authenticator.isNull()) { throw new RecoverableException("Netrc:parse error. %s encounterd where 'machine' or 'default' expected."); @@ -123,7 +123,7 @@ AuthenticatorHandle Netrc::findAuthenticator(const std::string& hostname) const std::find_if(authenticators.begin(), authenticators.end(), AuthHostMatch(hostname)); if(itr == authenticators.end()) { - return 0; + return SharedHandle<Authenticator>(); } else { return *itr; } |
