Lines Matching refs:str

6 bool str_is_numeric(const char *str, char end_char)
8 if (*str == '\0' || *str == end_char)
11 while (*str != '\0' && *str != end_char) {
12 if (*str < '0' || *str > '9')
14 str++;
20 bool str_is_float(const char *str, char end_char)
25 if (*str == '\0' || *str == end_char)
28 while (*str != '\0' && *str != end_char) {
29 if (*str == '.') {
33 str++;
37 if (*str < '0' || *str > '9')
40 str++;
51 int name(const char *str, type *num_r, const char **endp_r) \
54 if (str_parse_uintmax(str, &l, endp_r) < 0 || l > (type)-1) \
67 int name(const char *str, type *num_r) \
70 if (str_to_uintmax(str, &l) < 0 || l > (type)-1) \
82 int str_parse_uintmax(const char *str, uintmax_t *num_r,
87 if (*str < '0' || *str > '9')
94 if ((uintmax_t)(*str - '0') > ((uintmax_t)-1 % 10))
97 n = n * 10 + (*str - '0');
98 str++;
99 } while (*str >= '0' && *str <= '9');
102 *endp_r = str;
106 int str_to_uintmax(const char *str, uintmax_t *num_r)
110 int ret = str_parse_uintmax(str, &n, &endp);
117 bool str_uint_equals(const char *str, uintmax_t num)
121 if (str_to_uintmax(str, &l) < 0)
131 int name(const char *str, type *num_r, const char **endp_r) \
134 if (str_parse_uintmax_hex(str, &l, endp_r) < 0 || l > (type)-1) \
147 int name(const char *str, type *num_r) \
150 if (str_to_uintmax_hex(str, &l) < 0 || l > (type)-1) \
181 int str_parse_uintmax_hex(const char *str, uintmax_t *num_r,
187 if (_str_parse_hex(*str, &hex) < 0)
194 str++;
195 } while (_str_parse_hex(*str, &hex) >= 0);
197 *endp_r = str;
201 int str_to_uintmax_hex(const char *str, uintmax_t *num_r)
205 int ret = str_parse_uintmax_hex(str, &n, &endp);
217 int name(const char *str, type *num_r, const char **endp_r) \
220 if (str_parse_uintmax_oct(str, &l, endp_r) < 0 || l > (type)-1) \
233 int name(const char *str, type *num_r) \
236 if (str_to_uintmax_oct(str, &l) < 0 || l > (type)-1) \
248 int str_parse_uintmax_oct(const char *str, uintmax_t *num_r,
253 if (*str < '0' || *str > '7')
256 for (; *str >= '0' && *str <= '7'; str++) {
259 n = (n << 3) + (*str - '0');
262 *endp_r = str;
266 int str_to_uintmax_oct(const char *str, uintmax_t *num_r)
270 int ret = str_parse_uintmax_oct(str, &n, &endp);
282 int name(const char *str, type *num_r, const char **endp_r) \
285 if (str_parse_intmax(str, &l, endp_r) < 0) \
300 int name(const char *str, type *num_r) \
303 if (str_to_intmax(str, &l) < 0) \
317 int str_parse_intmax(const char *str, intmax_t *num_r,
323 if (*str == '-') {
325 str++;
327 if (str_parse_uintmax(str, &l, endp_r) < 0)
341 int str_to_intmax(const char *str, intmax_t *num_r)
345 int ret = str_parse_intmax(str, &n, &endp);
368 int str_to_uid(const char *str, uid_t *num_r)
372 if (str_to_uintmax(str, &l) < 0)
381 int str_to_gid(const char *str, gid_t *num_r)
385 if (str_to_uintmax(str, &l) < 0)
397 int str_to_pid(const char *str, pid_t *num_r)
401 if (str_to_uintmax(str, &l) < 0)
410 int str_to_ino(const char *str, ino_t *num_r)
414 if (str_to_uintmax(str, &l) < 0)
423 int str_to_uoff(const char *str, uoff_t *num_r)
427 if (str_to_uintmax(str, &l) < 0)
436 int str_to_time(const char *str, time_t *num_r)
440 if (str_to_intmax(str, &l) < 0)
453 const char *str_num_error(const char *str)
455 if (*str == '-') {
456 if (!str_is_numeric(str + 1, '\0'))
460 if (!str_is_numeric(str, '\0'))