From db12775d59ab709f8afc361eaa30c9d54a0a8d7c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 7 Apr 2010 20:27:19 +0200 Subject: [PATCH] util: add chars_intersect() call --- util.c | 11 +++++++++++ util.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/util.c b/util.c index 939b2b06..a0f26762 100644 --- a/util.c +++ b/util.c @@ -1193,6 +1193,17 @@ finish: return r; } +bool chars_intersect(const char *a, const char *b) { + const char *p; + + /* Returns true if any of the chars in a are in b. */ + for (p = a; *p; p++) + if (strchr(b, *p)) + return true; + + return false; +} + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime", diff --git a/util.h b/util.h index 3ee536ad..14f1a7a1 100644 --- a/util.h +++ b/util.h @@ -157,6 +157,8 @@ char *bus_path_unescape(const char *s); bool ignore_file(const char *filename); +bool chars_intersect(const char *a, const char *b); + #define DEFINE_STRING_TABLE_LOOKUP(name,type) \ const char *name##_to_string(type i) { \ if (i < 0 || i >= (type) ELEMENTSOF(name##_table)) \ -- 2.39.5