Home | History | Annotate | Download | only in stdio
History log of /src/lib/libc/stdio/vfprintf.c
RevisionDateAuthorComments
 1.60  19-Apr-2013  joerg Add explicit locale versions for the printf family. Replace asprintf,
snprintf and sprintf with simple wrappers around the corresponding
va_list functions to reduce code duplication.
 1.59  15-Oct-2009  dsl branches: 1.59.6; 1.59.12;
Reverse previous, committed by mistake.
 1.58  14-Oct-2009  dsl Change a while () {} into a do {} while() so that fgets(buf, 1, file)
detects EOF on an empty file.
Fixes most of PR/41992
 1.57  03-Feb-2007  christos use vfwprintf.c
 1.56  02-Feb-2007  christos Instead of abusing stdio to get a signal-safe version of sprintf, provide one.
 1.55  26-Jan-2007  cbiere Fix for issue reported in PR lib/35401 as well as related overflow bugs.
 1.54  30-Oct-2006  christos branches: 1.54.2;
set n properly so that we can terminate.
 1.53  28-Oct-2006  christos Initialize decimal_point.
 1.52  28-Oct-2006  christos initialize floating_point as needed.
 1.51  27-Oct-2006  christos Add signal-safe versions of snprintf and vsnprintf
 1.50  16-Feb-2006  christos - s/notyet/WIDE_DOUBLE/
- Add a little more glue for WIDE_DOUBLE; not done yet.
- s/def FLOATING_POINT/ndef NO_FLOATING_POINT/ to reduce diffs with FreeBSD.
- fix memory leak where each double formatted leaked 24 by calling __freedtoa()
appropriately. the new gdtoa keeps a list of memory chunks allocated by
malloc(), and it must maintained properly by calling __freedtoa() on the
results of __dtoa() Hi Klaus!
- in vfwprintf() make cvt return char * and convert it using __mbsconv(),
instead of having it return wchar_t *.

This should fix the memory leaks people have been reporting (eg. in top etc.)
 1.49  29-Nov-2005  christos WARNS=4
 1.48  09-Feb-2005  kleink A little libc namespace housekeeping exercise:
* Make vfprintf_unlocked() an internal function, c.f. __svfscanf_unlocked().
* Add internal names for arc4random(), endnetpath(), fhstatvfs(),
fstatvfs(), mkstemp(), shquote(), statvfs(), taddr2uaddr(), uaddr2taddr(),
uuid_create_nil(), uuid_is_nil(), and wcwidth().
* Include namespace.h where supposed to.
 1.47  02-Jul-2004  christos remove __UNCONST definition; it is now in <sys/cdefs.h>
 1.46  03-Mar-2004  drochner branches: 1.46.4;
Don't zero a floating point variable on entry -- this causes the FPU to
be allocated needlessly by almost every program (at least on i386/amd64).
 1.45  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.44  18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.43  26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.42  07-Dec-2001  yamt - make FILE structure extensible without breaking binary-compatibility.
- add fputwc, fgetwc, fwide and related functions.
- add hooks needed to maintain the orientation of file stream.
 1.41  02-Dec-2001  kleink C99:
* Recognize %F.
* Convert {Infinity,NaN} to {"inf","nan"} for %[efg], and to
{"INF","NAN"} for %[EFG].
 1.40  28-Nov-2001  kleink Since we're returned the sign of a floating-point number by __dtoa(),
use that to decide whether to include a minus sign in the result.
Fixes printing -0.0, and thus PR lib/3137.
 1.39  27-Nov-2001  augustss Ugh, back out last commit. It makes vfprintf depend on -lm.
 1.38  27-Nov-2001  augustss Print sign of -0.0 correctly. Fixes PR 3137 (mine).
 1.37  04-Nov-2001  lukem fix WARNS=2 (-Wshadow) warnings
 1.36  28-Apr-2001  kleink * Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.35  30-Dec-2000  itojun branches: 1.35.2;
initialize mbstate_t properly.
 1.34  23-Dec-2000  itojun make printf-variant work with stateful encodings.
 1.33  08-Jul-2000  sommerfeld Attach __format__ attributes to local __sbprintf function
 1.32  20-Sep-1999  lukem branches: 1.32.8;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.31  16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.30  15-Nov-1998  christos This is ugly. There is a const castaway inside the print macro, so we cannot
use /* LINTED */ comments, since cpp will expand comments only at the macro
definition location, not at every expansion.
 1.29  13-Oct-1998  kleink Need internal names for isinf() and isnan().
 1.28  09-Sep-1998  kleink Perform stdio stream locking as appropriate.
 1.27  27-Jul-1998  mycroft Delint (partially).
 1.26  26-Jul-1998  mycroft Minor nit.
 1.25  26-Jul-1998  mycroft const poisoning.
 1.24  26-Jul-1998  mycroft const poisoning.
 1.23  03-Feb-1998  perry remove obsolete register declarations
 1.22  19-Dec-1997  kleink Change several functions to return -1 instead of EOF, which was semantically
wrong.
 1.21  29-Aug-1997  phil Remove the flag test when seeing if _double is zero or not. We
are only testing for the cvt problem, not for alternate forms.
This change makes %#e and %e both correctly print 0. It is just
a question of is it the proper number of zeros or not?
 1.20  13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
Add prototypes for functions that were declared in more than one place
to local.h or extern.h and use that instead.
 1.19  03-May-1997  kleink Upon an attempt to write to a stream that can't be written to, set errno
to EBADF.
 1.18  02-Apr-1997  kleink RCSid police
 1.17  02-May-1995  jtc The C Standard says that printf's format string is a multi-byte
character string. NA1 says that the 99 characters required by the
Standard have representations in the initial state which are one byte
long and do not alter the state.

Thus we can safely break apart the format string with mbtowc() until
we reach a '%' character, and the process format directive characters
one by one.

We really shouldn't be using mbtowc(), rather mbrtowc() (which takes a
mbstate-t argument) but we don't have the NA1 functions implemented
yet. This is safe, because even when we do we're not likely to
support multi-byte character encodings that use shift states.
 1.16  22-Mar-1995  jtc Added "long long" support %ll{d,x,o,i}.
 1.15  25-Feb-1995  cgd when you have a pointer and want to assign to a quad, you must cast it
to long to quiet the compiler.
 1.14  25-Jan-1995  jtc branches: 1.14.2;
Fixed bug with '+' or ' ' flags and precision.
for example, printf("% 6.4d\n", 77) output one two many padding chars.
 1.13  20-Oct-1994  jtc Fix zero padding when using the # format modifier.
 1.12  30-Sep-1994  jtc The decimal point character is locale specific.
 1.11  19-Sep-1994  mycroft Move FLOATING_POINT definition into Makefile.inc.
 1.10  22-May-1994  cgd _VA_LIST_ -> _BSD_VA_LIST_
 1.9  04-Nov-1993  jtc Corrected and simplified floating point formatting.
Now conforms to ANSI C --- passes the fairly rigorous TCL "format.test".
 1.8  03-Nov-1993  jtc Trailing zeros should be printed with all floating point formats
except %g && %G --- ANSI X3.159-1989, Sect 7.9.6.1.
 1.7  26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.6  01-Aug-1993  mycroft Add RCS identifiers.
 1.5  12-Jul-1993  mycroft Make declarations match prototypes.
 1.4  09-Jul-1993  cgd update for better FP routines, from AT&T & elsewhere
 1.3  18-Apr-1993  mycroft Fix error in last patch.
 1.2  18-Apr-1993  mycroft Make arguments match prototypes.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2  02-Feb-1995  jtc imported from 44lite
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.14.2.1  02-Mar-1995  jtc #include "namespace.h"
 1.32.8.1  09-Dec-2001  he Pull up revision 1.40 (requested by kleink):
Print the sign prefix for -0.0; fixes PR#3137.
 1.35.2.6  21-Jun-2002  nathanw Catch up to -current.
 1.35.2.5  02-May-2002  nathanw Remove calls to FLOCKFILE() and FUNLOCKFILE() from vfprintf() and __svfscanf(),
rename those routines to vfprintf_unlocked() and __svfscanf_unlocked(),
and implement vfprintf() and __svfscanf() as small routines that do
FLOCKFILE()/foo_unlocked()/FUNLOCKFILE().
 1.35.2.4  06-Feb-2002  nathanw #include "reentrant.h" before "local.h" so that the thread types used
in fileext.h are avaliable.
 1.35.2.3  28-Jan-2002  nathanw Catch up to -current.
 1.35.2.2  14-Nov-2001  nathanw Catch up to -current.
 1.35.2.1  08-Oct-2001  nathanw Catch up to -current.
 1.46.4.1  01-Jun-2005  riz Pull up revision 1.47 (requested by christos in ticket #1968):
remove __UNCONST definition; it is now in &lt;sys/cdefs.h&gt;
 1.54.2.1  07-May-2007  pavel Pull up following revision(s) (requested by manu in ticket #607):
lib/libc/arch/i386/gen/isnanl.c: revision 1.6
lib/libc/gdtoa/gdtoa.c: revision 1.2-1.3
lib/libc/arch/x86_64/gen/isnanl.c: revision 1.6
lib/libc/gdtoa/gdtoaimp.h: revision 1.6
sys/arch/m68k/include/ieee.h: revision 1.13
usr.bin/xlint/lint1/scan.l: revision 1.36-1.37
lib/libc/stdio/snprintf_ss.c: revision 1.4
lib/libc/arch/i386/gen/isfinitel.c: revision 1.2
lib/libc/stdio/vfscanf.c: revision 1.38
sys/arch/sparc/include/ieee.h: revision 1.11-1.12
lib/libc/gdtoa/dtoa.c: revision 1.4
lib/libc/stdio/Makefile.inc: revision 1.35
lib/libc/stdio/fvwrite.c: revision 1.17
lib/libc/arch/m68k/gen/fpclassifyl.c: revision 1.2
lib/libc/arch/i386/gen/isinfl.c: revision 1.6
lib/libc/arch/x86_64/gen/isinfl.c: revision 1.6
lib/libc/arch/x86_64/gen/isfinitel.c: revision 1.2
lib/libc/stdio/vfprintf.c: revision 1.55-1.57
lib/libc/stdio/vsnprintf_ss.c: revision 1.3
lib/libc/stdio/vfwprintf.c: revision 1.10
sys/arch/x86/include/ieee.h: revision 1.10
lib/libc/gdtoa/dmisc.c: revision 1.3
lib/libc/gdtoa/Makefile.inc: revision 1.5
sys/arch/hppa/include/ieee.h: revision 1.10
lib/libc/arch/x86_64/gen/fpclassifyl.c: revision 1.3
lib/libc/arch/i386/gen/fpclassifyl.c: revision 1.2
sys/sys/ieee754.h: revision 1.7
lib/libc/gdtoa/gdtoa.h: revision 1.7
include/stdio.h: revision 1.67-1.68
lib/libc/gdtoa/hdtoa.c: revision 1.1-1.4
lib/libc/gdtoa/ldtoa.c: revision 1.1-1.4
defined(_NETBSD_SOURCE) is equivalent to (!defined(_ANSI_SOURCE) &&
!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)), so there's no
need to check both of them.
Fix for issue reported in PR lib/35401 as well as related overflow bugs.
deal with hex doubles.
Instead of abusing stdio to get a signal-safe version of sprintf, provide one.
remove __SAFE
add long double and hex double support from freebsd.
make this compile.
add new prototypes.
add the new files to the build. Note I am not bumping libc now, because
these are not used yet.
Merge the int bit with the high fraction bit. Add constants/macros
needed by gdtoa.
add constants used by gdtoa
since the int bit is merged, do the explicit math.
ext_int bit is no more.
ext_int bit is no more.
- merge change from freebsd
- add support for building as vfprintf.c
- XXX: we strdup to simplify the freeing logic. This should be fixed for
efficiency in the vfprintf case.
use vfwprintf.c
enable wide doubles.
some int -> size_t
deal with sparc64 that has 112 bits of mantissa.
make extended precision gdtoa friendly.
int/size_t changes
make this gdtoa friendly.
remove dup definition
use dtoa() instead of returning empty when we don't have extended precision
information.
Fix previous, add forgotten pointer dereference in the call to dtoa().
Add a cheesy workaround marked XXX for the situation where the
strtod() implementation available in the environment does not
handle hex floats.
Discussed with and suggested by christos
From Christos: gdtoa fixes for m68k. M68k ports should build now, but
printing extended precision is a little off.
vax does not have <machine/ieee.h> or long double
It would be nice if the compiler provided something like __IEEE_MATH__
bring in FreeBSD's vfscanf() to gain multi-byte/collation support.
Unfortunately it is too difficult to make vfwscanf and this share
the same code like I did with printf, because for string parsing
the code is too different.
 1.59.12.1  23-Jun-2013  tls resync from head
 1.59.6.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")

RSS XML Feed