chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util: add chars_intersect() call
[elogind.git]
/
util.c
diff --git
a/util.c
b/util.c
index 03c60af98daa527222c87214cb14d60edc6c1a9b..a0f26762dc39b87b3f6cb3c24acb50db14849512 100644
(file)
--- a/
util.c
+++ b/
util.c
@@
-611,6
+611,23
@@
char *strstrip(char *s) {
}
}
+char *delete_chars(char *s, const char *bad) {
+ char *f, *t;
+
+ /* Drops all whitespace, regardless where in the string */
+
+ for (f = s, t = s; *f; f++) {
+ if (strchr(bad, *f))
+ continue;
+
+ *(t++) = *f;
+ }
+
+ *t = 0;
+
+ return s;
+}
+
char *file_in_same_dir(const char *path, const char *filename) {
char *e, *r;
size_t k;
char *file_in_same_dir(const char *path, const char *filename) {
char *e, *r;
size_t k;
@@
-1133,7
+1150,7
@@
int close_all_fds(const int except[], unsigned n_except) {
return -errno;
while ((de = readdir(d))) {
return -errno;
while ((de = readdir(d))) {
- int fd;
+ int fd
= -1
;
if (de->d_name[0] == '.')
continue;
if (de->d_name[0] == '.')
continue;
@@
-1176,6
+1193,17
@@
finish:
return r;
}
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",
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",