summaryrefslogtreecommitdiffstats
path: root/pbl/string.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-12-08 10:05:07 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2014-12-09 12:56:10 +0100
commit2c670b8f1d426dade00c25f47bfa01267d43cc94 (patch)
tree5917edd8803ebf3ebaebaa141267dac9ca69ea39 /pbl/string.c
parent5844f3c3c7a12d0b09a2cb26f8a3ac88b4408e37 (diff)
downloadbarebox-2c670b8f1d426dade00c25f47bfa01267d43cc94.tar.gz
barebox-2c670b8f1d426dade00c25f47bfa01267d43cc94.tar.xz
PBL: Add strnlen, needed for printf support
vsprintf needs strnlen, so in oder to add console support to the PBL we need a strnlen implementation. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'pbl/string.c')
-rw-r--r--pbl/string.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/pbl/string.c b/pbl/string.c
index b773f5cf7c..927c92dc05 100644
--- a/pbl/string.c
+++ b/pbl/string.c
@@ -119,3 +119,17 @@ void *memset(void *s, int c, size_t count)
*xs++ = c;
return s;
}
+
+/**
+ * strnlen - Find the length of a length-limited string
+ * @s: The string to be sized
+ * @count: The maximum number of bytes to search
+ */
+size_t strnlen(const char * s, size_t count)
+{
+ const char *sc;
+
+ for (sc = s; count-- && *sc != '\0'; ++sc)
+ /* nothing */;
+ return sc - s;
+}