---
New version that use std::regex instead of regex.h.

 src/db/update/ExcludeList.cxx | 18 +++++-------------
 src/db/update/ExcludeList.hxx | 23 +++++------------------
 2 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/src/db/update/ExcludeList.cxx b/src/db/update/ExcludeList.cxx
index 631d452..832828b 100644
--- a/src/db/update/ExcludeList.cxx
+++ b/src/db/update/ExcludeList.cxx
@@ -35,26 +35,27 @@
 #include <string.h>
 #include <errno.h>
 
-#ifdef HAVE_GLIB
-
 gcc_pure
 static bool
 IsFileNotFound(const Error &error)
 {
+#ifdef HAVE_GLIB
 #ifdef WIN32
        return error.IsDomain(win32_domain) &&
                error.GetCode() == ERROR_FILE_NOT_FOUND;
 #else
        return error.IsDomain(errno_domain) && error.GetCode() == ENOENT;
 #endif
+#else
+       (void) error;
+       return true;
+#endif
 }
 
-#endif
 
 bool
 ExcludeList::LoadFile(Path path_fs)
 {
-#ifdef HAVE_GLIB
        Error error;
        TextFile file(path_fs, error);
        if (file.HasFailed()) {
@@ -73,10 +74,6 @@ ExcludeList::LoadFile(Path path_fs)
                if (*p != 0)
                        patterns.emplace_front(p);
        }
-#else
-       // TODO: implement
-       (void)path_fs;
-#endif
 
        return true;
 }
@@ -88,14 +85,9 @@ ExcludeList::Check(Path name_fs) const
 
        /* XXX include full path name in check */
 
-#ifdef HAVE_GLIB
        for (const auto &i : patterns)
                if (i.Check(NarrowPath(name_fs).c_str()))
                        return true;
-#else
-       // TODO: implement
-       (void)name_fs;
-#endif
 
        return false;
 }
diff --git a/src/db/update/ExcludeList.hxx b/src/db/update/ExcludeList.hxx
index ae196a7..b81f262 100644
--- a/src/db/update/ExcludeList.hxx
+++ b/src/db/update/ExcludeList.hxx
@@ -30,50 +30,37 @@
 
 #include <forward_list>
 
-#ifdef HAVE_GLIB
-#include <glib.h>
-#endif
+#include <regex>
 
 class Path;
 
 class ExcludeList {
-#ifdef HAVE_GLIB
        class Pattern {
-               GPatternSpec *pattern;
+               std::regex pattern;
 
        public:
                Pattern(const char *_pattern)
-                       :pattern(g_pattern_spec_new(_pattern)) {}
+                       :pattern(_pattern) {}
 
                Pattern(Pattern &&other)
                        :pattern(other.pattern) {
                        other.pattern = nullptr;
                }
 
-               ~Pattern() {
-                       g_pattern_spec_free(pattern);
-               }
+               ~Pattern() {}
 
                gcc_pure
                bool Check(const char *name_fs) const {
-                       return g_pattern_match_string(pattern, name_fs);
+                       return regex_match(name_fs, pattern);
                }
        };
 
        std::forward_list<Pattern> patterns;
-#else
-       // TODO: implement
-#endif
 
 public:
        gcc_pure
        bool IsEmpty() const {
-#ifdef HAVE_GLIB
                return patterns.empty();
-#else
-               // TODO: implement
-               return true;
-#endif
        }
 
        /**
-- 
2.1.4

_______________________________________________
mpd-devel mailing list
[email protected]
http://mailman.blarg.de/listinfo/mpd-devel

Reply via email to