SCCS-vsn: lib/libc/gen/err.c 5.2
SCCS-vsn: lib/libc/gen/err.3 5.2
.\"
.\" %sccs.include.redist.roff%
.\"
.\"
.\" %sccs.include.redist.roff%
.\"
-.\" @(#)err.3 5.1 (Berkeley) %G%
+.\" @(#)err.3 5.2 (Berkeley) %G%
.Fn warn
family of functions display a formatted error message on the standard
error output.
.Fn warn
family of functions display a formatted error message on the standard
error output.
-In all cases, the error message is preceded by the last component
-of the program name, a colon character, and a space.
+In all cases, the last component of the program name, a colon character,
+and a space are output.
+If the
+.Va fmt
+argument is not NULL, the formatted error message, a colon character,
+and a space are output.
In the case of the
.Fn err ,
.Fn verr ,
.Fn warn ,
and
.Fn vwarn
In the case of the
.Fn err ,
.Fn verr ,
.Fn warn ,
and
.Fn vwarn
-functions, a colon character, a space and the error message string
-affiliated with the current value of the global variable
+functions, the error message string affiliated with the current value of
+the global variable
-are displayed after the formatted error message.
-In all cases, the message is followed by a newline character.
+is output.
+In all cases, the output is followed by a newline character.
.Sh EXAMPLES
Display the current errno information string and exit:
.Bd -literal -offset indent
.Sh EXAMPLES
Display the current errno information string and exit:
.Bd -literal -offset indent
+if ((p = malloc(size)) == NULL)
+ err(1, NULL);
if ((fd = open(file_name, O_RDONLY, 0)) == -1)
err(1, "%s", file_name);
.Ed
if ((fd = open(file_name, O_RDONLY, 0)) == -1)
err(1, "%s", file_name);
.Ed
*/
#if defined(LIBC_SCCS) && !defined(lint)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)err.c 5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)err.c 5.2 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <err.h>
#endif /* LIBC_SCCS and not lint */
#include <err.h>
sverrno = errno;
(void)fprintf(stderr, "%s: ", __progname);
sverrno = errno;
(void)fprintf(stderr, "%s: ", __progname);
- (void)vfprintf(stderr, fmt, ap);
- (void)fprintf(stderr, ": %s\n", strerror(sverrno));
+ if (fmt != NULL) {
+ (void)vfprintf(stderr, fmt, ap);
+ (void)fprintf(stderr, ": ");
+ }
+ (void)fprintf(stderr, "%s\n", strerror(sverrno));
va_list ap;
{
(void)fprintf(stderr, "%s: ", __progname);
va_list ap;
{
(void)fprintf(stderr, "%s: ", __progname);
- (void)vfprintf(stderr, fmt, ap);
+ if (fmt != NULL)
+ (void)vfprintf(stderr, fmt, ap);
(void)fprintf(stderr, "\n");
exit(eval);
}
(void)fprintf(stderr, "\n");
exit(eval);
}
sverrno = errno;
(void)fprintf(stderr, "%s: ", __progname);
sverrno = errno;
(void)fprintf(stderr, "%s: ", __progname);
- (void)vfprintf(stderr, fmt, ap);
- (void)fprintf(stderr, ": %s\n", strerror(sverrno));
+ if (fmt != NULL) {
+ (void)vfprintf(stderr, fmt, ap);
+ (void)fprintf(stderr, ": ");
+ }
+ (void)fprintf(stderr, "%s\n", strerror(sverrno));
va_list ap;
{
(void)fprintf(stderr, "%s: ", __progname);
va_list ap;
{
(void)fprintf(stderr, "%s: ", __progname);
- (void)vfprintf(stderr, fmt, ap);
+ if (fmt != NULL)
+ (void)vfprintf(stderr, fmt, ap);
(void)fprintf(stderr, "\n");
}
(void)fprintf(stderr, "\n");
}