If the string to be printed is NULL substitute "(null)". Approved by core.
This is a workaround to make gcc's behavior consistent, since gcc can transform: printf("%s\n", s) -> puts(s) fprintf(fp, "%s", s) -> fputs(s, fp) as an optimization. I've left the _DIAGASSERT's that make sure that s != NULL alone because we should really still abort in a debugging environment.
This commit is contained in:
parent
e45d20fa18
commit
07c1b4dc67
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fputs.c,v 1.13 2003/08/07 16:43:24 agc Exp $ */
|
||||
/* $NetBSD: fputs.c,v 1.14 2005/06/22 19:45:22 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)fputs.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: fputs.c,v 1.13 2003/08/07 16:43:24 agc Exp $");
|
||||
__RCSID("$NetBSD: fputs.c,v 1.14 2005/06/22 19:45:22 christos Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -64,8 +64,10 @@ fputs(s, fp)
|
|||
_DIAGASSERT(s != NULL);
|
||||
_DIAGASSERT(fp != NULL);
|
||||
|
||||
/* LINTED we don't touch s */
|
||||
iov.iov_base = (void *)s;
|
||||
if (s == NULL)
|
||||
s = "(null)";
|
||||
|
||||
iov.iov_base = __UNCONST(s);
|
||||
iov.iov_len = uio.uio_resid = strlen(s);
|
||||
uio.uio_iov = &iov;
|
||||
uio.uio_iovcnt = 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: puts.c,v 1.12 2003/08/07 16:43:29 agc Exp $ */
|
||||
/* $NetBSD: puts.c,v 1.13 2005/06/22 19:45:22 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)puts.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: puts.c,v 1.12 2003/08/07 16:43:29 agc Exp $");
|
||||
__RCSID("$NetBSD: puts.c,v 1.13 2005/06/22 19:45:22 christos Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -63,8 +63,10 @@ puts(s)
|
|||
|
||||
_DIAGASSERT(s != NULL);
|
||||
|
||||
/* LINTED we don't touch the string */
|
||||
iov[0].iov_base = (void *)s;
|
||||
if (s == NULL)
|
||||
s = "(null)";
|
||||
|
||||
iov[0].iov_base = __UNCONST(s);
|
||||
iov[0].iov_len = c;
|
||||
iov[1].iov_base = "\n";
|
||||
iov[1].iov_len = 1;
|
||||
|
|
Loading…
Reference in New Issue