/*
* strncpy.c
- *
- * strncpy()
*/
#include <string.h>
const char *p = src;
char ch;
- while ( n-- ) {
+ while (n) {
+ n--;
*q++ = ch = *p++;
if ( !ch )
break;
}
+ /* The specs say strncpy() fills the entire buffer with NUL. Sigh. */
+ memset(q, 0, n);
+
return dst;
}