This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: *printf cleanup


Christopher Faylor <cgf-use-the-mailinglist-please <at> sourceware.org> writes:

> 
> I have a gravely important concern:
> 
> >- * Copyright (c) 1990 The Regents of the University of California.
> >+ * Copyright (c) 1990, 2007 The Regents of the University of California.
> >  * All rights reserved.
> 
> I don't believe that it is appropriate to change the copyright in this
> fashion since it isn't clear that any changes made to this file would go
> to the Regents of the University of California.  Probably it should just
> be left alone.

I'm not quite sure what the copyright editing rules are in newlib, since 
IANAL.  I just have an emacs copyright hook, that always checks files for the 
current year when I edit them.  Here's the same patch, but with all UC 
copyright hunks omitted (although some of my prior patches have done the same 
thing, and have already been committed).

> 
> Otherwise, this kind of fix seems nice, although I haven't looked at it
> in any great detail.

Once applied, there is a followup patch to cygwin to export all these functions.

And I still hope to get around to adding vasnprintf() as well as %a support.


Index: libc/include/stdio.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/stdio.h,v
retrieving revision 1.41
diff -u -r1.41 stdio.h
--- libc/include/stdio.h	30 Mar 2007 00:49:56 -0000	1.41
+++ libc/include/stdio.h	3 Apr 2007 15:18:17 -0000
@@ -230,6 +230,7 @@
 int	_EXFUN(asiprintf, (char **, const char *, ...));
 int	_EXFUN(asprintf, (char **, const char *, ...));
 #ifndef dprintf
+int	_EXFUN(diprintf, (int, const char *, ...));
 int	_EXFUN(dprintf, (int, const char *, ...));
 #endif
 int	_EXFUN(fcloseall, (_VOID));
@@ -244,6 +245,7 @@
 char *	_EXFUN(tempnam, (const char *, const char *));
 int	_EXFUN(vasiprintf, (char **, const char *, __VALIST));
 int	_EXFUN(vasprintf, (char **, const char *, __VALIST));
+int	_EXFUN(vdiprintf, (int, const char *, __VALIST));
 int	_EXFUN(vdprintf, (int, const char *, __VALIST));
 int	_EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST));
 int	_EXFUN(vsnprintf, (char *, size_t, const char *, __VALIST));
@@ -289,13 +291,16 @@
 
 int	_EXFUN(_asiprintf_r, (struct _reent *, char **, const char *, ...));
 int	_EXFUN(_asprintf_r, (struct _reent *, char **, const char *, ...));
+int	_EXFUN(_diprintf_r, (struct _reent *, int, const char *, ...));
 int	_EXFUN(_dprintf_r, (struct _reent *, int, const char *, ...));
+int	_EXFUN(_fclose_r, (struct _reent *, FILE *));
 int	_EXFUN(_fcloseall_r, (struct _reent *));
 FILE *	_EXFUN(_fdopen_r, (struct _reent *, int, const char *));
 FILE *	_EXFUN(_fopen_r, (struct _reent *, const char *, const char *));
-int	_EXFUN(_fclose_r, (struct _reent *, FILE *));
 char *  _EXFUN(_fgets_r, (struct _reent *, char *, int, FILE *));
+int	_EXFUN(_fiprintf_r, (struct _reent *, FILE *, const char *, ...));
 int	_EXFUN(_fiscanf_r, (struct _reent *, FILE *, const char *, ...));
+int	_EXFUN(_fprintf_r, (struct _reent *, FILE *, const char *, ...));
 int	_EXFUN(_fputc_r, (struct _reent *, int, FILE *));
 int	_EXFUN(_fputs_r, (struct _reent *, const char *, FILE *));
 size_t	_EXFUN(_fread_r, (struct _reent *, _PTR, size_t _size, size_t _n, FILE 
*));
@@ -335,6 +340,7 @@
 int	_EXFUN(_ungetc_r, (struct _reent *, int, FILE *));
 int	_EXFUN(_vasiprintf_r, (struct _reent *, char **, const char *, 
__VALIST));
 int	_EXFUN(_vasprintf_r, (struct _reent *, char **, const char *, 
__VALIST));
+int	_EXFUN(_vdiprintf_r, (struct _reent *, int, const char *, __VALIST));
 int	_EXFUN(_vdprintf_r, (struct _reent *, int, const char *, __VALIST));
 int	_EXFUN(_vfiprintf_r, (struct _reent *, FILE *, const char *, __VALIST));
 int	_EXFUN(_vfprintf_r, (struct _reent *, FILE *, const char *, __VALIST));
Index: libc/stdio/Makefile.am
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/Makefile.am,v
retrieving revision 1.22
diff -u -r1.22 Makefile.am
--- libc/stdio/Makefile.am	1 May 2006 22:01:02 -0000	1.22
+++ libc/stdio/Makefile.am	3 Apr 2007 15:18:18 -0000
@@ -6,6 +6,7 @@
 
 GENERAL_SOURCES = \
 	clearerr.c 			\
+	diprintf.c			\
 	dprintf.c			\
 	fclose.c 			\
 	fdopen.c 			\
@@ -71,6 +72,7 @@
 	tmpfile.c 			\
 	tmpnam.c 			\
 	ungetc.c 			\
+	vdiprintf.c			\
 	vdprintf.c			\
 	viprintf.c 			\
 	viscanf.c			\
@@ -83,7 +85,7 @@
 	vsprintf.c 			\
 	vsscanf.c			\
 	wbuf.c 				\
-	wsetup.c 
+	wsetup.c
 
 ## The following are EL/IX level 2 interfaces
 if ELIX_LEVEL_1
Index: libc/stdio/asiprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/asiprintf.c,v
retrieving revision 1.2
diff -u -r1.2 asiprintf.c
--- libc/stdio/asiprintf.c	12 Mar 2007 20:30:08 -0000	1.2
+++ libc/stdio/asiprintf.c	3 Apr 2007 15:18:18 -0000
@@ -19,27 +19,15 @@
 #include <_ansi.h>
 #include <reent.h>
 #include <stdio.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 #include <limits.h>
 #include "local.h"
 
 int
-#ifdef _HAVE_STDC
 _DEFUN(_asiprintf_r, (ptr, strp, fmt),
        struct _reent *ptr _AND
        char **strp        _AND
-       _CONST char *fmt _DOTS)
-#else
-_asiprintf_r(ptr, strp, fmt, va_alist)
-           struct _reent *ptr;
-           char **strp;
-           _CONST char *fmt;
-           va_dcl
-#endif
+       const char *fmt _DOTS)
 {
   int ret;
   va_list ap;
@@ -50,12 +38,8 @@
   f._bf._base = f._p = NULL;
   f._bf._size = f._w = 0;
   f._file = -1;  /* No file. */
-#ifdef _HAVE_STDC
   va_start (ap, fmt);
-#else
-  va_start (ap);
-#endif
-  ret = vfiprintf (&f, fmt, ap);
+  ret = _vfiprintf_r (ptr, &f, fmt, ap);
   va_end (ap);
   if (ret >= 0)
     {
@@ -68,16 +52,9 @@
 #ifndef _REENT_ONLY
 
 int
-#ifdef _HAVE_STDC
 _DEFUN(asiprintf, (strp, fmt),
        char **strp _AND
-       _CONST char *fmt _DOTS)
-#else
-asiprintf(strp, fmt, va_alist)
-        char **strp;
-        _CONST char *fmt;
-        va_dcl
-#endif
+       const char *fmt _DOTS)
 {
   int ret;
   va_list ap;
@@ -88,12 +65,8 @@
   f._bf._base = f._p = NULL;
   f._bf._size = f._w = 0;
   f._file = -1;  /* No file. */
-#ifdef _HAVE_STDC
   va_start (ap, fmt);
-#else
-  va_start (ap);
-#endif
-  ret = vfiprintf (&f, fmt, ap);
+  ret = _vfiprintf_r (_REENT, &f, fmt, ap);
   va_end (ap);
   if (ret >= 0)
     {
@@ -103,4 +76,4 @@
   return (ret);
 }
 
-#endif
+#endif /* ! _REENT_ONLY */
Index: libc/stdio/asprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/asprintf.c,v
retrieving revision 1.6
diff -u -r1.6 asprintf.c
--- libc/stdio/asprintf.c	12 Mar 2007 20:30:08 -0000	1.6
+++ libc/stdio/asprintf.c	3 Apr 2007 15:18:18 -0000
@@ -19,27 +19,15 @@
 #include <_ansi.h>
 #include <reent.h>
 #include <stdio.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 #include <limits.h>
 #include "local.h"
 
 int
-#ifdef _HAVE_STDC
 _DEFUN(_asprintf_r, (ptr, strp, fmt),
        struct _reent *ptr _AND
        char **strp        _AND
-       _CONST char *fmt _DOTS)
-#else
-_asprintf_r(ptr, strp, fmt, va_alist)
-           struct _reent *ptr;
-           char **strp;
-           _CONST char *fmt;
-           va_dcl
-#endif
+       const char *fmt _DOTS)
 {
   int ret;
   va_list ap;
@@ -50,12 +38,8 @@
   f._bf._base = f._p = NULL;
   f._bf._size = f._w = 0;
   f._file = -1;  /* No file. */
-#ifdef _HAVE_STDC
   va_start (ap, fmt);
-#else
-  va_start (ap);
-#endif
-  ret = vfprintf (&f, fmt, ap);
+  ret = _vfprintf_r (ptr, &f, fmt, ap);
   va_end (ap);
   if (ret >= 0)
     {
@@ -68,16 +52,9 @@
 #ifndef _REENT_ONLY
 
 int
-#ifdef _HAVE_STDC
 _DEFUN(asprintf, (strp, fmt),
        char **strp _AND
-       _CONST char *fmt _DOTS)
-#else
-asprintf(strp, fmt, va_alist)
-        char **strp;
-        _CONST char *fmt;
-        va_dcl
-#endif
+       const char *fmt _DOTS)
 {
   int ret;
   va_list ap;
@@ -88,12 +65,8 @@
   f._bf._base = f._p = NULL;
   f._bf._size = f._w = 0;
   f._file = -1;  /* No file. */
-#ifdef _HAVE_STDC
   va_start (ap, fmt);
-#else
-  va_start (ap);
-#endif
-  ret = vfprintf (&f, fmt, ap);
+  ret = _vfprintf_r (_REENT, &f, fmt, ap);
   va_end (ap);
   if (ret >= 0)
     {
@@ -103,4 +76,4 @@
   return (ret);
 }
 
-#endif
+#endif /* ! _REENT_ONLY */
Index: libc/stdio/diprintf.c
===================================================================
RCS file: libc/stdio/diprintf.c
diff -N libc/stdio/diprintf.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libc/stdio/diprintf.c	3 Apr 2007 15:18:18 -0000
@@ -0,0 +1,75 @@
+/* Copyright (C) 2005, 2007 Shaun Jackman
+ * Permission to use, copy, modify, and distribute this software
+ * is freely granted, provided that this notice is preserved.
+ */
+
+/*
+FUNCTION
+<<diprintf>>, <<vdiprintf>>---print to a file descriptor
+
+INDEX
+	diprintf
+INDEX
+	vdiprintf
+
+ANSI_SYNOPSIS
+	#include <stdio.h>
+	#include <stdarg.h>
+	int diprintf(int <[fd]>, const char *<[format]>, ...);
+	int vdiprintf(int <[fd]>, const char *<[format]>, va_list <[ap]>);
+	int _diprintf_r(struct _reent *<[ptr]>, int <[fd]>,
+			const char *<[format]>, ...);
+	int _vidprintf_r(struct _reent *<[ptr]>, int <[fd]>,
+			const char *<[format]>, va_list <[ap]>);
+
+DESCRIPTION
+<<diprintf>> and <<vdiprintf>> are similar to <<dprintf>> and <<vdprintf>>,
+except that only integer format specifiers are processed.
+
+RETURNS
+Similar to <<dprintf>> and <<vdprintf>>.
+
+PORTABILITY
+This set of functions is an integer-only extension, and is not portable.
+
+Supporting OS subroutines required: <<sbrk>>, <<write>>.
+*/
+
+#include <_ansi.h>
+#include <reent.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+int
+_DEFUN(_diprintf_r, (ptr, fd, format),
+       struct _reent *ptr _AND
+       int fd _AND
+       const char *format _DOTS)
+{
+  va_list ap;
+  int n;
+
+  va_start (ap, format);
+  n = _vdiprintf_r (ptr, fd, format, ap);
+  va_end (ap);
+  return n;
+}
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN(diprintf, (fd, format),
+       int fd _AND
+       const char *format _DOTS)
+{
+  va_list ap;
+  int n;
+
+  va_start (ap, format);
+  n = _vdiprintf_r (_REENT, fd, format, ap);
+  va_end (ap);
+  return n;
+}
+
+#endif /* ! _REENT_ONLY */
Index: libc/stdio/dprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/dprintf.c,v
retrieving revision 1.1
diff -u -r1.1 dprintf.c
--- libc/stdio/dprintf.c	11 Oct 2005 23:59:32 -0000	1.1
+++ libc/stdio/dprintf.c	3 Apr 2007 15:18:18 -0000
@@ -1,4 +1,4 @@
-/* Copyright 2005 Shaun Jackman
+/* Copyright 2005, 2007 Shaun Jackman
  * Permission to use, copy, modify, and distribute this software
  * is freely granted, provided that this notice is preserved.
  */
@@ -17,9 +17,9 @@
 	#include <stdarg.h>
 	int dprintf(int <[fd]>, const char *<[format]>, ...);
 	int vdprintf(int <[fd]>, const char *<[format]>, va_list <[ap]>);
-	int _dprintf_r(struct _reent *<[ptr]>, int <[fd]>, 
+	int _dprintf_r(struct _reent *<[ptr]>, int <[fd]>,
 			const char *<[format]>, ...);
-	int _vdprintf_r(struct _reent *<[ptr]>, int <[fd]>, 
+	int _vdprintf_r(struct _reent *<[ptr]>, int <[fd]>,
 			const char *<[format]>, va_list <[ap]>);
 
 TRAD_SYNOPSIS
@@ -68,32 +68,18 @@
 #include <reent.h>
 #include <stdio.h>
 #include <unistd.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 
-#ifdef _HAVE_STDC
 int
-_dprintf_r(struct _reent *ptr, int fd, _CONST char *format, ...)
-#else
-int
-_dprintf_r(ptr, fd, format, va_alist)
-	struct _reent *ptr;
-	int fd;
-	char *format;
-	va_dcl
-#endif
+_DEFUN(_dprintf_r, (ptr, fd, format),
+       struct _reent *ptr _AND
+       int fd _AND
+       const char *format _DOTS)
 {
 	va_list ap;
 	int n;
 	_REENT_SMALL_CHECK_INIT (ptr);
-#ifdef _HAVE_STDC
-  	va_start (ap, format);
-#else
-  	va_start (ap);
-#endif
+	va_start (ap, format);
 	n = _vdprintf_r (ptr, fd, format, ap);
 	va_end (ap);
 	return n;
@@ -101,29 +87,20 @@
 
 #ifndef _REENT_ONLY
 
-#ifdef _HAVE_STDC
-int
-dprintf(int fd, _CONST char *format, ...)
-#else
 int
-dprintf(fd, format, va_alist)
-	struct _reent *ptr;
-	int fd;
-	char *format;
-	va_dcl
-#endif
+_DEFUN(dprintf, (fd, format),
+       int fd _AND
+       const char *format _DOTS)
 {
-	va_list ap;
-	int n;
-	_REENT_SMALL_CHECK_INIT (_REENT);
-#ifdef _HAVE_STDC
-  	va_start (ap, format);
-#else
-  	va_start (ap);
-#endif
-	n = _vdprintf_r (_REENT, fd, format, ap);
-	va_end (ap);
-	return n;
+  va_list ap;
+  int n;
+  struct _reent *ptr = _REENT;
+
+  _REENT_SMALL_CHECK_INIT (ptr);
+  va_start (ap, format);
+  n = _vdprintf_r (ptr, fd, format, ap);
+  va_end (ap);
+  return n;
 }
 
 #endif /* ! _REENT_ONLY */
Index: libc/stdio/fiprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/fiprintf.c,v
retrieving revision 1.4
diff -u -r1.4 fiprintf.c
--- libc/stdio/fiprintf.c	24 Nov 2004 00:45:41 -0000	1.4
+++ libc/stdio/fiprintf.c	3 Apr 2007 15:18:18 -0000
@@ -16,33 +16,39 @@
  */
 
 #include <_ansi.h>
+#include <reent.h>
 #include <stdio.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 
-#ifdef _HAVE_STDC
 int
-fiprintf(FILE * fp, _CONST char *fmt,...)
-#else
+_DEFUN(_fiprintf_r, (ptr, fp, fmt),
+       struct _reent *ptr _AND
+       FILE * fp _AND
+       const char *fmt _DOTS)
+{
+  int ret;
+  va_list ap;
+
+  va_start (ap, fmt);
+  ret = _vfiprintf_r (ptr, fp, fmt, ap);
+  va_end (ap);
+  return ret;
+}
+
+#ifndef _REENT_ONLY
+
 int
-fiprintf(fp, fmt, va_alist)
-         FILE *fp;
-         char *fmt;
-         va_dcl
-#endif
+_DEFUN(fiprintf, (fp, fmt),
+       FILE * fp _AND
+       const char *fmt _DOTS)
 {
   int ret;
   va_list ap;
 
-#ifdef _HAVE_STDC
   va_start (ap, fmt);
-#else
-  va_start (ap);
-#endif
-  ret = vfiprintf (fp, fmt, ap);
+  ret = _vfiprintf_r (_REENT, fp, fmt, ap);
   va_end (ap);
   return ret;
 }
+
+#endif /* ! _REENT_ONLY */
Index: libc/stdio/fprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/fprintf.c,v
retrieving revision 1.3
diff -u -r1.3 fprintf.c
--- libc/stdio/fprintf.c	23 Apr 2004 20:01:55 -0000	1.3
+++ libc/stdio/fprintf.c	3 Apr 2007 15:18:18 -0000
@@ -16,33 +16,39 @@
  */
 
 #include <_ansi.h>
+#include <reent.h>
 #include <stdio.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 
-#ifdef _HAVE_STDC
 int
-fprintf(FILE * fp, _CONST char *fmt,...)
-#else
+_DEFUN(_fprintf_r, (ptr, fp, fmt),
+       struct _reent *ptr _AND
+       FILE *fp _AND
+       const char *fmt _DOTS)
+{
+  int ret;
+  va_list ap;
+
+  va_start (ap, fmt);
+  ret = _vfprintf_r (ptr, fp, fmt, ap);
+  va_end (ap);
+  return ret;
+}
+
+#ifndef _REENT_ONLY
+
 int
-fprintf(fp, fmt, va_alist)
-        FILE *fp;
-        char *fmt;
-        va_dcl
-#endif
+_DEFUN(fprintf, (fp, fmt),
+       FILE *fp _AND
+       const char *fmt _DOTS)
 {
   int ret;
   va_list ap;
 
-#ifdef _HAVE_STDC
   va_start (ap, fmt);
-#else
-  va_start (ap);
-#endif
-  ret = vfprintf (fp, fmt, ap);
+  ret = _vfprintf_r (_REENT, fp, fmt, ap);
   va_end (ap);
   return ret;
 }
+
+#endif /* ! _REENT_ONLY */
Index: libc/stdio/iprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/iprintf.c,v
retrieving revision 1.7
diff -u -r1.7 iprintf.c
--- libc/stdio/iprintf.c	8 Feb 2005 01:33:17 -0000	1.7
+++ libc/stdio/iprintf.c	3 Apr 2007 15:18:18 -0000
@@ -18,63 +18,39 @@
 #include <_ansi.h>
 #include <reent.h>
 #include <stdio.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 #include "local.h"
 
 #ifndef _REENT_ONLY
 
-#ifdef _HAVE_STDC
 int
-iprintf(_CONST char *fmt,...)
-#else
-int
-iprintf(fmt, va_alist)
-        char *fmt;
-        va_dcl
-#endif
+_DEFUN(iprintf, (fmt),
+       const char *fmt _DOTS)
 {
   int ret;
   va_list ap;
+  struct _reent *ptr = _REENT;
 
-  _REENT_SMALL_CHECK_INIT (_REENT);
-#ifdef _HAVE_STDC
+  _REENT_SMALL_CHECK_INIT (ptr);
   va_start (ap, fmt);
-#else
-  va_start (ap);
-#endif
-  ret = vfiprintf (stdout, fmt, ap);
+  ret = _vfiprintf_r (ptr, _stdout_r (ptr), fmt, ap);
   va_end (ap);
   return ret;
 }
 
 #endif /* ! _REENT_ONLY */
 
-#ifdef _HAVE_STDC
 int
-_iprintf_r(struct _reent *ptr, _CONST char *fmt, ...)
-#else
-int
-_iprintf_r(ptr, fmt, va_alist)
-           struct _reent *ptr;
-           char *fmt;
-           va_dcl
-#endif
+_DEFUN(_iprintf_r, (ptr, fmt),
+       struct _reent *ptr _AND
+       const char *fmt _DOTS)
 {
   int ret;
   va_list ap;
 
   _REENT_SMALL_CHECK_INIT (ptr);
-#ifdef _HAVE_STDC
   va_start (ap, fmt);
-#else
-  va_start (ap);
-#endif
   ret = _vfiprintf_r (ptr, _stdout_r (ptr), fmt, ap);
   va_end (ap);
   return ret;
 }
-
Index: libc/stdio/printf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/printf.c,v
retrieving revision 1.5
diff -u -r1.5 printf.c
--- libc/stdio/printf.c	8 Feb 2005 01:33:17 -0000	1.5
+++ libc/stdio/printf.c	3 Apr 2007 15:18:18 -0000
@@ -18,33 +18,19 @@
 #include <_ansi.h>
 #include <reent.h>
 #include <stdio.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 #include "local.h"
 
-#ifdef _HAVE_STDC
 int
-_printf_r(struct _reent *ptr, _CONST char *fmt, ...)
-#else
-int
-_printf_r(ptr, fmt, va_alist)
-          struct _reent *ptr;
-          char *fmt;
-          va_dcl
-#endif
+_DEFUN(_printf_r, (ptr, fmt),
+       struct _reent *ptr _AND
+       const char *fmt _DOTS)
 {
   int ret;
   va_list ap;
 
   _REENT_SMALL_CHECK_INIT (ptr);
-#ifdef _HAVE_STDC
   va_start (ap, fmt);
-#else
-  va_start (ap);
-#endif
   ret = _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap);
   va_end (ap);
   return ret;
@@ -52,26 +38,17 @@
 
 #ifndef _REENT_ONLY
 
-#ifdef _HAVE_STDC
-int
-printf(_CONST char *fmt, ...)
-#else
 int
-printf(fmt, va_alist)
-       char *fmt;
-       va_dcl
-#endif
+_DEFUN(printf, (fmt),
+       const char *fmt _DOTS)
 {
   int ret;
   va_list ap;
+  struct _reent *ptr = _REENT;
 
-  _REENT_SMALL_CHECK_INIT (_REENT);
-#ifdef _HAVE_STDC
+  _REENT_SMALL_CHECK_INIT (ptr);
   va_start (ap, fmt);
-#else
-  va_start (ap);
-#endif
-  ret = vfprintf (_stdout_r (_REENT), fmt, ap);
+  ret = _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap);
   va_end (ap);
   return ret;
 }
Index: libc/stdio/vasiprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vasiprintf.c,v
retrieving revision 1.2
diff -u -r1.2 vasiprintf.c
--- libc/stdio/vasiprintf.c	12 Mar 2007 20:30:08 -0000	1.2
+++ libc/stdio/vasiprintf.c	3 Apr 2007 15:18:18 -0000
@@ -24,34 +24,17 @@
 #include <_ansi.h>
 #include <stdio.h>
 #include <limits.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 
 #ifndef _REENT_ONLY
 
 int
 _DEFUN(vasiprintf, (strp, fmt, ap),
        char **strp      _AND
-       _CONST char *fmt _AND
+       const char *fmt _AND
        va_list ap)
 {
-  int ret;
-  FILE f;
-
-  f._flags = __SWR | __SSTR | __SMBF;
-  f._bf._base = f._p = NULL;
-  f._bf._size = f._w = 0;
-  f._file = -1;  /* No file. */
-  ret = _vfiprintf_r (_REENT, &f, fmt, ap);
-  if (ret >= 0)
-    {
-      *f._p = 0;
-      *strp = f._bf._base;
-    }
-  return ret;
+  return _vasiprintf_r (_REENT, strp, fmt, ap);
 }
 
 #endif /* !_REENT_ONLY */
@@ -60,7 +43,7 @@
 _DEFUN(_vasiprintf_r, (ptr, strp, fmt, ap),
        struct _reent *ptr _AND
        char **strp        _AND
-       _CONST char *fmt   _AND
+       const char *fmt   _AND
        va_list ap)
 {
   int ret;
Index: libc/stdio/vasprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vasprintf.c,v
retrieving revision 1.5
diff -u -r1.5 vasprintf.c
--- libc/stdio/vasprintf.c	12 Mar 2007 20:30:08 -0000	1.5
+++ libc/stdio/vasprintf.c	3 Apr 2007 15:18:18 -0000
@@ -24,34 +24,17 @@
 #include <_ansi.h>
 #include <stdio.h>
 #include <limits.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 
 #ifndef _REENT_ONLY
 
 int
 _DEFUN(vasprintf, (strp, fmt, ap),
        char **strp      _AND
-       _CONST char *fmt _AND
+       const char *fmt _AND
        va_list ap)
 {
-  int ret;
-  FILE f;
-
-  f._flags = __SWR | __SSTR | __SMBF;
-  f._bf._base = f._p = NULL;
-  f._bf._size = f._w = 0;
-  f._file = -1;  /* No file. */
-  ret = _vfprintf_r (_REENT, &f, fmt, ap);
-  if (ret >= 0)
-    {
-      *f._p = 0;
-      *strp = f._bf._base;
-    }
-  return ret;
+  return _vasprintf_r (_REENT, strp, fmt, ap);
 }
 
 #endif /* !_REENT_ONLY */
@@ -60,7 +43,7 @@
 _DEFUN(_vasprintf_r, (ptr, strp, fmt, ap),
        struct _reent *ptr _AND
        char **strp        _AND
-       _CONST char *fmt   _AND
+       const char *fmt   _AND
        va_list ap)
 {
   int ret;
Index: libc/stdio/vdiprintf.c
===================================================================
RCS file: libc/stdio/vdiprintf.c
diff -N libc/stdio/vdiprintf.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libc/stdio/vdiprintf.c	3 Apr 2007 15:18:18 -0000
@@ -0,0 +1,42 @@
+/* Copyright 2005, 2007 Shaun Jackman
+ * Permission to use, copy, modify, and distribute this software
+ * is freely granted, provided that this notice is preserved.
+ */
+
+#include <_ansi.h>
+#include <reent.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+int
+_DEFUN(_vdiprintf_r, (ptr, fd, format, ap),
+       struct _reent *ptr _AND
+       int fd _AND
+       const char *format _AND
+       va_list ap)
+{
+  char *p;
+  int n;
+
+  _REENT_SMALL_CHECK_INIT (ptr);
+  n = _vasiprintf_r (ptr, &p, format, ap);
+  if (n == -1) return -1;
+  n = _write_r (ptr, fd, p, n);
+  _free_r (ptr, p);
+  return n;
+}
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN(vdiprintf, (fd, format, ap),
+       int fd _AND
+       const char *format _AND
+       va_list ap)
+{
+  return _vdiprintf_r (_REENT, fd, format, ap);
+}
+
+#endif /* ! _REENT_ONLY */
Index: libc/stdio/vdprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vdprintf.c,v
retrieving revision 1.1
diff -u -r1.1 vdprintf.c
--- libc/stdio/vdprintf.c	11 Oct 2005 23:59:32 -0000	1.1
+++ libc/stdio/vdprintf.c	3 Apr 2007 15:18:18 -0000
@@ -1,4 +1,4 @@
-/* Copyright 2005 Shaun Jackman
+/* Copyright 2005, 2007 Shaun Jackman
  * Permission to use, copy, modify, and distribute this software
  * is freely granted, provided that this notice is preserved.
  */
@@ -8,39 +8,36 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 
 int
-_DEFUN (_vdprintf_r, (ptr, fd, format, ap),
-	struct _reent *ptr _AND
-	int fd _AND
-	_CONST char *format _AND
-	va_list ap)
+_DEFUN(_vdprintf_r, (ptr, fd, format, ap),
+       struct _reent *ptr _AND
+       int fd _AND
+       const char *format _AND
+       va_list ap)
 {
-	char *p;
-	int n;
-	_REENT_SMALL_CHECK_INIT (ptr);
-	n = _vasprintf_r (ptr, &p, format, ap);
-	if (n == -1) return -1;
-	n = _write_r (ptr, fd, p, n);
-	_free_r (ptr, p);
-	return n;
+  char *p;
+  int n;
+
+  _REENT_SMALL_CHECK_INIT (ptr);
+  n = _vasprintf_r (ptr, &p, format, ap);
+  if (n == -1)
+    return -1;
+  n = _write_r (ptr, fd, p, n);
+  _free_r (ptr, p);
+  return n;
 }
 
 #ifndef _REENT_ONLY
 
-int 
-_DEFUN (vdprintf, (fd, format, ap),
-	int fd _AND
-	_CONST char *format _AND
-	va_list ap)
+int
+_DEFUN(vdprintf, (fd, format, ap),
+       int fd _AND
+       const char *format _AND
+       va_list ap)
 {
-	_REENT_SMALL_CHECK_INIT (_REENT);
-	return _vdprintf_r (_REENT, fd, format, ap);
+  return _vdprintf_r (_REENT, fd, format, ap);
 }
 
 #endif /* ! _REENT_ONLY */
Index: libc/stdio/vsiprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vsiprintf.c,v
retrieving revision 1.1
diff -u -r1.1 vsiprintf.c
--- libc/stdio/vsiprintf.c	24 Nov 2004 00:45:41 -0000	1.1
+++ libc/stdio/vsiprintf.c	3 Apr 2007 15:18:18 -0000
@@ -24,30 +24,17 @@
 #include <reent.h>
 #include <stdio.h>
 #include <limits.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 
-#ifndef _REENT_ONLY 
+#ifndef _REENT_ONLY
 
 int
 _DEFUN(vsiprintf, (str, fmt, ap),
        char *str        _AND
-       _CONST char *fmt _AND
+       const char *fmt _AND
        va_list ap)
 {
-  int ret;
-  FILE f;
-
-  f._flags = __SWR | __SSTR;
-  f._bf._base = f._p = (unsigned char *) str;
-  f._bf._size = f._w = INT_MAX;
-  f._file = -1;  /* No file. */
-  ret = _vfiprintf_r (_REENT, &f, fmt, ap);
-  *f._p = 0;
-  return ret;
+  return _vsiprintf_r (_REENT, str, fmt, ap);
 }
 
 #endif /* !_REENT_ONLY */
@@ -56,7 +43,7 @@
 _DEFUN(_vsiprintf_r, (ptr, str, fmt, ap),
        struct _reent *ptr _AND
        char *str          _AND
-       _CONST char *fmt   _AND
+       const char *fmt   _AND
        va_list ap)
 {
   int ret;
@@ -70,4 +57,3 @@
   *f._p = 0;
   return ret;
 }
-
Index: libc/stdio/vsniprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vsniprintf.c,v
retrieving revision 1.2
diff -u -r1.2 vsniprintf.c
--- libc/stdio/vsniprintf.c	15 Mar 2007 18:40:48 -0000	1.2
+++ libc/stdio/vsniprintf.c	3 Apr 2007 15:18:18 -0000
@@ -63,11 +63,7 @@
 #include <reent.h>
 #include <stdio.h>
 #include <limits.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 #include <errno.h>
 
 #ifndef _REENT_ONLY
@@ -76,28 +72,10 @@
 _DEFUN(vsniprintf, (str, size, fmt, ap),
        char *str        _AND
        size_t size      _AND
-       _CONST char *fmt _AND
+       const char *fmt _AND
        va_list ap)
 {
-  int ret;
-  FILE f;
-  struct _reent *ptr = _REENT;
-
-  if (size > INT_MAX)
-    {
-      ptr->_errno = EOVERFLOW;
-      return EOF;
-    }
-  f._flags = __SWR | __SSTR;
-  f._bf._base = f._p = (unsigned char *) str;
-  f._bf._size = f._w = (size > 0 ? size - 1 : 0);
-  f._file = -1;  /* No file. */
-  ret = _vfiprintf_r (ptr, &f, fmt, ap);
-  if (ret < EOF)
-    ptr->_errno = EOVERFLOW;
-  if (size > 0)
-    *f._p = 0;
-  return ret;
+  return _vsniprintf_r (_REENT, str, size, fmt, ap);
 }
 
 #endif /* !_REENT_ONLY */
@@ -107,7 +85,7 @@
        struct _reent *ptr _AND
        char *str          _AND
        size_t size        _AND
-       _CONST char *fmt   _AND
+       const char *fmt   _AND
        va_list ap)
 {
   int ret;
Index: libc/stdio/vsnprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vsnprintf.c,v
retrieving revision 1.7
diff -u -r1.7 vsnprintf.c
--- libc/stdio/vsnprintf.c	15 Mar 2007 18:40:48 -0000	1.7
+++ libc/stdio/vsnprintf.c	3 Apr 2007 15:18:18 -0000
@@ -24,11 +24,7 @@
 #include <reent.h>
 #include <stdio.h>
 #include <limits.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 #include <errno.h>
 
 #ifndef _REENT_ONLY
@@ -37,28 +33,10 @@
 _DEFUN(vsnprintf, (str, size, fmt, ap),
        char *str        _AND
        size_t size      _AND
-       _CONST char *fmt _AND
+       const char *fmt _AND
        va_list ap)
 {
-  int ret;
-  FILE f;
-  struct _reent *ptr = _REENT;
-
-  if (size > INT_MAX)
-    {
-      ptr->_errno = EOVERFLOW;
-      return EOF;
-    }
-  f._flags = __SWR | __SSTR;
-  f._bf._base = f._p = (unsigned char *) str;
-  f._bf._size = f._w = (size > 0 ? size - 1 : 0);
-  f._file = -1;  /* No file. */
-  ret = _vfprintf_r (ptr, &f, fmt, ap);
-  if (ret < EOF)
-    ptr->_errno = EOVERFLOW;
-  if (size > 0)
-    *f._p = 0;
-  return ret;
+  return _vsnprintf_r (_REENT, str, size, fmt, ap);
 }
 
 #endif /* !_REENT_ONLY */
@@ -68,7 +46,7 @@
        struct _reent *ptr _AND
        char *str          _AND
        size_t size        _AND
-       _CONST char *fmt   _AND
+       const char *fmt   _AND
        va_list ap)
 {
   int ret;
Index: libc/stdio/vsprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vsprintf.c,v
retrieving revision 1.5
diff -u -r1.5 vsprintf.c
--- libc/stdio/vsprintf.c	23 Apr 2004 20:01:55 -0000	1.5
+++ libc/stdio/vsprintf.c	3 Apr 2007 15:18:18 -0000
@@ -24,30 +24,17 @@
 #include <reent.h>
 #include <stdio.h>
 #include <limits.h>
-#ifdef _HAVE_STDC
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 
-#ifndef _REENT_ONLY 
+#ifndef _REENT_ONLY
 
 int
 _DEFUN(vsprintf, (str, fmt, ap),
        char *str        _AND
-       _CONST char *fmt _AND
+       const char *fmt _AND
        va_list ap)
 {
-  int ret;
-  FILE f;
-
-  f._flags = __SWR | __SSTR;
-  f._bf._base = f._p = (unsigned char *) str;
-  f._bf._size = f._w = INT_MAX;
-  f._file = -1;  /* No file. */
-  ret = _vfprintf_r (_REENT, &f, fmt, ap);
-  *f._p = 0;
-  return ret;
+  return _vsprintf_r (_REENT, str, fmt, ap);
 }
 
 #endif /* !_REENT_ONLY */
@@ -56,7 +43,7 @@
 _DEFUN(_vsprintf_r, (ptr, str, fmt, ap),
        struct _reent *ptr _AND
        char *str          _AND
-       _CONST char *fmt   _AND
+       const char *fmt   _AND
        va_list ap)
 {
   int ret;
@@ -70,4 +57,3 @@
   *f._p = 0;
   return ret;
 }
-



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]