[virt-tools-list] [libosinfo] Correct pattern matching logic

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Thu Nov 24 02:23:24 UTC 2011


From: "Zeeshan Ali (Khattak)" <zeeshanak at 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 4394dcf..d9ec6e3 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




More information about the virt-tools-list mailing list