Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!ucsd!rutgers!att!lzaz!bds From: bds@lzaz.ATT.COM (B.SZABLAK) Newsgroups: comp.os.minix Subject: New version of strncpy Keywords: ATARI ST, stevie Message-ID: <345@lzaz.ATT.COM> Date: 4 Jan 89 14:53:52 GMT Organization: AT&T ISL Lincroft NJ USA Lines: 20 The recent version of stevie posted here would crash frequently on "puts". I've tracked the problem down to a bug in strncpy. Following is the new version of strncpy that fixes the problems I was having (stevie whas calling strncpy with n == 0 which may be a bug in itself): char *strncpy(s1, s2, n) register char *s1, *s2; register n; { /* Copy s2 to s1, but at most n characters. */ char *original = s1; while (n > 0 && *s2) { *s1++ = *s2++; --n; } while (--n >= 0) *s1++ = 0; return(original); }