Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src add dprintf and vdprintf
details: https://anonhg.NetBSD.org/src/rev/4948b074b0fa
branches: trunk
changeset: 757573:4948b074b0fa
user: christos <christos%NetBSD.org@localhost>
date: Mon Sep 06 14:52:55 2010 +0000
description:
add dprintf and vdprintf
diffstat:
distrib/sets/lists/comp/mi | 8 ++-
lib/libc/stdio/Makefile.inc | 21 ++++---
lib/libc/stdio/dprintf.c | 59 ++++++++++++++++++++++
lib/libc/stdio/findfp.c | 34 +++++++-----
lib/libc/stdio/local.h | 3 +-
lib/libc/stdio/printf.3 | 21 +++++++-
lib/libc/stdio/vdprintf.c | 116 ++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 234 insertions(+), 28 deletions(-)
diffs (truncated from 441 to 300 lines):
diff -r 8efed860a5e9 -r 4948b074b0fa distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Mon Sep 06 14:52:26 2010 +0000
+++ b/distrib/sets/lists/comp/mi Mon Sep 06 14:52:55 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1506 2010/09/02 12:29:49 pooka Exp $
+# $NetBSD: mi,v 1.1507 2010/09/06 14:55:37 christos Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -5594,6 +5594,7 @@
./usr/share/man/cat3/dn_expand.0 comp-c-catman .cat
./usr/share/man/cat3/dngettext.0 comp-c-catman .cat
./usr/share/man/cat3/doupdate.0 comp-c-catman .cat
+./usr/share/man/cat3/dprintf.0 comp-c-catman .cat
./usr/share/man/cat3/drand48.0 comp-c-catman .cat
./usr/share/man/cat3/dsa.0 comp-obsolete obsolete
./usr/share/man/cat3/dup_field.0 comp-c-catman .cat
@@ -8403,6 +8404,7 @@
./usr/share/man/cat3/valloc.0 comp-c-catman .cat
./usr/share/man/cat3/varargs.0 comp-c-catman .cat
./usr/share/man/cat3/vasprintf.0 comp-c-catman .cat
+./usr/share/man/cat3/vdprintf.0 comp-c-catman .cat
./usr/share/man/cat3/verr.0 comp-c-catman .cat
./usr/share/man/cat3/verrx.0 comp-c-catman .cat
./usr/share/man/cat3/vfprintf.0 comp-c-catman .cat
@@ -11532,6 +11534,7 @@
./usr/share/man/html3/dn_expand.html comp-c-htmlman html
./usr/share/man/html3/dngettext.html comp-c-htmlman html
./usr/share/man/html3/doupdate.html comp-c-htmlman html
+./usr/share/man/html3/dprintf.html comp-c-htmlman html
./usr/share/man/html3/drand48.html comp-c-htmlman html
./usr/share/man/html3/dup_field.html comp-c-htmlman html
./usr/share/man/html3/dupwin.html comp-c-htmlman html
@@ -14257,6 +14260,7 @@
./usr/share/man/html3/valloc.html comp-c-htmlman html
./usr/share/man/html3/varargs.html comp-c-htmlman html
./usr/share/man/html3/vasprintf.html comp-c-htmlman html
+./usr/share/man/html3/vdprintf.html comp-c-htmlman html
./usr/share/man/html3/verr.html comp-c-htmlman html
./usr/share/man/html3/verrx.html comp-c-htmlman html
./usr/share/man/html3/vfprintf.html comp-c-htmlman html
@@ -17378,6 +17382,7 @@
./usr/share/man/man3/dn_expand.3 comp-c-man .man
./usr/share/man/man3/dngettext.3 comp-c-man .man
./usr/share/man/man3/doupdate.3 comp-c-man .man
+./usr/share/man/man3/dprintf.3 comp-c-man .man
./usr/share/man/man3/drand48.3 comp-c-man .man
./usr/share/man/man3/dsa.3 comp-obsolete obsolete
./usr/share/man/man3/dup_field.3 comp-c-man .man
@@ -20183,6 +20188,7 @@
./usr/share/man/man3/valloc.3 comp-c-man .man
./usr/share/man/man3/varargs.3 comp-c-man .man
./usr/share/man/man3/vasprintf.3 comp-c-man .man
+./usr/share/man/man3/vdprintf.3 comp-c-man .man
./usr/share/man/man3/verr.3 comp-c-man .man
./usr/share/man/man3/verrx.3 comp-c-man .man
./usr/share/man/man3/vfprintf.3 comp-c-man .man
diff -r 8efed860a5e9 -r 4948b074b0fa lib/libc/stdio/Makefile.inc
--- a/lib/libc/stdio/Makefile.inc Mon Sep 06 14:52:26 2010 +0000
+++ b/lib/libc/stdio/Makefile.inc Mon Sep 06 14:52:55 2010 +0000
@@ -1,25 +1,25 @@
# from: @(#)Makefile.inc 5.7 (Berkeley) 6/27/91
-# $NetBSD: Makefile.inc,v 1.36 2009/07/13 22:19:25 roy Exp $
+# $NetBSD: Makefile.inc,v 1.37 2010/09/06 14:52:55 christos Exp $
# stdio sources
.PATH: ${.CURDIR}/stdio
CPPFLAGS+=-DWIDE_DOUBLE
-SRCS+= asprintf.c clrerr.c fclose.c fdopen.c feof.c ferror.c fflush.c \
- fgetc.c fgetln.c fgetpos.c fgets.c fgetstr.c fgetwc.c fgetwln.c \
- fgetws.c fileno.c findfp.c flags.c flockfile.c fopen.c fparseln.c \
- fprintf.c fpurge.c fputc.c fputs.c fputwc.c fputws.c fread.c \
- freopen.c fscanf.c fseek.c fseeko.c fsetpos.c ftell.c ftello.c \
+SRCS+= asprintf.c clrerr.c dprintf.c fclose.c fdopen.c feof.c ferror.c \
+ fflush.c fgetc.c fgetln.c fgetpos.c fgets.c fgetstr.c fgetwc.c \
+ fgetwln.c fgetws.c fileno.c findfp.c flags.c flockfile.c fopen.c \
+ fparseln.c fprintf.c fpurge.c fputc.c fputs.c fputwc.c fputws.c \
+ fread.c freopen.c fscanf.c fseek.c fseeko.c fsetpos.c ftell.c ftello.c \
funopen.c fvwrite.c fwalk.c fwide.c fwprintf.c fwrite.c fwscanf.c \
getc.c getchar.c getdelim.c getline.c gettemp.c getw.c getwc.c \
getwchar.c makebuf.c mkdtemp.c mkstemp.c perror.c printf.c putc.c \
putchar.c puts.c putw.c putwc.c putwchar.c refill.c remove.c rewind.c \
rget.c scanf.c setbuf.c setbuffer.c setvbuf.c snprintf.c snprintf_ss.c \
sscanf.c stdio.c swprintf.c swscanf.c tmpfile.c ungetc.c ungetwc.c \
- vasprintf.c vfprintf.c vfscanf.c vfwprintf.c vfwscanf.c vprintf.c \
- vscanf.c vsnprintf.c vsnprintf_ss.c vsscanf.c vswprintf.c vswscanf.c \
- vwprintf.c vwscanf.c wbuf.c wprintf.c wscanf.c wsetup.c
+ vasprintf.c vdprintf.c vfprintf.c vfscanf.c vfwprintf.c vfwscanf.c \
+ vprintf.c vscanf.c vsnprintf.c vsnprintf_ss.c vsscanf.c vswprintf.c \
+ vswscanf.c vwprintf.c vwscanf.c wbuf.c wprintf.c wscanf.c wsetup.c
.if !defined(AUDIT)
SRCS+= gets.c sprintf.c vsprintf.c tempnam.c tmpnam.c mktemp.c
@@ -50,7 +50,8 @@
MLINKS+=mktemp.3 mkdtemp.3 mktemp.3 mkstemp.3
MLINKS+=printf.3 asprintf.3 printf.3 fprintf.3 printf.3 snprintf.3 \
printf.3 sprintf.3 printf.3 vasprintf.3 printf.3 vfprintf.3 \
- printf.3 vprintf.3 printf.3 vsnprintf.3 printf.3 vsprintf.3
+ printf.3 vprintf.3 printf.3 vsnprintf.3 printf.3 vsprintf.3 \
+ printf.3 dprintf.3 printf.3 vdprintf.3
MLINKS+=putc.3 fputc.3 putc.3 putc_unlocked.3 putc.3 putchar.3 \
putc.3 putchar_unlocked.3 putc.3 putw.3
MLINKS+=scanf.3 fscanf.3 scanf.3 sscanf.3 scanf.3 vfscanf.3 scanf.3 vscanf.3 \
diff -r 8efed860a5e9 -r 4948b074b0fa lib/libc/stdio/dprintf.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/stdio/dprintf.c Mon Sep 06 14:52:55 2010 +0000
@@ -0,0 +1,59 @@
+/* $NetBSD: dprintf.c,v 1.1 2010/09/06 14:52:55 christos Exp $ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: dprintf.c,v 1.1 2010/09/06 14:52:55 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "reentrant.h"
+#include "local.h"
+
+int
+dprintf(int fd, const char * __restrict fmt, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start(ap, fmt);
+ ret = vdprintf(fd, fmt, ap);
+ va_end(ap);
+ return ret;
+}
diff -r 8efed860a5e9 -r 4948b074b0fa lib/libc/stdio/findfp.c
--- a/lib/libc/stdio/findfp.c Mon Sep 06 14:52:26 2010 +0000
+++ b/lib/libc/stdio/findfp.c Mon Sep 06 14:52:55 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: findfp.c,v 1.24 2010/01/11 20:39:29 joerg Exp $ */
+/* $NetBSD: findfp.c,v 1.25 2010/09/06 14:52:55 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)findfp.c 8.2 (Berkeley) 1/4/94";
#else
-__RCSID("$NetBSD: findfp.c,v 1.24 2010/01/11 20:39:29 joerg Exp $");
+__RCSID("$NetBSD: findfp.c,v 1.25 2010/09/06 14:52:55 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -119,6 +119,23 @@
return (g);
}
+void
+__sfpinit(FILE *fp)
+{
+ fp->_flags = 1; /* reserve this slot; caller sets real flags */
+ fp->_p = NULL; /* no current pointer */
+ fp->_w = 0; /* nothing to read or write */
+ fp->_r = 0;
+ fp->_bf._base = NULL; /* no buffer */
+ fp->_bf._size = 0;
+ fp->_lbfsize = 0; /* not line buffered */
+ fp->_file = -1; /* no file */
+/* fp->_cookie = <any>; */ /* caller sets cookie, _read/_write etc */
+ _UB(fp)._base = NULL; /* no ungetc buffer */
+ _UB(fp)._size = 0;
+ memset(WCIO_GET(fp), 0, sizeof(struct wchar_io_data));
+}
+
/*
* Find a free FILE for fopen et al.
*/
@@ -143,18 +160,7 @@
rwlock_unlock(&__sfp_lock);
return (NULL);
found:
- fp->_flags = 1; /* reserve this slot; caller sets real flags */
- fp->_p = NULL; /* no current pointer */
- fp->_w = 0; /* nothing to read or write */
- fp->_r = 0;
- fp->_bf._base = NULL; /* no buffer */
- fp->_bf._size = 0;
- fp->_lbfsize = 0; /* not line buffered */
- fp->_file = -1; /* no file */
-/* fp->_cookie = <any>; */ /* caller sets cookie, _read/_write etc */
- _UB(fp)._base = NULL; /* no ungetc buffer */
- _UB(fp)._size = 0;
- memset(WCIO_GET(fp), 0, sizeof(struct wchar_io_data));
+ __sfpinit(fp);
rwlock_unlock(&__sfp_lock);
return (fp);
}
diff -r 8efed860a5e9 -r 4948b074b0fa lib/libc/stdio/local.h
--- a/lib/libc/stdio/local.h Mon Sep 06 14:52:26 2010 +0000
+++ b/lib/libc/stdio/local.h Mon Sep 06 14:52:55 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: local.h,v 1.24 2010/01/11 20:39:29 joerg Exp $ */
+/* $NetBSD: local.h,v 1.25 2010/09/06 14:52:55 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -44,6 +44,7 @@
extern int __sflush __P((FILE *));
extern FILE *__sfp __P((void));
+extern void __sfpinit __P((FILE *));
extern int __srefill __P((FILE *));
extern int __sread __P((void *, char *, int));
extern int __swrite __P((void *, char const *, int));
diff -r 8efed860a5e9 -r 4948b074b0fa lib/libc/stdio/printf.3
--- a/lib/libc/stdio/printf.3 Mon Sep 06 14:52:26 2010 +0000
+++ b/lib/libc/stdio/printf.3 Mon Sep 06 14:52:55 2010 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: printf.3,v 1.52 2010/05/13 21:52:43 joerg Exp $
+.\" $NetBSD: printf.3,v 1.53 2010/09/06 14:52:55 christos Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -33,18 +33,20 @@
.\"
.\" @(#)printf.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd March 21, 2010
+.Dd August 28, 2010
.Dt PRINTF 3
.Os
.Sh NAME
.Nm printf ,
.Nm fprintf ,
+.Nm dprintf
.Nm sprintf ,
.Nm snprintf ,
.Nm asprintf ,
.Nm vprintf ,
.Nm vfprintf ,
.Nm vsprintf ,
+.Nm vdprintf ,
.Nm vsnprintf ,
.Nm vasprintf
.Nd formatted output conversion
@@ -57,6 +59,8 @@
.Ft int
.Fn fprintf "FILE * restrict stream" "const char * restrict format" ...
.Ft int
+.Fn dprintf "int fd" "const char * restrict format" ...
+.Ft int
.Fn sprintf "char * restrict str" "const char * restrict format" ...
.Ft int
.Fn snprintf "char * restrict str" "size_t size" "const char * restrict format" ...
@@ -70,6 +74,8 @@
.Ft int
.Fn vsprintf "char * restrict str" "const char * restrict format" "va_list ap"
.Ft int
+.Fn vdprintf "int fd" "const char * restrict format" "va_list ap"
+.Ft int
.Fn vsnprintf "char * restrict str" "size_t size" "const char * restrict format" "va_list ap"
.Ft int
.Fn vasprintf "char ** restrict ret" "const char * restrict format" "va_list ap"
@@ -92,6 +98,11 @@
.Fn vfprintf
write output to the given output
.Fa stream ;
Home |
Main Index |
Thread Index |
Old Index