Source-Changes-HG archive

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

[src/trunk]: src/lib/libc Add the {v, }{err, warn}c flavors, from FreeBSD.



details:   https://anonhg.NetBSD.org/src/rev/0fdb750e6581
branches:  trunk
changeset: 792777:0fdb750e6581
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jan 16 17:21:38 2014 +0000

description:
Add the {v,}{err,warn}c flavors, from FreeBSD.

diffstat:

 lib/libc/gen/Makefile.inc |  14 +++++----
 lib/libc/gen/_errc.c      |  30 ++++++++++++++++++++
 lib/libc/gen/_verrc.c     |  27 ++++++++++++++++++
 lib/libc/gen/_vwarnc.c    |  27 ++++++++++++++++++
 lib/libc/gen/_warnc.c     |  30 ++++++++++++++++++++
 lib/libc/gen/err.3        |  37 +++++++++++++++++++++++--
 lib/libc/gen/errc.c       |  59 ++++++++++++++++++++++++++++++++++++++++
 lib/libc/gen/verr.c       |  55 +++++++++++++------------------------
 lib/libc/gen/verrc.c      |  68 +++++++++++++++++++++++++++++++++++++++++++++++
 lib/libc/gen/vwarn.c      |  54 +++++++++++++------------------------
 lib/libc/gen/vwarnc.c     |  67 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/libc/gen/warnc.c      |  63 +++++++++++++++++++++++++++++++++++++++++++
 lib/libc/shlib_version    |   4 +-
 13 files changed, 453 insertions(+), 82 deletions(-)

diffs (truncated from 730 to 300 lines):

diff -r bd052ee0b7da -r 0fdb750e6581 lib/libc/gen/Makefile.inc
--- a/lib/libc/gen/Makefile.inc Thu Jan 16 16:03:33 2014 +0000
+++ b/lib/libc/gen/Makefile.inc Thu Jan 16 17:21:38 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.185 2012/11/03 19:39:21 christos Exp $
+#      $NetBSD: Makefile.inc,v 1.186 2014/01/16 17:21:38 christos Exp $
 #      from: @(#)Makefile.inc  8.6 (Berkeley) 5/4/95
 
 # gen sources
@@ -8,7 +8,7 @@
        closedir.c closefrom.c \
        confstr.c ctermid.c ctype_.c daemon.c \
        dehumanize_number.c devname.c dirname.c disklabel.c err.c errx.c \
-       errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \
+       errc.c errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \
        extattr.c fmtcheck.c fmtmsg.c fnmatch.c fstab.c ftok.c \
        fts.c ftw.c getbsize.c getcap.c getcwd.c \
        getdevmajor.c getdomainname.c getgrent.c \
@@ -32,11 +32,12 @@
        times.c toascii.c tolower_.c ttyname.c ttyslot.c toupper_.c ualarm.c \
        ulimit.c uname.c unvis.c usleep.c utime.c utimens.c utmp.c \
        utmpx.c valloc.c vis.c wait.c wait3.c waitpid.c warn.c warnx.c \
-       vwarn.c vwarnx.c verr.c verrx.c wordexp.c
+       warnc.c vwarn.c vwarnx.c vwarnc.c verr.c verrx.c verrc.c wordexp.c
 
 # indirect reference stubs, to be removed soon.
-SRCS+= _err.c _errx.c \
-       _sysconf.c _verr.c _verrx.c _vwarn.c _vwarnx.c _warn.c _warnx.c
+SRCS+= _err.c _errx.c _errc.c \
+       _sysconf.c _verr.c _verrx.c _verrc.c _vwarn.c _vwarnx.c _vwarnc.c \
+       _warn.c _warnx.c _warnc.c
 
 # uses alloca
 COPTS.execvp.c = -Wno-stack-protector
@@ -96,7 +97,8 @@
        endutxent.3 getutxline.3 endutxent.3 pututxline.3 \
        endutxent.3 setutxent.3
 MLINKS+=err.3 verr.3 err.3 errx.3 err.3 verrx.3 err.3 warn.3 err.3 vwarn.3 \
-        err.3 warnx.3 err.3 vwarnx.3
+        err.3 warnx.3 err.3 vwarnx.3 err.3 errc.3 err.3 verrc.3 err.3 warnc.3 \
+       err.3 vwarnc.3
 MLINKS+=exec.3 execl.3 exec.3 execle.3 exec.3 execlp.3 exec.3 execv.3 \
        exec.3 execvp.3 exec.3 exect.3
 MLINKS+=extattr_namespace_to_string.3 extattr_string_to_namespace.3 \
diff -r bd052ee0b7da -r 0fdb750e6581 lib/libc/gen/_errc.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/gen/_errc.c      Thu Jan 16 17:21:38 2014 +0000
@@ -0,0 +1,30 @@
+/*     $NetBSD: _errc.c,v 1.1 2014/01/16 17:21:38 christos Exp $       */
+
+/*
+ * J.T. Conklin, December 12, 1994
+ * Public Domain
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: _errc.c,v 1.1 2014/01/16 17:21:38 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#if defined(__indr_reference)
+__indr_reference(_errc, errc)
+#else
+
+#include <stdarg.h>
+
+__dead void _verrc(int eval, int code, const char *, va_list);
+
+__dead void
+errc(int eval, int code, const char *fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, fmt);
+       _verr(eval, code, fmt, ap);
+       va_end(ap);
+}
+#endif
diff -r bd052ee0b7da -r 0fdb750e6581 lib/libc/gen/_verrc.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/gen/_verrc.c     Thu Jan 16 17:21:38 2014 +0000
@@ -0,0 +1,27 @@
+/*     $NetBSD: _verrc.c,v 1.1 2014/01/16 17:21:38 christos Exp $      */
+
+/*
+ * J.T. Conklin, December 12, 1994
+ * Public Domain
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: _verrc.c,v 1.1 2014/01/16 17:21:38 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdarg.h>
+
+#if defined(__indr_reference)
+__indr_reference(_verrc, verrc)
+#else
+
+__dead void _verrc(int, int, const char *, va_list);
+
+void
+verrc(int eval, int code, const char *fmt, va_list ap)
+{
+       _verrc(eval, code, fmt, ap);
+}
+
+#endif
diff -r bd052ee0b7da -r 0fdb750e6581 lib/libc/gen/_vwarnc.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/gen/_vwarnc.c    Thu Jan 16 17:21:38 2014 +0000
@@ -0,0 +1,27 @@
+/*     $NetBSD: _vwarnc.c,v 1.1 2014/01/16 17:21:38 christos Exp $     */
+
+/*
+ * J.T. Conklin, December 12, 1994
+ * Public Domain
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: _vwarnc.c,v 1.1 2014/01/16 17:21:38 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdarg.h>
+
+#if defined(__indr_reference)
+__indr_reference(_vwarnc, vwarnc)
+#else
+
+void _vwarnc(int code, const char *, va_list);
+
+void
+vwarnc(int code, const char *fmt, va_list ap)
+{
+       _vwarnc(code, fmt, ap);
+}
+
+#endif
diff -r bd052ee0b7da -r 0fdb750e6581 lib/libc/gen/_warnc.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/gen/_warnc.c     Thu Jan 16 17:21:38 2014 +0000
@@ -0,0 +1,30 @@
+/*     $NetBSD: _warnc.c,v 1.1 2014/01/16 17:21:38 christos Exp $      */
+
+/*
+ * J.T. Conklin, December 12, 1994
+ * Public Domain
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: _warnc.c,v 1.1 2014/01/16 17:21:38 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#if defined(__indr_reference)
+__indr_reference(_warnc, warnc)
+#else
+
+#include <stdarg.h>
+
+void _vwarnc(int, const char *, va_list);
+
+void
+warnc(int code, const char *fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, fmt);
+       _vwarnc(code, fmt, ap);
+       va_end(ap);
+}
+#endif
diff -r bd052ee0b7da -r 0fdb750e6581 lib/libc/gen/err.3
--- a/lib/libc/gen/err.3        Thu Jan 16 16:03:33 2014 +0000
+++ b/lib/libc/gen/err.3        Thu Jan 16 17:21:38 2014 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: err.3,v 1.20 2010/03/22 19:30:53 joerg Exp $
+.\" $NetBSD: err.3,v 1.21 2014/01/16 17:21:38 christos Exp $
 .\"
 .\" Copyright (c) 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"    @(#)err.3       8.1 (Berkeley) 6/9/93
 .\"
-.Dd March 21, 2001
+.Dd January 16, 2014
 .Dt ERR 3
 .Os
 .Sh NAME
@@ -37,10 +37,14 @@
 .Nm verr ,
 .Nm errx ,
 .Nm verrx ,
+.Nm errc ,
+.Nm verrc ,
 .Nm warn ,
 .Nm vwarn ,
 .Nm warnx ,
-.Nm vwarnx
+.Nm vwarnx ,
+.Nm warnc ,
+.Nm vwarnc
 .Nd formatted error messages
 .Sh LIBRARY
 .Lb libc
@@ -55,6 +59,10 @@
 .Ft void
 .Fn verrx "int status" "const char *fmt" "va_list args"
 .Ft void
+.Fn errc "int status" "int code" "const char *fmt" "..."
+.Ft void
+.Fn verrc "int status" "int code" "const char *fmt" "va_list args"
+.Ft void
 .Fn warn "const char *fmt" "..."
 .Ft void
 .Fn vwarn "const char *fmt" "va_list args"
@@ -62,6 +70,10 @@
 .Fn warnx "const char *fmt" "..."
 .Ft void
 .Fn vwarnx "const char *fmt" "va_list args"
+.Ft void
+.Fn warnc "int code" "const char *fmt" "..."
+.Ft void
+.Fn vwarnc "int code" "const char *fmt" "va_list args"
 .Sh DESCRIPTION
 The
 .Fn err
@@ -91,6 +103,17 @@
 .Dv NULL .
 In all cases, the output is followed by a newline character.
 The
+.Fn errc ,
+.Fn verrc ,
+.Fn warnc ,
+and
+.Fn vwarnc
+functions take an additional
+.Ar code
+argument to be used as the error number instead of using the global
+.Va errno
+variable.
+The
 .Fn errx ,
 .Fn verrx ,
 .Fn warnx ,
@@ -151,6 +174,14 @@
 .Fn warn
 functions first appeared in
 .Bx 4.4 .
+The
+.Fn errc
+and
+.Fn warnc
+functions first appeared in
+.Fx 3.0
+and
+.Nx 7.0 .
 .Sh CAVEATS
 It is important never to pass a string with user-supplied data as a
 format without using
diff -r bd052ee0b7da -r 0fdb750e6581 lib/libc/gen/errc.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/gen/errc.c       Thu Jan 16 17:21:38 2014 +0000
@@ -0,0 +1,59 @@
+/*     $NetBSD: errc.c,v 1.1 2014/01/16 17:21:38 christos Exp $        */
+
+/*-
+ * Copyright (c) 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"



Home | Main Index | Thread Index | Old Index