Mercurial > octave
changeset 32596:89cfd9dc69d8 stable
Allow making copies of symbol_match objects (bug #64975).
* glob-match.h, glob-match.cc: Add implementations for copy constructor and
copy assignment operator.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Wed, 13 Dec 2023 18:01:24 +0100 |
parents | 5383ad4d16c1 |
children | 2c3808f6155b 1386e11a30fe |
files | liboctave/util/glob-match.cc liboctave/util/glob-match.h |
diffstat | 2 files changed, 32 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/util/glob-match.cc Wed Dec 13 08:24:53 2023 -0800 +++ b/liboctave/util/glob-match.cc Wed Dec 13 18:01:24 2023 +0100 @@ -71,6 +71,17 @@ #endif } +symbol_match::symbol_match (const symbol_match& in) +{ + m_pat = in.m_pat; + +#if defined (OCTAVE_USE_WINDOWS_API) + m_glob = nullptr; +#else + m_glob = std::unique_ptr<glob_match> {new glob_match {m_pat}}; +#endif +} + bool symbol_match::match (const std::string& sym) {
--- a/liboctave/util/glob-match.h Wed Dec 13 08:24:53 2023 -0800 +++ b/liboctave/util/glob-match.h Wed Dec 13 18:01:24 2023 +0100 @@ -113,12 +113,31 @@ symbol_match (const std::string& pattern); - symbol_match (const symbol_match&) = default; + symbol_match (const symbol_match&); + + symbol_match& operator = (const symbol_match& in) + { + if (this == &in) + return *this; - symbol_match& operator = (const symbol_match&) = default; + m_pat = in.m_pat; + + if (m_glob) + m_glob->set_pattern (m_pat); + + return *this; + } ~symbol_match () = default; + void set_pattern (const std::string& p) + { + m_pat = p; + + if (m_glob) + m_glob->set_pattern (m_pat); + } + bool match (const std::string& sym); private: