/src/util-linux/include/strutils.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * No copyright is claimed. This code is in the public domain; do with |
3 | | * it what you wish. |
4 | | */ |
5 | | #ifndef UTIL_LINUX_STRUTILS |
6 | | #define UTIL_LINUX_STRUTILS |
7 | | |
8 | | #include <stdlib.h> |
9 | | #include <inttypes.h> |
10 | | #include <string.h> |
11 | | #include <sys/types.h> |
12 | | #include <ctype.h> |
13 | | #include <stdio.h> |
14 | | #include <errno.h> |
15 | | #include <time.h> |
16 | | |
17 | | #include "c.h" |
18 | | |
19 | | /* initialize a custom exit code for all *_or_err functions */ |
20 | | extern void strutils_set_exitcode(int exit_code); |
21 | | |
22 | | extern int parse_size(const char *str, uintmax_t *res, int *power); |
23 | | extern int strtosize(const char *str, uintmax_t *res); |
24 | | extern uintmax_t strtosize_or_err(const char *str, const char *errmesg); |
25 | | |
26 | | extern int ul_strtos64(const char *str, int64_t *num, int base); |
27 | | extern int ul_strtou64(const char *str, uint64_t *num, int base); |
28 | | extern int ul_strtos32(const char *str, int32_t *num, int base); |
29 | | extern int ul_strtou32(const char *str, uint32_t *num, int base); |
30 | | |
31 | | extern int64_t str2num_or_err(const char *str, int base, const char *errmesg, int64_t low, int64_t up); |
32 | | extern uint64_t str2unum_or_err(const char *str, int base, const char *errmesg, uint64_t up); |
33 | | |
34 | 0 | #define strtos64_or_err(_s, _e) str2num_or_err(_s, 10, _e, 0, 0) |
35 | | #define strtou64_or_err(_s, _e) str2unum_or_err(_s, 10, _e, 0) |
36 | | #define strtox64_or_err(_s, _e) str2unum_or_err(_s, 16, _e, 0) |
37 | | |
38 | | #define strtos32_or_err(_s, _e) (int32_t) str2num_or_err(_s, 10, _e, INT32_MIN, INT32_MAX) |
39 | | #define strtou32_or_err(_s, _e) (uint32_t) str2unum_or_err(_s, 10, _e, UINT32_MAX) |
40 | | #define strtox32_or_err(_s, _e) (uint32_t) str2unum_or_err(_s, 16, _e, UINT32_MAX) |
41 | | |
42 | | #define strtos16_or_err(_s, _e) (int16_t) str2num_or_err(_s, 10, _e, INT16_MIN, INT16_MAX) |
43 | | #define strtou16_or_err(_s, _e) (uint16_t) str2unum_or_err(_s, 10, _e, UINT16_MAX) |
44 | | #define strtox16_or_err(_s, _e) (uint16_t) str2unum_or_err(_s, 16, _e, UINT16_MAX) |
45 | | |
46 | | extern double strtod_or_err(const char *str, const char *errmesg); |
47 | | extern long double strtold_or_err(const char *str, const char *errmesg); |
48 | | |
49 | | #define strtol_or_err(_s, _e) (long) str2num_or_err(_s, 10, _e, LONG_MIN, LONG_MAX) |
50 | | #define strtopid_or_err(_s, _e) (pid_t) str2num_or_err(_s, 10, _e, 1, SINT_MAX(pid_t)) |
51 | | #define strtoul_or_err(_s, _e) (unsigned long) str2unum_or_err(_s, 10, _e, ULONG_MAX) |
52 | | |
53 | | extern void strtotimeval_or_err(const char *str, struct timeval *tv, |
54 | | const char *errmesg); |
55 | | extern void strtotimespec_or_err(const char *str, struct timespec *ts, |
56 | | const char *errmesg); |
57 | | extern time_t strtotime_or_err(const char *str, const char *errmesg); |
58 | | |
59 | | extern int isdigit_strend(const char *str, const char **end); |
60 | | #define isdigit_string(_s) isdigit_strend(_s, NULL) |
61 | | |
62 | | extern int isxdigit_strend(const char *str, const char **end); |
63 | 42 | #define isxdigit_string(_s) isxdigit_strend(_s, NULL) |
64 | | |
65 | | |
66 | | extern int parse_switch(const char *arg, const char *errmesg, ...); |
67 | | |
68 | | #ifndef HAVE_MEMPCPY |
69 | | extern void *mempcpy(void *restrict dest, const void *restrict src, size_t n); |
70 | | #endif |
71 | | #ifndef HAVE_STRNLEN |
72 | | extern size_t strnlen(const char *s, size_t maxlen); |
73 | | #endif |
74 | | #ifndef HAVE_STRNDUP |
75 | | extern char *strndup(const char *s, size_t n); |
76 | | #endif |
77 | | #ifndef HAVE_STRNCHR |
78 | | extern char *strnchr(const char *s, size_t maxlen, int c); |
79 | | #endif |
80 | | |
81 | | /* caller guarantees n > 0 */ |
82 | | static inline void xstrncpy(char *dest, const char *src, size_t n) |
83 | 0 | { |
84 | 0 | size_t len = src ? strlen(src) : 0; |
85 | |
|
86 | 0 | if (!len) |
87 | 0 | return; |
88 | 0 | len = min(len, n - 1); |
89 | 0 | memcpy(dest, src, len); |
90 | 0 | dest[len] = 0; |
91 | 0 | } Unexecuted instantiation: tab.c:xstrncpy Unexecuted instantiation: tab_parse.c:xstrncpy Unexecuted instantiation: utils.c:xstrncpy Unexecuted instantiation: canonicalize.c:xstrncpy Unexecuted instantiation: loopdev.c:xstrncpy Unexecuted instantiation: path.c:xstrncpy Unexecuted instantiation: strutils.c:xstrncpy Unexecuted instantiation: sysfs.c:xstrncpy Unexecuted instantiation: cache.c:xstrncpy Unexecuted instantiation: fs.c:xstrncpy Unexecuted instantiation: optmap.c:xstrncpy Unexecuted instantiation: optlist.c:xstrncpy Unexecuted instantiation: optstr.c:xstrncpy Unexecuted instantiation: buffer.c:xstrncpy Unexecuted instantiation: mbsalign.c:xstrncpy Unexecuted instantiation: evaluate.c:xstrncpy Unexecuted instantiation: probe.c:xstrncpy Unexecuted instantiation: partitions.c:xstrncpy Unexecuted instantiation: devname.c:xstrncpy Unexecuted instantiation: devno.c:xstrncpy Unexecuted instantiation: encode.c:xstrncpy Unexecuted instantiation: script.c:xstrncpy Unexecuted instantiation: ask.c:xstrncpy Unexecuted instantiation: context.c:xstrncpy Unexecuted instantiation: parttype.c:xstrncpy Unexecuted instantiation: partition.c:xstrncpy Unexecuted instantiation: wipe.c:xstrncpy Unexecuted instantiation: dos.c:xstrncpy Unexecuted instantiation: gpt.c:xstrncpy Unexecuted instantiation: gen_uuid.c:xstrncpy Unexecuted instantiation: last.c:xstrncpy Unexecuted instantiation: timeutils.c:xstrncpy |
92 | | |
93 | | /* This is like strncpy(), but based on memcpy(), so compilers and static |
94 | | * analyzers do not complain when sizeof(destination) is the same as 'n' and |
95 | | * result is not terminated by zero. |
96 | | * |
97 | | * Use this function to copy string to logs with fixed sizes (wtmp/utmp. ...) |
98 | | * where string terminator is optional. |
99 | | */ |
100 | | static inline void * __attribute__((nonnull (1))) |
101 | | str2memcpy(void *dest, const char *src, size_t n) |
102 | 0 | { |
103 | 0 | size_t bytes = strlen(src) + 1; |
104 | 0 |
|
105 | 0 | if (bytes > n) |
106 | 0 | bytes = n; |
107 | 0 |
|
108 | 0 | memcpy(dest, src, bytes); |
109 | 0 | return dest; |
110 | 0 | } Unexecuted instantiation: tab.c:str2memcpy Unexecuted instantiation: tab_parse.c:str2memcpy Unexecuted instantiation: utils.c:str2memcpy Unexecuted instantiation: canonicalize.c:str2memcpy Unexecuted instantiation: loopdev.c:str2memcpy Unexecuted instantiation: path.c:str2memcpy Unexecuted instantiation: strutils.c:str2memcpy Unexecuted instantiation: sysfs.c:str2memcpy Unexecuted instantiation: cache.c:str2memcpy Unexecuted instantiation: fs.c:str2memcpy Unexecuted instantiation: optmap.c:str2memcpy Unexecuted instantiation: optlist.c:str2memcpy Unexecuted instantiation: optstr.c:str2memcpy Unexecuted instantiation: buffer.c:str2memcpy Unexecuted instantiation: mbsalign.c:str2memcpy Unexecuted instantiation: evaluate.c:str2memcpy Unexecuted instantiation: probe.c:str2memcpy Unexecuted instantiation: partitions.c:str2memcpy Unexecuted instantiation: devname.c:str2memcpy Unexecuted instantiation: devno.c:str2memcpy Unexecuted instantiation: encode.c:str2memcpy Unexecuted instantiation: script.c:str2memcpy Unexecuted instantiation: ask.c:str2memcpy Unexecuted instantiation: context.c:str2memcpy Unexecuted instantiation: parttype.c:str2memcpy Unexecuted instantiation: partition.c:str2memcpy Unexecuted instantiation: wipe.c:str2memcpy Unexecuted instantiation: dos.c:str2memcpy Unexecuted instantiation: gpt.c:str2memcpy Unexecuted instantiation: gen_uuid.c:str2memcpy Unexecuted instantiation: last.c:str2memcpy Unexecuted instantiation: timeutils.c:str2memcpy |
111 | | |
112 | | static inline char * __attribute__((nonnull (1))) |
113 | | mem2strcpy(char *dest, const void *src, size_t n, size_t nmax) |
114 | 42.2k | { |
115 | 42.2k | if (n + 1 > nmax) |
116 | 19.8k | n = nmax - 1; |
117 | | |
118 | 42.2k | memset(dest, '\0', nmax); |
119 | 42.2k | memcpy(dest, src, n); |
120 | 42.2k | return dest; |
121 | 42.2k | } Unexecuted instantiation: tab.c:mem2strcpy Unexecuted instantiation: tab_parse.c:mem2strcpy Unexecuted instantiation: utils.c:mem2strcpy Unexecuted instantiation: canonicalize.c:mem2strcpy Unexecuted instantiation: loopdev.c:mem2strcpy Unexecuted instantiation: path.c:mem2strcpy Unexecuted instantiation: strutils.c:mem2strcpy Unexecuted instantiation: sysfs.c:mem2strcpy Unexecuted instantiation: cache.c:mem2strcpy Unexecuted instantiation: fs.c:mem2strcpy Unexecuted instantiation: optmap.c:mem2strcpy Unexecuted instantiation: optlist.c:mem2strcpy Unexecuted instantiation: optstr.c:mem2strcpy Unexecuted instantiation: buffer.c:mem2strcpy Unexecuted instantiation: mbsalign.c:mem2strcpy Unexecuted instantiation: evaluate.c:mem2strcpy Unexecuted instantiation: probe.c:mem2strcpy Unexecuted instantiation: partitions.c:mem2strcpy Unexecuted instantiation: devname.c:mem2strcpy Unexecuted instantiation: devno.c:mem2strcpy Unexecuted instantiation: encode.c:mem2strcpy Unexecuted instantiation: script.c:mem2strcpy Unexecuted instantiation: ask.c:mem2strcpy Unexecuted instantiation: context.c:mem2strcpy Unexecuted instantiation: parttype.c:mem2strcpy Unexecuted instantiation: partition.c:mem2strcpy Unexecuted instantiation: wipe.c:mem2strcpy Unexecuted instantiation: dos.c:mem2strcpy Unexecuted instantiation: gpt.c:mem2strcpy Unexecuted instantiation: gen_uuid.c:mem2strcpy Line | Count | Source | 114 | 42.2k | { | 115 | 42.2k | if (n + 1 > nmax) | 116 | 19.8k | n = nmax - 1; | 117 | | | 118 | 42.2k | memset(dest, '\0', nmax); | 119 | 42.2k | memcpy(dest, src, n); | 120 | 42.2k | return dest; | 121 | 42.2k | } |
Unexecuted instantiation: timeutils.c:mem2strcpy |
122 | | |
123 | | /* Reallocate @str according to @newstr and copy @newstr to @str; returns new @str. |
124 | | * The @str is not modified if reallocation failed (like classic realloc()). |
125 | | */ |
126 | | static inline char * __attribute__((warn_unused_result)) |
127 | | strrealloc(char *str, const char *newstr) |
128 | 0 | { |
129 | 0 | size_t nsz, osz; |
130 | 0 |
|
131 | 0 | if (!str) |
132 | 0 | return newstr ? strdup(newstr) : NULL; |
133 | 0 | if (!newstr) |
134 | 0 | return NULL; |
135 | 0 |
|
136 | 0 | osz = strlen(str); |
137 | 0 | nsz = strlen(newstr); |
138 | 0 |
|
139 | 0 | if (nsz > osz) |
140 | 0 | str = realloc(str, nsz + 1); |
141 | 0 | if (str) |
142 | 0 | memcpy(str, newstr, nsz + 1); |
143 | 0 | return str; |
144 | 0 | } Unexecuted instantiation: tab.c:strrealloc Unexecuted instantiation: tab_parse.c:strrealloc Unexecuted instantiation: utils.c:strrealloc Unexecuted instantiation: canonicalize.c:strrealloc Unexecuted instantiation: loopdev.c:strrealloc Unexecuted instantiation: path.c:strrealloc Unexecuted instantiation: strutils.c:strrealloc Unexecuted instantiation: sysfs.c:strrealloc Unexecuted instantiation: cache.c:strrealloc Unexecuted instantiation: fs.c:strrealloc Unexecuted instantiation: optmap.c:strrealloc Unexecuted instantiation: optlist.c:strrealloc Unexecuted instantiation: optstr.c:strrealloc Unexecuted instantiation: buffer.c:strrealloc Unexecuted instantiation: mbsalign.c:strrealloc Unexecuted instantiation: evaluate.c:strrealloc Unexecuted instantiation: probe.c:strrealloc Unexecuted instantiation: partitions.c:strrealloc Unexecuted instantiation: devname.c:strrealloc Unexecuted instantiation: devno.c:strrealloc Unexecuted instantiation: encode.c:strrealloc Unexecuted instantiation: script.c:strrealloc Unexecuted instantiation: ask.c:strrealloc Unexecuted instantiation: context.c:strrealloc Unexecuted instantiation: parttype.c:strrealloc Unexecuted instantiation: partition.c:strrealloc Unexecuted instantiation: wipe.c:strrealloc Unexecuted instantiation: dos.c:strrealloc Unexecuted instantiation: gpt.c:strrealloc Unexecuted instantiation: gen_uuid.c:strrealloc Unexecuted instantiation: last.c:strrealloc Unexecuted instantiation: timeutils.c:strrealloc |
145 | | |
146 | | /* Copy string @str to struct @stru to member addressed by @offset */ |
147 | | static inline int strdup_to_offset(void *stru, size_t offset, const char *str) |
148 | 10.0k | { |
149 | 10.0k | char **o; |
150 | 10.0k | char *p = NULL; |
151 | | |
152 | 10.0k | if (!stru) |
153 | 0 | return -EINVAL; |
154 | | |
155 | 10.0k | o = (char **) ((char *) stru + offset); |
156 | 10.0k | if (str) { |
157 | 8.54k | p = strdup(str); |
158 | 8.54k | if (!p) |
159 | 0 | return -ENOMEM; |
160 | 8.54k | } |
161 | | |
162 | 10.0k | free(*o); |
163 | 10.0k | *o = p; |
164 | 10.0k | return 0; |
165 | 10.0k | } Line | Count | Source | 148 | 159 | { | 149 | 159 | char **o; | 150 | 159 | char *p = NULL; | 151 | | | 152 | 159 | if (!stru) | 153 | 0 | return -EINVAL; | 154 | | | 155 | 159 | o = (char **) ((char *) stru + offset); | 156 | 159 | if (str) { | 157 | 81 | p = strdup(str); | 158 | 81 | if (!p) | 159 | 0 | return -ENOMEM; | 160 | 81 | } | 161 | | | 162 | 159 | free(*o); | 163 | 159 | *o = p; | 164 | 159 | return 0; | 165 | 159 | } |
Unexecuted instantiation: tab_parse.c:strdup_to_offset Unexecuted instantiation: utils.c:strdup_to_offset Unexecuted instantiation: canonicalize.c:strdup_to_offset Unexecuted instantiation: loopdev.c:strdup_to_offset Unexecuted instantiation: path.c:strdup_to_offset Unexecuted instantiation: strutils.c:strdup_to_offset Unexecuted instantiation: sysfs.c:strdup_to_offset Unexecuted instantiation: cache.c:strdup_to_offset Line | Count | Source | 148 | 159 | { | 149 | 159 | char **o; | 150 | 159 | char *p = NULL; | 151 | | | 152 | 159 | if (!stru) | 153 | 0 | return -EINVAL; | 154 | | | 155 | 159 | o = (char **) ((char *) stru + offset); | 156 | 159 | if (str) { | 157 | 0 | p = strdup(str); | 158 | 0 | if (!p) | 159 | 0 | return -ENOMEM; | 160 | 0 | } | 161 | | | 162 | 159 | free(*o); | 163 | 159 | *o = p; | 164 | 159 | return 0; | 165 | 159 | } |
Unexecuted instantiation: optmap.c:strdup_to_offset Unexecuted instantiation: optlist.c:strdup_to_offset Unexecuted instantiation: optstr.c:strdup_to_offset Unexecuted instantiation: buffer.c:strdup_to_offset Unexecuted instantiation: mbsalign.c:strdup_to_offset Unexecuted instantiation: evaluate.c:strdup_to_offset Unexecuted instantiation: probe.c:strdup_to_offset Unexecuted instantiation: partitions.c:strdup_to_offset Unexecuted instantiation: devname.c:strdup_to_offset Unexecuted instantiation: devno.c:strdup_to_offset Unexecuted instantiation: encode.c:strdup_to_offset script.c:strdup_to_offset Line | Count | Source | 148 | 2.57k | { | 149 | 2.57k | char **o; | 150 | 2.57k | char *p = NULL; | 151 | | | 152 | 2.57k | if (!stru) | 153 | 0 | return -EINVAL; | 154 | | | 155 | 2.57k | o = (char **) ((char *) stru + offset); | 156 | 2.57k | if (str) { | 157 | 2.57k | p = strdup(str); | 158 | 2.57k | if (!p) | 159 | 0 | return -ENOMEM; | 160 | 2.57k | } | 161 | | | 162 | 2.57k | free(*o); | 163 | 2.57k | *o = p; | 164 | 2.57k | return 0; | 165 | 2.57k | } |
Unexecuted instantiation: ask.c:strdup_to_offset Unexecuted instantiation: context.c:strdup_to_offset parttype.c:strdup_to_offset Line | Count | Source | 148 | 7.14k | { | 149 | 7.14k | char **o; | 150 | 7.14k | char *p = NULL; | 151 | | | 152 | 7.14k | if (!stru) | 153 | 0 | return -EINVAL; | 154 | | | 155 | 7.14k | o = (char **) ((char *) stru + offset); | 156 | 7.14k | if (str) { | 157 | 5.89k | p = strdup(str); | 158 | 5.89k | if (!p) | 159 | 0 | return -ENOMEM; | 160 | 5.89k | } | 161 | | | 162 | 7.14k | free(*o); | 163 | 7.14k | *o = p; | 164 | 7.14k | return 0; | 165 | 7.14k | } |
Unexecuted instantiation: partition.c:strdup_to_offset Unexecuted instantiation: wipe.c:strdup_to_offset Unexecuted instantiation: dos.c:strdup_to_offset Unexecuted instantiation: gpt.c:strdup_to_offset Unexecuted instantiation: gen_uuid.c:strdup_to_offset Unexecuted instantiation: last.c:strdup_to_offset Unexecuted instantiation: timeutils.c:strdup_to_offset |
166 | | |
167 | | /* Copy string __str to struct member _m of the struct _s */ |
168 | | #define strdup_to_struct_member(_s, _m, _str) \ |
169 | 10.0k | strdup_to_offset((void *) _s, offsetof(__typeof__(*(_s)), _m), _str) |
170 | | |
171 | | /* Copy string addressed by @offset between two structs */ |
172 | | static inline int strdup_between_offsets(void *stru_dst, void *stru_src, size_t offset) |
173 | 0 | { |
174 | 0 | char **src; |
175 | 0 | char **dst; |
176 | 0 | char *p = NULL; |
177 | |
|
178 | 0 | if (!stru_src || !stru_dst) |
179 | 0 | return -EINVAL; |
180 | | |
181 | 0 | src = (char **) ((char *) stru_src + offset); |
182 | 0 | dst = (char **) ((char *) stru_dst + offset); |
183 | |
|
184 | 0 | if (*src) { |
185 | 0 | p = strdup(*src); |
186 | 0 | if (!p) |
187 | 0 | return -ENOMEM; |
188 | 0 | } |
189 | | |
190 | 0 | free(*dst); |
191 | 0 | *dst = p; |
192 | 0 | return 0; |
193 | 0 | } Unexecuted instantiation: tab.c:strdup_between_offsets Unexecuted instantiation: tab_parse.c:strdup_between_offsets Unexecuted instantiation: utils.c:strdup_between_offsets Unexecuted instantiation: canonicalize.c:strdup_between_offsets Unexecuted instantiation: loopdev.c:strdup_between_offsets Unexecuted instantiation: path.c:strdup_between_offsets Unexecuted instantiation: strutils.c:strdup_between_offsets Unexecuted instantiation: sysfs.c:strdup_between_offsets Unexecuted instantiation: cache.c:strdup_between_offsets Unexecuted instantiation: fs.c:strdup_between_offsets Unexecuted instantiation: optmap.c:strdup_between_offsets Unexecuted instantiation: optlist.c:strdup_between_offsets Unexecuted instantiation: optstr.c:strdup_between_offsets Unexecuted instantiation: buffer.c:strdup_between_offsets Unexecuted instantiation: mbsalign.c:strdup_between_offsets Unexecuted instantiation: evaluate.c:strdup_between_offsets Unexecuted instantiation: probe.c:strdup_between_offsets Unexecuted instantiation: partitions.c:strdup_between_offsets Unexecuted instantiation: devname.c:strdup_between_offsets Unexecuted instantiation: devno.c:strdup_between_offsets Unexecuted instantiation: encode.c:strdup_between_offsets Unexecuted instantiation: script.c:strdup_between_offsets Unexecuted instantiation: ask.c:strdup_between_offsets Unexecuted instantiation: context.c:strdup_between_offsets Unexecuted instantiation: parttype.c:strdup_between_offsets Unexecuted instantiation: partition.c:strdup_between_offsets Unexecuted instantiation: wipe.c:strdup_between_offsets Unexecuted instantiation: dos.c:strdup_between_offsets Unexecuted instantiation: gpt.c:strdup_between_offsets Unexecuted instantiation: gen_uuid.c:strdup_between_offsets Unexecuted instantiation: last.c:strdup_between_offsets Unexecuted instantiation: timeutils.c:strdup_between_offsets |
194 | | |
195 | | /* Copy string addressed by struct member between two instances of the same |
196 | | * struct type */ |
197 | | #define strdup_between_structs(_dst, _src, _m) \ |
198 | 0 | strdup_between_offsets((void *)_dst, (void *)_src, offsetof(__typeof__(*(_src)), _m)) |
199 | | |
200 | | |
201 | | extern char *xstrmode(mode_t mode, char *str); |
202 | | |
203 | | /* Options for size_to_human_string() */ |
204 | | enum |
205 | | { |
206 | | SIZE_SUFFIX_1LETTER = 0, |
207 | | SIZE_SUFFIX_3LETTER = (1 << 0), |
208 | | SIZE_SUFFIX_SPACE = (1 << 1), |
209 | | SIZE_DECIMAL_2DIGITS = (1 << 2) |
210 | | }; |
211 | | |
212 | | extern char *size_to_human_string(int options, uint64_t bytes); |
213 | | |
214 | | extern int string_to_idarray(const char *list, int ary[], size_t arysz, |
215 | | int (name2id)(const char *, size_t)); |
216 | | extern int string_add_to_idarray(const char *list, int ary[], |
217 | | size_t arysz, size_t *ary_pos, |
218 | | int (name2id)(const char *, size_t)); |
219 | | |
220 | | extern int string_to_bitarray(const char *list, char *ary, |
221 | | int (*name2bit)(const char *, size_t), |
222 | | size_t allow_range); |
223 | | |
224 | | extern int string_to_bitmask(const char *list, |
225 | | unsigned long *mask, |
226 | | long (*name2flag)(const char *, size_t)); |
227 | | extern int parse_range(const char *str, int *lower, int *upper, int def); |
228 | | |
229 | | extern int streq_paths(const char *a, const char *b); |
230 | | |
231 | | /* |
232 | | * Match string beginning. |
233 | | */ |
234 | | static inline const char *startswith(const char *s, const char *prefix) |
235 | 13.5k | { |
236 | 13.5k | size_t sz = prefix ? strlen(prefix) : 0; |
237 | | |
238 | 13.5k | if (s && sz && strncmp(s, prefix, sz) == 0) |
239 | 934 | return s + sz; |
240 | 12.6k | return NULL; |
241 | 13.5k | } Unexecuted instantiation: tab.c:startswith Unexecuted instantiation: tab_parse.c:startswith Unexecuted instantiation: utils.c:startswith Unexecuted instantiation: canonicalize.c:startswith Unexecuted instantiation: loopdev.c:startswith Unexecuted instantiation: path.c:startswith Unexecuted instantiation: strutils.c:startswith Unexecuted instantiation: sysfs.c:startswith Unexecuted instantiation: cache.c:startswith Unexecuted instantiation: fs.c:startswith Line | Count | Source | 235 | 13.5k | { | 236 | 13.5k | size_t sz = prefix ? strlen(prefix) : 0; | 237 | | | 238 | 13.5k | if (s && sz && strncmp(s, prefix, sz) == 0) | 239 | 934 | return s + sz; | 240 | 12.6k | return NULL; | 241 | 13.5k | } |
Unexecuted instantiation: optlist.c:startswith Unexecuted instantiation: optstr.c:startswith Unexecuted instantiation: buffer.c:startswith Unexecuted instantiation: mbsalign.c:startswith Unexecuted instantiation: evaluate.c:startswith Unexecuted instantiation: probe.c:startswith Unexecuted instantiation: partitions.c:startswith Unexecuted instantiation: devname.c:startswith Unexecuted instantiation: devno.c:startswith Unexecuted instantiation: encode.c:startswith Unexecuted instantiation: script.c:startswith Unexecuted instantiation: ask.c:startswith Unexecuted instantiation: context.c:startswith Unexecuted instantiation: parttype.c:startswith Unexecuted instantiation: partition.c:startswith Unexecuted instantiation: wipe.c:startswith Unexecuted instantiation: dos.c:startswith Unexecuted instantiation: gpt.c:startswith Unexecuted instantiation: gen_uuid.c:startswith Unexecuted instantiation: last.c:startswith Unexecuted instantiation: timeutils.c:startswith |
242 | | |
243 | | /* |
244 | | * Case insensitive match string beginning. |
245 | | */ |
246 | | static inline const char *startswith_no_case(const char *s, const char *prefix) |
247 | 0 | { |
248 | 0 | size_t sz = prefix ? strlen(prefix) : 0; |
249 | |
|
250 | 0 | if (s && sz && strncasecmp(s, prefix, sz) == 0) |
251 | 0 | return s + sz; |
252 | 0 | return NULL; |
253 | 0 | } Unexecuted instantiation: tab.c:startswith_no_case Unexecuted instantiation: tab_parse.c:startswith_no_case Unexecuted instantiation: utils.c:startswith_no_case Unexecuted instantiation: canonicalize.c:startswith_no_case Unexecuted instantiation: loopdev.c:startswith_no_case Unexecuted instantiation: path.c:startswith_no_case Unexecuted instantiation: strutils.c:startswith_no_case Unexecuted instantiation: sysfs.c:startswith_no_case Unexecuted instantiation: cache.c:startswith_no_case Unexecuted instantiation: fs.c:startswith_no_case Unexecuted instantiation: optmap.c:startswith_no_case Unexecuted instantiation: optlist.c:startswith_no_case Unexecuted instantiation: optstr.c:startswith_no_case Unexecuted instantiation: buffer.c:startswith_no_case Unexecuted instantiation: mbsalign.c:startswith_no_case Unexecuted instantiation: evaluate.c:startswith_no_case Unexecuted instantiation: probe.c:startswith_no_case Unexecuted instantiation: partitions.c:startswith_no_case Unexecuted instantiation: devname.c:startswith_no_case Unexecuted instantiation: devno.c:startswith_no_case Unexecuted instantiation: encode.c:startswith_no_case Unexecuted instantiation: script.c:startswith_no_case Unexecuted instantiation: ask.c:startswith_no_case Unexecuted instantiation: context.c:startswith_no_case Unexecuted instantiation: parttype.c:startswith_no_case Unexecuted instantiation: partition.c:startswith_no_case Unexecuted instantiation: wipe.c:startswith_no_case Unexecuted instantiation: dos.c:startswith_no_case Unexecuted instantiation: gpt.c:startswith_no_case Unexecuted instantiation: gen_uuid.c:startswith_no_case Unexecuted instantiation: last.c:startswith_no_case Unexecuted instantiation: timeutils.c:startswith_no_case |
254 | | |
255 | | /* |
256 | | * Match string ending. |
257 | | */ |
258 | | static inline const char *endswith(const char *s, const char *postfix) |
259 | 7.59k | { |
260 | 7.59k | size_t sl = s ? strlen(s) : 0; |
261 | 7.59k | size_t pl = postfix ? strlen(postfix) : 0; |
262 | | |
263 | 7.59k | if (pl == 0) |
264 | 0 | return s + sl; |
265 | 7.59k | if (sl < pl) |
266 | 3.58k | return NULL; |
267 | 4.01k | if (memcmp(s + sl - pl, postfix, pl) != 0) |
268 | 3.62k | return NULL; |
269 | 389 | return s + sl - pl; |
270 | 4.01k | } Unexecuted instantiation: tab.c:endswith Line | Count | Source | 259 | 3.60k | { | 260 | 3.60k | size_t sl = s ? strlen(s) : 0; | 261 | 3.60k | size_t pl = postfix ? strlen(postfix) : 0; | 262 | | | 263 | 3.60k | if (pl == 0) | 264 | 0 | return s + sl; | 265 | 3.60k | if (sl < pl) | 266 | 3.11k | return NULL; | 267 | 486 | if (memcmp(s + sl - pl, postfix, pl) != 0) | 268 | 292 | return NULL; | 269 | 194 | return s + sl - pl; | 270 | 486 | } |
Unexecuted instantiation: canonicalize.c:endswith Unexecuted instantiation: loopdev.c:endswith Unexecuted instantiation: path.c:endswith Unexecuted instantiation: strutils.c:endswith Unexecuted instantiation: sysfs.c:endswith Unexecuted instantiation: cache.c:endswith Unexecuted instantiation: fs.c:endswith Unexecuted instantiation: optmap.c:endswith Unexecuted instantiation: optlist.c:endswith Unexecuted instantiation: optstr.c:endswith Unexecuted instantiation: buffer.c:endswith Unexecuted instantiation: mbsalign.c:endswith Unexecuted instantiation: evaluate.c:endswith Unexecuted instantiation: probe.c:endswith Unexecuted instantiation: partitions.c:endswith Unexecuted instantiation: devname.c:endswith Unexecuted instantiation: devno.c:endswith Unexecuted instantiation: encode.c:endswith Unexecuted instantiation: script.c:endswith Unexecuted instantiation: ask.c:endswith Line | Count | Source | 259 | 3.99k | { | 260 | 3.99k | size_t sl = s ? strlen(s) : 0; | 261 | 3.99k | size_t pl = postfix ? strlen(postfix) : 0; | 262 | | | 263 | 3.99k | if (pl == 0) | 264 | 0 | return s + sl; | 265 | 3.99k | if (sl < pl) | 266 | 464 | return NULL; | 267 | 3.53k | if (memcmp(s + sl - pl, postfix, pl) != 0) | 268 | 3.33k | return NULL; | 269 | 195 | return s + sl - pl; | 270 | 3.53k | } |
Unexecuted instantiation: context.c:endswith Unexecuted instantiation: parttype.c:endswith Unexecuted instantiation: partition.c:endswith Unexecuted instantiation: wipe.c:endswith Unexecuted instantiation: dos.c:endswith Unexecuted instantiation: gpt.c:endswith Unexecuted instantiation: gen_uuid.c:endswith Unexecuted instantiation: last.c:endswith Unexecuted instantiation: timeutils.c:endswith |
271 | | |
272 | | /* |
273 | | * Skip leading white space. |
274 | | */ |
275 | | static inline const char *skip_space(const char *p) |
276 | 0 | { |
277 | 0 | while (isspace(*p)) |
278 | 0 | ++p; |
279 | 0 | return p; |
280 | 0 | } Unexecuted instantiation: tab.c:skip_space Unexecuted instantiation: tab_parse.c:skip_space Unexecuted instantiation: utils.c:skip_space Unexecuted instantiation: canonicalize.c:skip_space Unexecuted instantiation: loopdev.c:skip_space Unexecuted instantiation: path.c:skip_space Unexecuted instantiation: strutils.c:skip_space Unexecuted instantiation: sysfs.c:skip_space Unexecuted instantiation: cache.c:skip_space Unexecuted instantiation: fs.c:skip_space Unexecuted instantiation: optmap.c:skip_space Unexecuted instantiation: optlist.c:skip_space Unexecuted instantiation: optstr.c:skip_space Unexecuted instantiation: buffer.c:skip_space Unexecuted instantiation: mbsalign.c:skip_space Unexecuted instantiation: evaluate.c:skip_space Unexecuted instantiation: probe.c:skip_space Unexecuted instantiation: partitions.c:skip_space Unexecuted instantiation: devname.c:skip_space Unexecuted instantiation: devno.c:skip_space Unexecuted instantiation: encode.c:skip_space Unexecuted instantiation: script.c:skip_space Unexecuted instantiation: ask.c:skip_space Unexecuted instantiation: context.c:skip_space Unexecuted instantiation: parttype.c:skip_space Unexecuted instantiation: partition.c:skip_space Unexecuted instantiation: wipe.c:skip_space Unexecuted instantiation: dos.c:skip_space Unexecuted instantiation: gpt.c:skip_space Unexecuted instantiation: gen_uuid.c:skip_space Unexecuted instantiation: last.c:skip_space Unexecuted instantiation: timeutils.c:skip_space |
281 | | |
282 | | static inline const char *skip_blank(const char *p) |
283 | 273k | { |
284 | 273k | while (isblank(*p)) |
285 | 34.7k | ++p; |
286 | 273k | return p; |
287 | 273k | } Unexecuted instantiation: tab.c:skip_blank Line | Count | Source | 283 | 104k | { | 284 | 104k | while (isblank(*p)) | 285 | 1.20k | ++p; | 286 | 104k | return p; | 287 | 104k | } |
Unexecuted instantiation: utils.c:skip_blank Unexecuted instantiation: canonicalize.c:skip_blank Unexecuted instantiation: loopdev.c:skip_blank Unexecuted instantiation: path.c:skip_blank Unexecuted instantiation: strutils.c:skip_blank Unexecuted instantiation: sysfs.c:skip_blank Unexecuted instantiation: cache.c:skip_blank Unexecuted instantiation: fs.c:skip_blank Unexecuted instantiation: optmap.c:skip_blank Unexecuted instantiation: optlist.c:skip_blank Unexecuted instantiation: optstr.c:skip_blank Unexecuted instantiation: buffer.c:skip_blank Unexecuted instantiation: mbsalign.c:skip_blank Unexecuted instantiation: evaluate.c:skip_blank Unexecuted instantiation: probe.c:skip_blank Unexecuted instantiation: partitions.c:skip_blank Unexecuted instantiation: devname.c:skip_blank Unexecuted instantiation: devno.c:skip_blank Unexecuted instantiation: encode.c:skip_blank Line | Count | Source | 283 | 169k | { | 284 | 169k | while (isblank(*p)) | 285 | 33.5k | ++p; | 286 | 169k | return p; | 287 | 169k | } |
Unexecuted instantiation: ask.c:skip_blank Unexecuted instantiation: context.c:skip_blank Unexecuted instantiation: parttype.c:skip_blank Unexecuted instantiation: partition.c:skip_blank Unexecuted instantiation: wipe.c:skip_blank Unexecuted instantiation: dos.c:skip_blank Unexecuted instantiation: gpt.c:skip_blank Unexecuted instantiation: gen_uuid.c:skip_blank Unexecuted instantiation: last.c:skip_blank Unexecuted instantiation: timeutils.c:skip_blank |
288 | | |
289 | | |
290 | | /* Removes whitespace from the right-hand side of a string (trailing |
291 | | * whitespace). |
292 | | * |
293 | | * Returns size of the new string (without \0). |
294 | | */ |
295 | | static inline size_t rtrim_whitespace(unsigned char *str) |
296 | 35.0k | { |
297 | 35.0k | size_t i; |
298 | | |
299 | 35.0k | if (!str) |
300 | 0 | return 0; |
301 | 35.0k | i = strlen((char *) str); |
302 | 63.1k | while (i) { |
303 | 62.1k | i--; |
304 | 62.1k | if (!isspace(str[i])) { |
305 | 34.0k | i++; |
306 | 34.0k | break; |
307 | 34.0k | } |
308 | 62.1k | } |
309 | 35.0k | str[i] = '\0'; |
310 | 35.0k | return i; |
311 | 35.0k | } Unexecuted instantiation: tab.c:rtrim_whitespace Unexecuted instantiation: tab_parse.c:rtrim_whitespace Unexecuted instantiation: utils.c:rtrim_whitespace Unexecuted instantiation: canonicalize.c:rtrim_whitespace Unexecuted instantiation: loopdev.c:rtrim_whitespace Unexecuted instantiation: path.c:rtrim_whitespace Unexecuted instantiation: strutils.c:rtrim_whitespace Unexecuted instantiation: sysfs.c:rtrim_whitespace Unexecuted instantiation: cache.c:rtrim_whitespace Unexecuted instantiation: fs.c:rtrim_whitespace Unexecuted instantiation: optmap.c:rtrim_whitespace Unexecuted instantiation: optlist.c:rtrim_whitespace Unexecuted instantiation: optstr.c:rtrim_whitespace Unexecuted instantiation: buffer.c:rtrim_whitespace Unexecuted instantiation: mbsalign.c:rtrim_whitespace Unexecuted instantiation: evaluate.c:rtrim_whitespace Line | Count | Source | 296 | 3.80k | { | 297 | 3.80k | size_t i; | 298 | | | 299 | 3.80k | if (!str) | 300 | 0 | return 0; | 301 | 3.80k | i = strlen((char *) str); | 302 | 9.25k | while (i) { | 303 | 8.51k | i--; | 304 | 8.51k | if (!isspace(str[i])) { | 305 | 3.05k | i++; | 306 | 3.05k | break; | 307 | 3.05k | } | 308 | 8.51k | } | 309 | 3.80k | str[i] = '\0'; | 310 | 3.80k | return i; | 311 | 3.80k | } |
Unexecuted instantiation: partitions.c:rtrim_whitespace Unexecuted instantiation: devname.c:rtrim_whitespace Unexecuted instantiation: devno.c:rtrim_whitespace Unexecuted instantiation: encode.c:rtrim_whitespace script.c:rtrim_whitespace Line | Count | Source | 296 | 10.2k | { | 297 | 10.2k | size_t i; | 298 | | | 299 | 10.2k | if (!str) | 300 | 0 | return 0; | 301 | 10.2k | i = strlen((char *) str); | 302 | 11.8k | while (i) { | 303 | 11.6k | i--; | 304 | 11.6k | if (!isspace(str[i])) { | 305 | 9.99k | i++; | 306 | 9.99k | break; | 307 | 9.99k | } | 308 | 11.6k | } | 309 | 10.2k | str[i] = '\0'; | 310 | 10.2k | return i; | 311 | 10.2k | } |
Unexecuted instantiation: ask.c:rtrim_whitespace Unexecuted instantiation: context.c:rtrim_whitespace Unexecuted instantiation: parttype.c:rtrim_whitespace Unexecuted instantiation: partition.c:rtrim_whitespace Unexecuted instantiation: wipe.c:rtrim_whitespace Unexecuted instantiation: dos.c:rtrim_whitespace Unexecuted instantiation: gpt.c:rtrim_whitespace Unexecuted instantiation: gen_uuid.c:rtrim_whitespace Line | Count | Source | 296 | 20.9k | { | 297 | 20.9k | size_t i; | 298 | | | 299 | 20.9k | if (!str) | 300 | 0 | return 0; | 301 | 20.9k | i = strlen((char *) str); | 302 | 41.9k | while (i) { | 303 | 41.9k | i--; | 304 | 41.9k | if (!isspace(str[i])) { | 305 | 20.9k | i++; | 306 | 20.9k | break; | 307 | 20.9k | } | 308 | 41.9k | } | 309 | 20.9k | str[i] = '\0'; | 310 | 20.9k | return i; | 311 | 20.9k | } |
Unexecuted instantiation: timeutils.c:rtrim_whitespace |
312 | | |
313 | | /* Removes whitespace from the left-hand side of a string. |
314 | | * |
315 | | * Returns size of the new string (without \0). |
316 | | */ |
317 | | static inline size_t ltrim_whitespace(unsigned char *str) |
318 | 10.7k | { |
319 | 10.7k | size_t len; |
320 | 10.7k | unsigned char *p; |
321 | | |
322 | 10.7k | if (!str) |
323 | 0 | return 0; |
324 | 21.7k | for (p = str; *p && isspace(*p); p++); |
325 | | |
326 | 10.7k | len = strlen((char *) p); |
327 | | |
328 | 10.7k | if (p > str) |
329 | 540 | memmove(str, p, len + 1); |
330 | | |
331 | 10.7k | return len; |
332 | 10.7k | } Unexecuted instantiation: tab.c:ltrim_whitespace Unexecuted instantiation: tab_parse.c:ltrim_whitespace Unexecuted instantiation: utils.c:ltrim_whitespace Unexecuted instantiation: canonicalize.c:ltrim_whitespace Unexecuted instantiation: loopdev.c:ltrim_whitespace Unexecuted instantiation: path.c:ltrim_whitespace Unexecuted instantiation: strutils.c:ltrim_whitespace Unexecuted instantiation: sysfs.c:ltrim_whitespace Unexecuted instantiation: cache.c:ltrim_whitespace Unexecuted instantiation: fs.c:ltrim_whitespace Unexecuted instantiation: optmap.c:ltrim_whitespace Unexecuted instantiation: optlist.c:ltrim_whitespace Unexecuted instantiation: optstr.c:ltrim_whitespace Unexecuted instantiation: buffer.c:ltrim_whitespace Unexecuted instantiation: mbsalign.c:ltrim_whitespace Unexecuted instantiation: evaluate.c:ltrim_whitespace Line | Count | Source | 318 | 1.84k | { | 319 | 1.84k | size_t len; | 320 | 1.84k | unsigned char *p; | 321 | | | 322 | 1.84k | if (!str) | 323 | 0 | return 0; | 324 | 3.51k | for (p = str; *p && isspace(*p); p++); | 325 | | | 326 | 1.84k | len = strlen((char *) p); | 327 | | | 328 | 1.84k | if (p > str) | 329 | 99 | memmove(str, p, len + 1); | 330 | | | 331 | 1.84k | return len; | 332 | 1.84k | } |
Unexecuted instantiation: partitions.c:ltrim_whitespace Unexecuted instantiation: devname.c:ltrim_whitespace Unexecuted instantiation: devno.c:ltrim_whitespace Unexecuted instantiation: encode.c:ltrim_whitespace script.c:ltrim_whitespace Line | Count | Source | 318 | 8.95k | { | 319 | 8.95k | size_t len; | 320 | 8.95k | unsigned char *p; | 321 | | | 322 | 8.95k | if (!str) | 323 | 0 | return 0; | 324 | 18.1k | for (p = str; *p && isspace(*p); p++); | 325 | | | 326 | 8.95k | len = strlen((char *) p); | 327 | | | 328 | 8.95k | if (p > str) | 329 | 441 | memmove(str, p, len + 1); | 330 | | | 331 | 8.95k | return len; | 332 | 8.95k | } |
Unexecuted instantiation: ask.c:ltrim_whitespace Unexecuted instantiation: context.c:ltrim_whitespace Unexecuted instantiation: parttype.c:ltrim_whitespace Unexecuted instantiation: partition.c:ltrim_whitespace Unexecuted instantiation: wipe.c:ltrim_whitespace Unexecuted instantiation: dos.c:ltrim_whitespace Unexecuted instantiation: gpt.c:ltrim_whitespace Unexecuted instantiation: gen_uuid.c:ltrim_whitespace Unexecuted instantiation: last.c:ltrim_whitespace Unexecuted instantiation: timeutils.c:ltrim_whitespace |
333 | | |
334 | | /* Removes left-hand, right-hand and repeating whitespaces. |
335 | | */ |
336 | | static inline size_t __normalize_whitespace( |
337 | | const unsigned char *src, |
338 | | size_t sz, |
339 | | unsigned char *dst, |
340 | | size_t len) |
341 | 0 | { |
342 | 0 | size_t i, x = 0; |
343 | 0 | int nsp = 0, intext = 0; |
344 | |
|
345 | 0 | if (!sz) |
346 | 0 | goto done; |
347 | | |
348 | 0 | for (i = 0, x = 0; i < sz && x < len - 1; ) { |
349 | 0 | if (isspace(src[i])) |
350 | 0 | nsp++; |
351 | 0 | else |
352 | 0 | nsp = 0, intext = 1; |
353 | |
|
354 | 0 | if (nsp > 1 || (nsp && !intext)) |
355 | 0 | i++; |
356 | 0 | else |
357 | 0 | dst[x++] = src[i++]; |
358 | 0 | } |
359 | 0 | if (nsp && x > 0) /* tailing space */ |
360 | 0 | x--; |
361 | 0 | done: |
362 | 0 | dst[x] = '\0'; |
363 | 0 | return x; |
364 | 0 | } Unexecuted instantiation: tab.c:__normalize_whitespace Unexecuted instantiation: tab_parse.c:__normalize_whitespace Unexecuted instantiation: utils.c:__normalize_whitespace Unexecuted instantiation: canonicalize.c:__normalize_whitespace Unexecuted instantiation: loopdev.c:__normalize_whitespace Unexecuted instantiation: path.c:__normalize_whitespace Unexecuted instantiation: strutils.c:__normalize_whitespace Unexecuted instantiation: sysfs.c:__normalize_whitespace Unexecuted instantiation: cache.c:__normalize_whitespace Unexecuted instantiation: fs.c:__normalize_whitespace Unexecuted instantiation: optmap.c:__normalize_whitespace Unexecuted instantiation: optlist.c:__normalize_whitespace Unexecuted instantiation: optstr.c:__normalize_whitespace Unexecuted instantiation: buffer.c:__normalize_whitespace Unexecuted instantiation: mbsalign.c:__normalize_whitespace Unexecuted instantiation: evaluate.c:__normalize_whitespace Unexecuted instantiation: probe.c:__normalize_whitespace Unexecuted instantiation: partitions.c:__normalize_whitespace Unexecuted instantiation: devname.c:__normalize_whitespace Unexecuted instantiation: devno.c:__normalize_whitespace Unexecuted instantiation: encode.c:__normalize_whitespace Unexecuted instantiation: script.c:__normalize_whitespace Unexecuted instantiation: ask.c:__normalize_whitespace Unexecuted instantiation: context.c:__normalize_whitespace Unexecuted instantiation: parttype.c:__normalize_whitespace Unexecuted instantiation: partition.c:__normalize_whitespace Unexecuted instantiation: wipe.c:__normalize_whitespace Unexecuted instantiation: dos.c:__normalize_whitespace Unexecuted instantiation: gpt.c:__normalize_whitespace Unexecuted instantiation: gen_uuid.c:__normalize_whitespace Unexecuted instantiation: last.c:__normalize_whitespace Unexecuted instantiation: timeutils.c:__normalize_whitespace |
365 | | |
366 | | static inline size_t normalize_whitespace(unsigned char *str) |
367 | 0 | { |
368 | 0 | size_t sz = strlen((char *) str); |
369 | 0 | return __normalize_whitespace(str, sz, str, sz + 1); |
370 | 0 | } Unexecuted instantiation: tab.c:normalize_whitespace Unexecuted instantiation: tab_parse.c:normalize_whitespace Unexecuted instantiation: utils.c:normalize_whitespace Unexecuted instantiation: canonicalize.c:normalize_whitespace Unexecuted instantiation: loopdev.c:normalize_whitespace Unexecuted instantiation: path.c:normalize_whitespace Unexecuted instantiation: strutils.c:normalize_whitespace Unexecuted instantiation: sysfs.c:normalize_whitespace Unexecuted instantiation: cache.c:normalize_whitespace Unexecuted instantiation: fs.c:normalize_whitespace Unexecuted instantiation: optmap.c:normalize_whitespace Unexecuted instantiation: optlist.c:normalize_whitespace Unexecuted instantiation: optstr.c:normalize_whitespace Unexecuted instantiation: buffer.c:normalize_whitespace Unexecuted instantiation: mbsalign.c:normalize_whitespace Unexecuted instantiation: evaluate.c:normalize_whitespace Unexecuted instantiation: probe.c:normalize_whitespace Unexecuted instantiation: partitions.c:normalize_whitespace Unexecuted instantiation: devname.c:normalize_whitespace Unexecuted instantiation: devno.c:normalize_whitespace Unexecuted instantiation: encode.c:normalize_whitespace Unexecuted instantiation: script.c:normalize_whitespace Unexecuted instantiation: ask.c:normalize_whitespace Unexecuted instantiation: context.c:normalize_whitespace Unexecuted instantiation: parttype.c:normalize_whitespace Unexecuted instantiation: partition.c:normalize_whitespace Unexecuted instantiation: wipe.c:normalize_whitespace Unexecuted instantiation: dos.c:normalize_whitespace Unexecuted instantiation: gpt.c:normalize_whitespace Unexecuted instantiation: gen_uuid.c:normalize_whitespace Unexecuted instantiation: last.c:normalize_whitespace Unexecuted instantiation: timeutils.c:normalize_whitespace |
371 | | |
372 | | static inline void strrep(char *s, int find, int replace) |
373 | 0 | { |
374 | 0 | while (s && *s && (s = strchr(s, find)) != NULL) |
375 | 0 | *s++ = replace; |
376 | 0 | } Unexecuted instantiation: tab.c:strrep Unexecuted instantiation: tab_parse.c:strrep Unexecuted instantiation: utils.c:strrep Unexecuted instantiation: canonicalize.c:strrep Unexecuted instantiation: loopdev.c:strrep Unexecuted instantiation: path.c:strrep Unexecuted instantiation: strutils.c:strrep Unexecuted instantiation: sysfs.c:strrep Unexecuted instantiation: cache.c:strrep Unexecuted instantiation: fs.c:strrep Unexecuted instantiation: optmap.c:strrep Unexecuted instantiation: optlist.c:strrep Unexecuted instantiation: optstr.c:strrep Unexecuted instantiation: buffer.c:strrep Unexecuted instantiation: mbsalign.c:strrep Unexecuted instantiation: evaluate.c:strrep Unexecuted instantiation: probe.c:strrep Unexecuted instantiation: partitions.c:strrep Unexecuted instantiation: devname.c:strrep Unexecuted instantiation: devno.c:strrep Unexecuted instantiation: encode.c:strrep Unexecuted instantiation: script.c:strrep Unexecuted instantiation: ask.c:strrep Unexecuted instantiation: context.c:strrep Unexecuted instantiation: parttype.c:strrep Unexecuted instantiation: partition.c:strrep Unexecuted instantiation: wipe.c:strrep Unexecuted instantiation: dos.c:strrep Unexecuted instantiation: gpt.c:strrep Unexecuted instantiation: gen_uuid.c:strrep Unexecuted instantiation: last.c:strrep Unexecuted instantiation: timeutils.c:strrep |
377 | | |
378 | | static inline void strrem(char *s, int rem) |
379 | 0 | { |
380 | 0 | char *p; |
381 | 0 |
|
382 | 0 | if (!s) |
383 | 0 | return; |
384 | 0 | for (p = s; *s; s++) { |
385 | 0 | if (*s != rem) |
386 | 0 | *p++ = *s; |
387 | 0 | } |
388 | 0 | *p = '\0'; |
389 | 0 | } Unexecuted instantiation: tab.c:strrem Unexecuted instantiation: tab_parse.c:strrem Unexecuted instantiation: utils.c:strrem Unexecuted instantiation: canonicalize.c:strrem Unexecuted instantiation: loopdev.c:strrem Unexecuted instantiation: path.c:strrem Unexecuted instantiation: strutils.c:strrem Unexecuted instantiation: sysfs.c:strrem Unexecuted instantiation: cache.c:strrem Unexecuted instantiation: fs.c:strrem Unexecuted instantiation: optmap.c:strrem Unexecuted instantiation: optlist.c:strrem Unexecuted instantiation: optstr.c:strrem Unexecuted instantiation: buffer.c:strrem Unexecuted instantiation: mbsalign.c:strrem Unexecuted instantiation: evaluate.c:strrem Unexecuted instantiation: probe.c:strrem Unexecuted instantiation: partitions.c:strrem Unexecuted instantiation: devname.c:strrem Unexecuted instantiation: devno.c:strrem Unexecuted instantiation: encode.c:strrem Unexecuted instantiation: script.c:strrem Unexecuted instantiation: ask.c:strrem Unexecuted instantiation: context.c:strrem Unexecuted instantiation: parttype.c:strrem Unexecuted instantiation: partition.c:strrem Unexecuted instantiation: wipe.c:strrem Unexecuted instantiation: dos.c:strrem Unexecuted instantiation: gpt.c:strrem Unexecuted instantiation: gen_uuid.c:strrem Unexecuted instantiation: last.c:strrem Unexecuted instantiation: timeutils.c:strrem |
390 | | |
391 | | extern char *strnconcat(const char *s, const char *suffix, size_t b); |
392 | | extern char *strconcat(const char *s, const char *suffix); |
393 | | extern char *strfconcat(const char *s, const char *format, ...) |
394 | | __attribute__ ((__format__ (__printf__, 2, 3))); |
395 | | |
396 | | extern int strappend(char **a, const char *b); |
397 | | |
398 | | extern const char *split(const char **state, size_t *l, const char *separator, int quoted); |
399 | | |
400 | | extern char *ul_strchr_escaped(const char *s, int c); |
401 | | |
402 | | extern int skip_fline(FILE *fp); |
403 | | extern int ul_stralnumcmp(const char *p1, const char *p2); |
404 | | |
405 | | extern int ul_optstr_next(char **optstr, char **name, size_t *namesz, char **value, size_t *valsz); |
406 | | |
407 | | #endif |