summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commonlib/Makefile.mk4
-rw-r--r--src/commonlib/bsd/include/commonlib/bsd/string.h10
-rw-r--r--src/commonlib/bsd/string.c15
-rw-r--r--src/include/string.h8
-rw-r--r--src/lib/string.c9
5 files changed, 30 insertions, 16 deletions
diff --git a/src/commonlib/Makefile.mk b/src/commonlib/Makefile.mk
index 30aaddf2cc..00f3629c1e 100644
--- a/src/commonlib/Makefile.mk
+++ b/src/commonlib/Makefile.mk
@@ -65,3 +65,7 @@ decompressor-y += bsd/gcd.c
all-y += bsd/gcd.c
all-y += bsd/ipchksum.c
+
+decompressor-y += bsd/string.c
+smm-y += bsd/string.c
+all-y += bsd/string.c
diff --git a/src/commonlib/bsd/include/commonlib/bsd/string.h b/src/commonlib/bsd/include/commonlib/bsd/string.h
new file mode 100644
index 0000000000..bbd4754800
--- /dev/null
+++ b/src/commonlib/bsd/include/commonlib/bsd/string.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+#ifndef _COMMONLIB_BSD_STRING_H_
+#define _COMMONLIB_BSD_STRING_H_
+
+#include <stdint.h>
+
+unsigned int skip_atoi(char **ptr);
+
+#endif /* _COMMONLIB_BSD_STRING_H_ */
diff --git a/src/commonlib/bsd/string.c b/src/commonlib/bsd/string.c
new file mode 100644
index 0000000000..3286d41b1c
--- /dev/null
+++ b/src/commonlib/bsd/string.c
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+#include <commonlib/bsd/string.h>
+#include <ctype.h>
+
+unsigned int skip_atoi(char **ptr)
+{
+ unsigned int result = 0;
+ char *str;
+
+ for (str = *ptr; isdigit(str[0]); str++)
+ result = result * 10 + (str[0] - '0');
+ *ptr = str;
+ return result;
+}
diff --git a/src/include/string.h b/src/include/string.h
index 33f0dfe196..e752f8f531 100644
--- a/src/include/string.h
+++ b/src/include/string.h
@@ -3,6 +3,7 @@
#ifndef STRING_H
#define STRING_H
+#include <commonlib/bsd/string.h>
#include <stddef.h>
void *memcpy(void *dest, const void *src, size_t n);
@@ -36,11 +37,4 @@ long atol(const char *str);
*/
char *strrchr(const char *s, int c);
-/*
- * Parses an unsigned integer and moves the input pointer forward to the first
- * character that's not a valid digit. s and *s must not be NULL. Result
- * undefined if it overruns the return type size.
- */
-unsigned int skip_atoi(char **s);
-
#endif /* STRING_H */
diff --git a/src/lib/string.c b/src/lib/string.c
index dd7d1512ea..d23ed1f7e5 100644
--- a/src/lib/string.c
+++ b/src/lib/string.c
@@ -125,15 +125,6 @@ int strncmp(const char *s1, const char *s2, int maxlen)
return 0;
}
-unsigned int skip_atoi(char **s)
-{
- unsigned int i = 0;
-
- while (isdigit(**s))
- i = i*10 + *((*s)++) - '0';
- return i;
-}
-
int strspn(const char *str, const char *spn)
{
int ret = 0;