Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/string add netbsd rcsid's



details:   https://anonhg.NetBSD.org/src/rev/adaaedf0edb0
branches:  trunk
changeset: 476183:adaaedf0edb0
user:      lukem <lukem%NetBSD.org@localhost>
date:      Wed Sep 08 22:56:55 1999 +0000

description:
add netbsd rcsid's
update for knf (return value on separate line to function name...)
check dst and src aren't null pointers before trying to use them
enable strlcat/strlcpy

diffstat:

 lib/libc/string/Makefile.inc |   9 +++++----
 lib/libc/string/strlcat.c    |  12 +++++++++---
 lib/libc/string/strlcpy.3    |   5 +++--
 lib/libc/string/strlcpy.c    |  12 +++++++++---
 4 files changed, 26 insertions(+), 12 deletions(-)

diffs (134 lines):

diff -r 3dce2c925d5d -r adaaedf0edb0 lib/libc/string/Makefile.inc
--- a/lib/libc/string/Makefile.inc      Wed Sep 08 22:29:46 1999 +0000
+++ b/lib/libc/string/Makefile.inc      Wed Sep 08 22:56:55 1999 +0000
@@ -1,10 +1,10 @@
 #      from: @(#)Makefile.inc  8.1 (Berkeley) 6/4/93
-#      $NetBSD: Makefile.inc,v 1.48 1999/02/24 15:05:21 drochner Exp $
+#      $NetBSD: Makefile.inc,v 1.49 1999/09/08 22:56:56 lukem Exp $
 
 # string sources
 .PATH: ${ARCHDIR}/string ${.CURDIR}/string
 
-SRCS+= bm.c strcasecmp.c strcoll.c strdup.c strerror.c \
+SRCS+= bm.c strcasecmp.c strcoll.c strdup.c strerror.c strlcat.c strlcpy.c \
        strmode.c strsignal.c strtok.c strtok_r.c strxfrm.c \
        __strerror.c __strsignal.c
 
@@ -40,8 +40,8 @@
 
 MAN+=  bm.3 bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 memccpy.3 memchr.3 \
        memcmp.3 memcpy.3 memmove.3 memset.3 rindex.3 strcasecmp.3 strcat.3 \
-       strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strerror.3 \
-       string.3 strlen.3 strmode.3 strdup.3 strpbrk.3 strrchr.3 strsep.3 \
+       strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strdup.3 strerror.3 \
+       string.3 strlcpy.3 strlen.3 strmode.3 strpbrk.3 strrchr.3 strsep.3 \
        strsignal.3 strspn.3 strstr.3 strtok.3 strxfrm.3 swab.3
 
 MLINKS+=bm.3 bm_comp.3 bm.3 bm_exec.3 bm.3 bm_free.3
@@ -49,4 +49,5 @@
 MLINKS+=strcat.3 strncat.3
 MLINKS+=strcmp.3 strncmp.3
 MLINKS+=strcpy.3 strncpy.3
+MLINKS+=strlcpy.3 strlcat.3
 MLINKS+=strtok.3 strtok_r.3
diff -r 3dce2c925d5d -r adaaedf0edb0 lib/libc/string/strlcat.c
--- a/lib/libc/string/strlcat.c Wed Sep 08 22:29:46 1999 +0000
+++ b/lib/libc/string/strlcat.c Wed Sep 08 22:56:55 1999 +0000
@@ -1,4 +1,5 @@
-/*     $OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $     */
+/*     $NetBSD: strlcat.c,v 1.2 1999/09/08 22:56:55 lukem Exp $        */
+/*     from OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp   */
 
 /*
  * Copyright (c) 1998 Todd C. Miller <Todd.Miller%courtesan.com@localhost>
@@ -27,8 +28,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $";
+__RCSID("$NetBSD: strlcat.c,v 1.2 1999/09/08 22:56:55 lukem Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -40,7 +42,8 @@
  * will be copied.  Always NUL terminates (unless siz == 0).
  * Returns strlen(src); if retval >= siz, truncation occurred.
  */
-size_t strlcat(dst, src, siz)
+size_t
+strlcat(dst, src, siz)
        char *dst;
        const char *src;
        size_t siz;
@@ -50,6 +53,9 @@
        register size_t n = siz;
        size_t dlen;
 
+       if (dst == NULL || src == NULL)
+               return (0);
+
        /* Find the end of dst and adjust bytes left but don't go past end */
        while (*d != '\0' && n-- != 0)
                d++;
diff -r 3dce2c925d5d -r adaaedf0edb0 lib/libc/string/strlcpy.3
--- a/lib/libc/string/strlcpy.3 Wed Sep 08 22:29:46 1999 +0000
+++ b/lib/libc/string/strlcpy.3 Wed Sep 08 22:56:55 1999 +0000
@@ -1,4 +1,5 @@
-.\" $OpenBSD: strlcpy.3,v 1.6 1999/09/04 02:22:46 pjanzen Exp $
+.\"    $NetBSD: strlcpy.3,v 1.2 1999/09/08 22:56:56 lukem Exp $
+.\" from OpenBSD: strlcpy.3,v 1.6 1999/09/04 02:22:46 pjanzen Exp 
 .\"
 .\" Copyright (c) 1998 Todd C. Miller <Todd.Miller%courtesan.com@localhost>
 .\" All rights reserved.
@@ -25,7 +26,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd June 22, 1998
+.Dd September 9, 1999
 .Dt STRLCPY 3
 .Os
 .Sh NAME
diff -r 3dce2c925d5d -r adaaedf0edb0 lib/libc/string/strlcpy.c
--- a/lib/libc/string/strlcpy.c Wed Sep 08 22:29:46 1999 +0000
+++ b/lib/libc/string/strlcpy.c Wed Sep 08 22:56:55 1999 +0000
@@ -1,4 +1,5 @@
-/*     $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $     */
+/*     $NetBSD: strlcpy.c,v 1.2 1999/09/08 22:56:56 lukem Exp $        */
+/*     from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp   */
 
 /*
  * Copyright (c) 1998 Todd C. Miller <Todd.Miller%courtesan.com@localhost>
@@ -27,8 +28,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $";
+__RCSID("$NetBSD: strlcpy.c,v 1.2 1999/09/08 22:56:56 lukem Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -39,7 +41,8 @@
  * will be copied.  Always NUL terminates (unless siz == 0).
  * Returns strlen(src); if retval >= siz, truncation occurred.
  */
-size_t strlcpy(dst, src, siz)
+size_t
+strlcpy(dst, src, siz)
        char *dst;
        const char *src;
        size_t siz;
@@ -48,6 +51,9 @@
        register const char *s = src;
        register size_t n = siz;
 
+       if (dst == NULL || src == NULL)
+               return (0);
+
        /* Copy as many bytes as will fit */
        if (n != 0 && --n != 0) {
                do {



Home | Main Index | Thread Index | Old Index