summaryrefslogtreecommitdiff
path: root/src/libudev
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-12-14 16:11:51 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-12-16 02:14:47 +0900
commit5953d8b910920e81ece32ac89468eee995df836e (patch)
tree27a7e953bc0609b3058c35eb01b5d0186c0ca252 /src/libudev
parentb17f651a17cd6ec0ceac7835f2f8607fbd9ddb95 (diff)
downloadsystemd-5953d8b910920e81ece32ac89468eee995df836e.tar.gz
udev: move util_replace_whitespace() to udev-util.c
Diffstat (limited to 'src/libudev')
-rw-r--r--src/libudev/libudev-util.c45
-rw-r--r--src/libudev/libudev-util.h1
2 files changed, 0 insertions, 46 deletions
diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c
index bbb2879764..45977339ac 100644
--- a/src/libudev/libudev-util.c
+++ b/src/libudev/libudev-util.c
@@ -109,51 +109,6 @@ size_t util_path_encode(const char *src, char *dest, size_t size) {
return j;
}
-/*
- * Copy from 'str' to 'to', while removing all leading and trailing whitespace,
- * and replacing each run of consecutive whitespace with a single underscore.
- * The chars from 'str' are copied up to the \0 at the end of the string, or
- * at most 'len' chars. This appends \0 to 'to', at the end of the copied
- * characters.
- *
- * If 'len' chars are copied into 'to', the final \0 is placed at len+1
- * (i.e. 'to[len] = \0'), so the 'to' buffer must have at least len+1
- * chars available.
- *
- * Note this may be called with 'str' == 'to', i.e. to replace whitespace
- * in-place in a buffer. This function can handle that situation.
- *
- * Note that only 'len' characters are read from 'str'.
- */
-size_t util_replace_whitespace(const char *str, char *to, size_t len) {
- bool is_space = false;
- size_t i, j;
-
- assert(str);
- assert(to);
-
- i = strspn(str, WHITESPACE);
-
- for (j = 0; j < len && i < len && str[i] != '\0'; i++) {
- if (isspace(str[i])) {
- is_space = true;
- continue;
- }
-
- if (is_space) {
- if (j + 1 >= len)
- break;
-
- to[j++] = '_';
- is_space = false;
- }
- to[j++] = str[i];
- }
-
- to[j] = '\0';
- return j;
-}
-
/* allow chars in allow list, plain ascii, hex-escaping and valid utf8 */
size_t util_replace_chars(char *str, const char *allow) {
size_t i = 0, replaced = 0;
diff --git a/src/libudev/libudev-util.h b/src/libudev/libudev-util.h
index 15e6214b0d..d2b22f9974 100644
--- a/src/libudev/libudev-util.h
+++ b/src/libudev/libudev-util.h
@@ -11,7 +11,6 @@
#define UTIL_LINE_SIZE 16384
#define UDEV_ALLOWED_CHARS_INPUT "/ $%?,"
size_t util_path_encode(const char *src, char *dest, size_t size);
-size_t util_replace_whitespace(const char *str, char *to, size_t len);
size_t util_replace_chars(char *str, const char *white);
int util_resolve_subsys_kernel(const char *string, char *result, size_t maxsize, bool read_value);