From: Lennart Poettering Date: Wed, 7 Apr 2010 18:27:05 +0000 (+0200) Subject: util: add delete_chars() call X-Git-Tag: 0.git+20100605+dfd8ee-1~218 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee9b5e011857ff4a75ceaa9aaf3b2ed8ceacfadf;p=systemd util: add delete_chars() call --- diff --git a/util.c b/util.c index 43826990..939b2b06 100644 --- 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; diff --git a/util.h b/util.h index d0fd66dd..3ee536ad 100644 --- a/util.h +++ b/util.h @@ -129,6 +129,8 @@ char **strv_path_make_absolute_cwd(char **l); int reset_all_signal_handlers(void); char *strstrip(char *s); +char *delete_chars(char *s, const char *bad); + char *file_in_same_dir(const char *path, const char *filename); int mkdir_parents(const char *path, mode_t mode);