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

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



On Thu, Nov 24, 2011 at 04:23:24AM +0200, Zeeshan Ali (Khattak) wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak gnome org>
> 
> If both pattern and string are NULL, they should match.

Have you met cases where it's needed? In the tests I ran, I'm not getting
NULL strings but strings full of whitespace when some fields are not set in
the iso,

Christophe

> ---
>  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
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list redhat com
> https://www.redhat.com/mailman/listinfo/virt-tools-list

Attachment: pgpD3b2PT4RQy.pgp
Description: PGP signature


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