scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 6cdd955f1d50996aa6b411756910e813f591e2f0
parent 6183f157e94dee4dd7ae776c621012e18a8da7ef
Author: Quentin Rameau <quinq@fifth.space>
Date:   Fri, 17 Feb 2017 00:21:50 +0100

[libc] Fix strncpy

Don't forget n is unsigned.

Diffstat:
Mlibc/src/strncpy.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/src/strncpy.c b/libc/src/strncpy.c @@ -7,8 +7,8 @@ strncpy(char *dst, const char *src, size_t n) { char *ret = dst; - while (n-- > 0 && (*dst++ = *src++)) - /* nothing */; + for (; n > 0 && *src; --n) + *dst++ = *src++; while (n-- > 0) *dst++ = '\0'; return ret;