diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2015-08-03 15:58:37 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2015-08-08 13:55:49 -0700 |
commit | d2049edcab6b2046b7e3e01b4a48f2e13f2aa878 (patch) | |
tree | 4bb5b0c8e774123973b436a4596686ba04bc4f4a /src/wildcard.cpp | |
parent | 83322f63c6e10e5ada88b4e99f49a6cd0b57b908 (diff) |
Slight refactoring of expander's return code implementation
Diffstat (limited to 'src/wildcard.cpp')
-rw-r--r-- | src/wildcard.cpp | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 2f3c9aa7..66318546 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -717,6 +717,16 @@ class wildcard_expander_t */ void expand_last_segment(const wcstring &base_dir, DIR *base_dir_fp, const wcstring &wc); + /* Indicate whether we should cancel wildcard expansion. This latches 'interrupt' */ + bool interrupted() + { + if (! did_interrupt) + { + did_interrupt = (is_main_thread() ? reader_interrupted() : reader_thread_job_is_stale()); + } + return did_interrupt; + } + /* Helper to resolve an empty base directory */ static DIR *open_dir(const wcstring &base_dir) { @@ -739,21 +749,16 @@ public: /* Do wildcard expansion. This is recursive. */ void expand(const wcstring &base_dir, const wchar_t *wc); - - /* Indicate whether we should cancel wildcard expansion. This latches 'interrupt' */ - bool interrupted() + int status_code() const { - if (! did_interrupt) + if (this->did_interrupt) { - did_interrupt = (is_main_thread() ? reader_interrupted() : reader_thread_job_is_stale()); + return -1; + } + else + { + return this->did_add ? 1 : 0; } - return did_interrupt; - } - - /* Indicates whether something was added */ - bool added() const - { - return this->did_add; } }; @@ -1309,14 +1314,7 @@ static int wildcard_expand(const wchar_t *wc, c.prepend_token_prefix(base_dir); } } - if (expander.interrupted()) - { - return -1; - } - else - { - return expander.added() ? 1 : 0; - } + return expander.status_code(); } int wildcard_expand_string(const wcstring &wc, const wcstring &base_dir, expand_flags_t flags, std::vector<completion_t> *output) |