- millert@cvs.openbsd.org 2006/05/05 15:27:38
[openbsd-compat/strlcpy.c] Convert do {} while loop -> while {} for clarity. No binary change on most architectures. From Oliver Smith. OK deraadt@ and henning@
This commit is contained in:
parent
add1e20802
commit
b9cd0491f7
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */
|
||||
/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
|
@ -37,11 +37,11 @@ strlcpy(char *dst, const char *src, size_t siz)
|
|||
size_t n = siz;
|
||||
|
||||
/* Copy as many bytes as will fit */
|
||||
if (n != 0 && --n != 0) {
|
||||
do {
|
||||
if ((*d++ = *s++) == 0)
|
||||
if (n != 0) {
|
||||
while (--n != 0) {
|
||||
if ((*d++ = *s++) == '\0')
|
||||
break;
|
||||
} while (--n != 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Not enough room in dst, add NUL and traverse rest of src */
|
||||
|
|
Loading…
Reference in New Issue