^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _SKC_LINUX_STRING_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _SKC_LINUX_STRING_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) /* Copied from lib/string.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) static inline char *skip_spaces(const char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) while (isspace(*str))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ++str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) return (char *)str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static inline char *strim(char *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) size_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) char *end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) size = strlen(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) if (!size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) return s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) end = s + size - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) while (end >= s && isspace(*end))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) end--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *(end + 1) = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) return skip_spaces(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #endif