[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [libosinfo 4/6] Correct pattern matching logic



From: "Zeeshan Ali (Khattak)" <zeeshanak gnome org>

If both pattern and string are NULL, they should match.
---
 osinfo/osinfo_db.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
index 83ee428..b359eb2 100644
--- a/osinfo/osinfo_db.c
+++ b/osinfo/osinfo_db.c
@@ -30,8 +30,9 @@ G_DEFINE_TYPE (OsinfoDb, osinfo_db, G_TYPE_OBJECT);
 
 #define OSINFO_DB_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DB, OsinfoDbPrivate))
 
-#define match_regex(pattern, str) ((pattern) && (str) && \
-                                   g_regex_match_simple((pattern), (str), 0, 0))
+#define match_regex(pattern, str) (((pattern) == NULL && (str) == NULL) || \
+                                   ((pattern) != NULL && (str) != NULL && \
+                                    g_regex_match_simple((pattern), (str), 0, 0)))
 
 /**
  * SECTION:osinfo_db
-- 
1.7.7.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]