From 94a764d6ea2d00a1c6fc268a062a59748e676c4c Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 26 Feb 2012 01:15:53 -0800 Subject: [PATCH] Fix for error messages when loading completions --- env.cpp | 2 +- env.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/env.cpp b/env.cpp index 51b503a1a..ed558f193 100644 --- a/env.cpp +++ b/env.cpp @@ -1151,7 +1151,7 @@ env_var_t env_get_string( const wcstring &key ) { if( res->val == ENV_NULL ) { - return wcstring(L""); + return env_var_t::missing_var(); } else { diff --git a/env.h b/env.h index b78015b1e..d3fbf44b8 100644 --- a/env.h +++ b/env.h @@ -100,6 +100,7 @@ private: bool is_missing; public: static env_var_t missing_var(void); + env_var_t(const env_var_t &x) : wcstring(x), is_missing(x.is_missing) { } env_var_t(const wcstring & x) : wcstring(x), is_missing(false) { } env_var_t(const wchar_t *x) : wcstring(x), is_missing(false) { } env_var_t() : wcstring(L""), is_missing(false) { } @@ -111,6 +112,15 @@ public: wcstring::operator=(s); return *this; } + + bool operator==(const env_var_t &s) const { + if (is_missing && s.is_missing) + return true; + else if (s.is_missing || s.is_missing) + return false; + else + return *static_cast(this) == *static_cast(&s); + } }; /**