Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=962807f96e4d73d556f59818eccb399fb945351d

commit 962807f96e4d73d556f59818eccb399fb945351d
Author: Michel Hermier <[email protected]>
Date:   Fri Sep 26 11:39:43 2014 +0200

libpacman: Add f_streq.

diff --git a/lib/libpacman/fstring.h b/lib/libpacman/fstring.h
index 9f53119..a84a038 100644
--- a/lib/libpacman/fstring.h
+++ b/lib/libpacman/fstring.h
@@ -21,6 +21,7 @@
#ifndef F_STRING_H
#define F_STRING_H

+#include <stdbool.h>
#include <string.h>

#ifdef __cplusplus
@@ -43,6 +44,12 @@ int f_strempty(const char *s)
}

static inline
+bool f_streq(const char *s1, const char *s2)
+{
+       return s1 == s2 || strcmp(s1, s2) == 0;
+}
+
+static inline
size_t f_strlen(const char *s)
{
return s != NULL ? strlen(s) : 0;
diff --git a/lib/libpacman/kernel/fstr.cpp b/lib/libpacman/kernel/fstr.cpp
index 393b8ac..2fa43d1 100644
--- a/lib/libpacman/kernel/fstr.cpp
+++ b/lib/libpacman/kernel/fstr.cpp
@@ -22,6 +22,7 @@
#include "kernel/fstr.h"

#include "fstring.h"
+#include "util/fstringlist.h"

FStrMatcher::FStrMatcher()
: m_flags(0), m_str(NULL)
@@ -70,7 +71,7 @@ bool FStrMatcher::match(const char *str) const
f_str_toupper(_str, str);
str = _str;
}
-       if(((m_flags & EQUAL) && strcmp(str, m_str) == 0) ||
+       if(((m_flags & EQUAL) && f_streq(str, m_str)) ||
((m_flags & SUBSTRING) && strstr(str, m_str) != NULL) ||
((m_flags & REGEXP) && regexec(&m_regex, str, 0, 0, 0) == 0)) {
return 1;
diff --git a/lib/libpacman/kernel/fstr.h b/lib/libpacman/kernel/fstr.h
index 3e3b102..a249527 100644
--- a/lib/libpacman/kernel/fstr.h
+++ b/lib/libpacman/kernel/fstr.h
@@ -24,10 +24,11 @@
#include "fstring.h"

#include "util/fmatcher.h"
-#include "util/fstringlist.h"

#include <regex.h>

+class FStringList;
+
class FStrMatcher
: public FMatcher<const char *>
{
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to