diff options
author | Maarten Lankhorst <maarten.lankhorst@linux.intel.com> | 2020-02-12 14:08:59 +0100 |
---|---|---|
committer | Maarten Lankhorst <maarten.lankhorst@linux.intel.com> | 2020-02-12 14:08:59 +0100 |
commit | 74c12ee02af109adcde36ec184fa59c0afb0edaa (patch) | |
tree | dfe4615e0a5e3f8583e685aacdd9a0908e9ffbe3 /lib/string.c | |
parent | 48bc281e4bf049abd3bb98371209315651bf4a14 (diff) | |
parent | bb6d3fb354c5ee8d6bde2d576eb7220ea09862b9 (diff) |
Merge v5.6-rc1 into drm-misc-fixes
We're based on v5.6, need v5.6-rc1 at least. :)
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Diffstat (limited to 'lib/string.c')
-rw-r--r-- | lib/string.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c index 08ec58cc673b..f607b967d978 100644 --- a/lib/string.c +++ b/lib/string.c @@ -434,6 +434,23 @@ char *strchrnul(const char *s, int c) EXPORT_SYMBOL(strchrnul); #endif +/** + * strnchrnul - Find and return a character in a length limited string, + * or end of string + * @s: The string to be searched + * @count: The number of characters to be searched + * @c: The character to search for + * + * Returns pointer to the first occurrence of 'c' in s. If c is not found, + * then return a pointer to the last character of the string. + */ +char *strnchrnul(const char *s, size_t count, int c) +{ + while (count-- && *s && *s != (char)c) + s++; + return (char *)s; +} + #ifndef __HAVE_ARCH_STRRCHR /** * strrchr - Find the last occurrence of a character in a string |