1 /* SPDX-License-Identifier: BSD-3-Clause */
3 #include <commonlib/bsd/string.h>
7 size_t strlen(const char *str
)
16 size_t strnlen(const char *str
, size_t maxlen
)
18 const char *ptr
= str
;
19 const char *end
= str
+ maxlen
;
25 /* Make sure this checks for ==, not >=, because the calculation
26 for `end` may overflow in some edge cases. */
33 char *strcat(char *dst
, const char *src
)
35 char *ptr
= dst
+ strlen(dst
);
44 char *strncat(char *dst
, const char *src
, size_t n
)
46 char *ptr
= dst
+ strlen(dst
);
48 /* Not using strncpy() because '\0' may not be appended. */
49 while (n
-- > 0 && *src
)
56 unsigned int skip_atoi(char **ptr
)
58 unsigned int result
= 0;
61 for (str
= *ptr
; isdigit(str
[0]); str
++)
62 result
= result
* 10 + (str
[0] - '0');