From 393fcaf733d8e50f18a70be7de1e088fb61f1ff4 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 14 Dec 2020 16:26:13 +0900 Subject: udev: move util_replace_chars() to udev-util.c --- src/libudev/libudev-util.c | 43 ------------------------------------------- src/libudev/libudev-util.h | 2 -- 2 files changed, 45 deletions(-) (limited to 'src/libudev') diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c index f4f686fc88..8a6b56be5c 100644 --- a/src/libudev/libudev-util.c +++ b/src/libudev/libudev-util.c @@ -75,49 +75,6 @@ int util_resolve_subsys_kernel(const char *string, char *result, size_t maxsize, return 0; } -/* 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; - - assert(str); - - while (str[i] != '\0') { - int len; - - if (allow_listed_char_for_devnode(str[i], allow)) { - i++; - continue; - } - - /* accept hex encoding */ - if (str[i] == '\\' && str[i+1] == 'x') { - i += 2; - continue; - } - - /* accept valid utf8 */ - len = utf8_encoded_valid_unichar(str + i, (size_t) -1); - if (len > 1) { - i += len; - continue; - } - - /* if space is allowed, replace whitespace with ordinary space */ - if (isspace(str[i]) && allow && strchr(allow, ' ')) { - str[i] = ' '; - i++; - replaced++; - continue; - } - - /* everything else is replaced with '_' */ - str[i] = '_'; - i++; - replaced++; - } - return replaced; -} - /** * udev_util_encode_string: * @str: input string to be encoded diff --git a/src/libudev/libudev-util.h b/src/libudev/libudev-util.h index dd0561d90e..547981311e 100644 --- a/src/libudev/libudev-util.h +++ b/src/libudev/libudev-util.h @@ -9,8 +9,6 @@ #define UTIL_PATH_SIZE 1024 #define UTIL_NAME_SIZE 512 #define UTIL_LINE_SIZE 16384 -#define UDEV_ALLOWED_CHARS_INPUT "/ $%?," -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); /* Cleanup functions */ -- cgit v1.2.1