diff mbox series

[04/29] util: add function to convert string to lowercase

Message ID 20211011112156.44192-5-sbabic@denx.de
State Changes Requested
Headers show
Series DELTA Update | expand

Commit Message

Stefano Babic Oct. 11, 2021, 11:21 a.m. UTC
No function available in libc, just add to utilities.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 core/util.c    | 12 ++++++++++++
 include/util.h |  1 +
 2 files changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/core/util.c b/core/util.c
index 7e96652..2844e1d 100644
--- a/core/util.c
+++ b/core/util.c
@@ -269,6 +269,18 @@  char *substring(const char *src, int first, int len) {
 	return s;
 }
 
+/*
+ * Convert all chars of a string to lower,
+ * there is no ready to use function
+ */
+
+char *string_tolower(char *s)
+{
+	char *p = s;
+	for ( ; *p; ++p) *p = tolower(*p);
+	return s;
+}
+
 int openfileoutput(const char *filename)
 {
 	int fdout;
diff --git a/include/util.h b/include/util.h
index 31f67b1..3d328ee 100644
--- a/include/util.h
+++ b/include/util.h
@@ -190,6 +190,7 @@  char **splitargs(char *args, int *argc);
 char *mstrcat(const char **nodes, const char *delim);
 char** string_split(const char* a_str, const char a_delim);
 char *substring(const char *src, int first, int len);
+char *string_tolower(char *s);
 size_t snescape(char *dst, size_t n, const char *src);
 void freeargs (char **argv);
 int get_hw_revision(struct hw_type *hw);