diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-11-22 09:47:20 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-11-25 08:43:59 +0100 |
commit | 07d2f1fd3e595aef539dc0443125bd08708e63ff (patch) | |
tree | 46342a8c5077e9ace36547428ee1f3fe1c580e9d /lib | |
parent | d3e90b58e7a5cbb1b74da98aed9dd4ec18c84d77 (diff) | |
download | barebox-07d2f1fd3e595aef539dc0443125bd08708e63ff.tar.gz barebox-07d2f1fd3e595aef539dc0443125bd08708e63ff.tar.xz |
lib: implement wcsnlen
This will come in handy for implementing %ls in the follow up commit.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20211122084732.2597109-19-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/wchar.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/wchar.c b/lib/wchar.c index 3be228b5a7..250538dd85 100644 --- a/lib/wchar.c +++ b/lib/wchar.c @@ -28,6 +28,15 @@ size_t wcslen(const wchar_t *s) return len; } +size_t wcsnlen(const wchar_t * s, size_t count) +{ + const wchar_t *sc; + + for (sc = s; count-- && *sc != L'\0'; ++sc) + /* nothing */; + return sc - s; +} + wchar_t *strdup_wchar(const wchar_t *src) { int len = wcslen(src); |