diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-05-02 18:38:19 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-05-02 18:38:19 +0300 |
commit | bd9de5ec9020384334b63582c7640372a9a2d022 (patch) | |
tree | bc6018e2a7f02ffcd284dfcaea3f1e8d5baa054a /lib/libc/string0.c | |
parent | 5302c3e8c4c2a3b7def285df1ec95285913c6176 (diff) | |
download | micropython-bd9de5ec9020384334b63582c7640372a9a2d022.tar.gz micropython-bd9de5ec9020384334b63582c7640372a9a2d022.zip |
lib/libc/string0: Add strncpy() implementation.
Diffstat (limited to 'lib/libc/string0.c')
-rw-r--r-- | lib/libc/string0.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/libc/string0.c b/lib/libc/string0.c index 1b37169edd..be003a1bc1 100644 --- a/lib/libc/string0.c +++ b/lib/libc/string0.c @@ -169,6 +169,15 @@ char *strcpy(char *dest, const char *src) { return dest; } +char *strncpy(char *dest, const char *src, size_t dest_sz) { + char *d = dest; + while (*src && --dest_sz) { + *d++ = *src++; + } + *d = '\0'; + return dest; +} + // needed because gcc optimises strcpy + strcat to this char *stpcpy(char *dest, const char *src) { while (*src) { |