Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1434915

[PATCH 1/6] lib: string: add function strtolower()

From Markus Mayer <mmayer@broadcom.com>
Newsgroups linux.kernel
Subject [PATCH 1/6] lib: string: add function strtolower()
Date 2016-07-01 02:00 +0200
Message-ID <rPU2e-7uX-19@gated-at.bofh.it> (permalink)
References <rPU2d-7uX-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Add a function called strtolower() to convert strings to lower case
in-place, overwriting the original string.

This seems to be a recurring requirement in the kernel that is
currently being solved by several duplicated implementations doing the
same thing.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
---
 include/linux/string.h |  1 +
 lib/string.c           | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index 26b6f6a..aad605e 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -116,6 +116,7 @@ extern void * memchr(const void *,int,__kernel_size_t);
 #endif
 void *memchr_inv(const void *s, int c, size_t n);
 char *strreplace(char *s, char old, char new);
+char *strtolower(char *s);
 
 extern void kfree_const(const void *x);
 
diff --git a/lib/string.c b/lib/string.c
index ed83562..6e3b560 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -952,3 +952,17 @@ char *strreplace(char *s, char old, char new)
 	return s;
 }
 EXPORT_SYMBOL(strreplace);
+
+char *strtolower(char *s)
+{
+	char *p;
+
+        if (unlikely(!s))
+                return NULL;
+
+	for (p = s; *p; p++)
+		*p = tolower(*p);
+
+	return s;
+}
+EXPORT_SYMBOL(strtolower);
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/6] lib: string: add function strtolower() Markus Mayer <mmayer@broadcom.com> - 2016-07-01 02:00 +0200
  [PATCH 4/6] ACPI / device_sysfs: make use of new strtolower() function Markus Mayer <mmayer@broadcom.com> - 2016-07-01 02:00 +0200
    Re: [PATCH 4/6] ACPI / device_sysfs: make use of new strtolower() function "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-07-01 22:50 +0200
  [PATCH 2/6] drm/nouveau/core: make use of new strtolower() function Markus Mayer <mmayer@broadcom.com> - 2016-07-01 02:00 +0200
    Re: [Nouveau] [PATCH 2/6] drm/nouveau/core: make use of new  strtolower() function Alexandre Courbot <gnurou@gmail.com> - 2016-07-02 03:20 +0200
      Re: [Nouveau] [PATCH 2/6] drm/nouveau/core: make use of new  strtolower() function Markus Mayer <markus.mayer@broadcom.com> - 2016-07-02 17:30 +0200
        Re: [Nouveau] [PATCH 2/6] drm/nouveau/core: make use of new  strtolower() function Alexandre Courbot <gnurou@gmail.com> - 2016-07-04 03:40 +0200
          Re: [Nouveau] [PATCH 2/6] drm/nouveau/core: make use of new  strtolower() function Alexandre Courbot <gnurou@gmail.com> - 2016-07-04 05:50 +0200
  [PATCH 3/6] ACPICA: make use of new strtolower() function Markus Mayer <mmayer@broadcom.com> - 2016-07-01 02:00 +0200
    RE: [PATCH 3/6] ACPICA: make use of new strtolower() function "Moore, Robert" <robert.moore@intel.com> - 2016-07-01 03:20 +0200
      Re: [PATCH 3/6] ACPICA: make use of new strtolower() function Markus Mayer <markus.mayer@broadcom.com> - 2016-07-01 06:20 +0200
        RE: [PATCH 3/6] ACPICA: make use of new strtolower() function "Moore, Robert" <robert.moore@intel.com> - 2016-07-01 06:40 +0200
  [PATCH 5/6] staging: speakup: replace spk_strlwr() with strtolower() Markus Mayer <mmayer@broadcom.com> - 2016-07-01 02:00 +0200
    Re: [PATCH 5/6] staging: speakup: replace spk_strlwr() with  strtolower() Samuel Thibault <samuel.thibault@ens-lyon.org> - 2016-07-01 02:40 +0200
  [PATCH 1/6] lib: string: add function strtolower() Markus Mayer <mmayer@broadcom.com> - 2016-07-01 02:00 +0200
    Re: [PATCH 1/6] lib: string: add function strtolower() Jani Nikula <jani.nikula@linux.intel.com> - 2016-07-01 13:00 +0200
      Re: [PATCH 1/6] lib: string: add function strtolower() Markus Mayer <markus.mayer@broadcom.com> - 2016-07-01 19:20 +0200
        Re: [PATCH 1/6] lib: string: add function strtolower() Jani Nikula <jani.nikula@linux.intel.com> - 2016-07-01 19:40 +0200
    Re: [PATCH 1/6] lib: string: add function strtolower() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-07-01 23:10 +0200
      Re: [PATCH 1/6] lib: string: add function strtolower() Markus Mayer <markus.mayer@broadcom.com> - 2016-07-04 22:20 +0200

csiph-web