Commit Graph

408 Commits

Author SHA1 Message Date
Tim J. Robbins
909a17f41a Use __sfvwrite() instead of __sputc() via __fputwc() to write to fake
string files (__SSTR flag set). This is necessary because __sputc()
does not respect the __SALC flag, and crashes trying to flush the buffer
instead of resizing it.

PR:		59167
2003-11-12 08:49:12 +00:00
Tim J. Robbins
2a49d3767f Pass NULL instead of a pointer to a zeroed mbstate_t object. 2003-11-05 08:20:45 +00:00
Tim J. Robbins
a27a4b3690 Pass mbrtowc() and wcrtomb() NULL instead of a pointer to a freshly zeroed
mbstate_t object that they ignore. The zeroing is fairly expensive, and it
will never be necessary in these functions; when we support state-dependent
encodings, we will pass in a pointer to the file's mbstate_t object, and
only zero it at the time the file gets opened.
2003-11-04 11:05:55 +00:00
Tim J. Robbins
d86d5b37b7 Fix a typo that caused the optimized single-byte locale path not to be taken. 2003-11-01 08:18:18 +00:00
Ruslan Ermilov
fe08efe680 mdoc(7): Use the new feature of the .In macro. 2003-09-08 19:57:22 +00:00
Tim J. Robbins
8954a5c85a Add more useful cross-references to the SEE ALSO section. 2003-07-05 07:55:34 +00:00
Tim J. Robbins
759f7dc308 Catch up with recent FP-related changes to scanf.3 and vfwscanf.c. 2003-07-05 07:47:55 +00:00
Tim J. Robbins
4ea76cb195 Fix two incorrect uses of sizeof: we need to divide the size of the buffer
by sizeof(wchar_t) to get the number of wide characters it contains.
Remove the !hardway micro-optimisation from the CT_INT case to avoid
having to fix it for wide characters.
2003-07-05 03:39:23 +00:00
Tim J. Robbins
b5c3fe0098 Merge recent floating point conversion changes from vfscanf.c. 2003-07-05 02:35:06 +00:00
Jordan K. Hubbard
b0a06af596 When size is 1 should just null terminate the string. The dummy variable
is made an array of two, to explicitly avoid stack corruption due to
null-terminating (which is doesn't actually happen due to stack alignment
padding).

Submitted by: Ed Moy <emoy@apple.com>
Obtained from: Apple Computer, Inc.
2003-07-02 07:08:44 +00:00
David Schultz
b6b7fb3782 Update to reflect changes in vfscanf.c,v 1.32. Remove bogus
documentation for %a, and document it correctly instead.
s/one of aefg/one of a, e, f, or g/

Reviewed by:	standards@
2003-06-28 09:03:25 +00:00
David Schultz
370077c7a6 Revamp scanf's floating-point-parsing algorithm to support
[+|-]Inf, [+|-]NaN, nan(...), and hexidecimal FP constants.
While here, add %a and %A, which are aliases for %e, and
add support for long doubles.

Reviewed by:	standards@
2003-06-28 09:03:05 +00:00
Philippe Charnier
0d511e328f Add or correct section number in .Xr. Use .Vt or .Fn
instead of .Xr when needed
2003-06-08 10:01:52 +00:00
Ruslan Ermilov
3a5146d9e2 Assorted mdoc(7) fixes.
Approved by:	re (blanket)
2003-05-22 13:02:28 +00:00
David Schultz
1f2a0cdf58 %E-like %g and %G conversions should remove trailing zeroes unless
the # flag is present.  Implement this behavior and add a comment
describing it.

Noticed by:	Enache Adrian <enache@rdslink.ro>
Pointy hat to:	das
2003-04-19 23:53:19 +00:00
Tim J. Robbins
d73c448b1c Merge in vfprintf.c rev. 1.58. 2003-04-14 12:15:59 +00:00
David Schultz
81ae2e9a4d Fix a bug where printf was erroneously printing a decimal point for
%f and sufficiently short %g specifiers where the precision was
explicitly zero, no '#' flag was specified, and the floating point
argument was > 0 and <= 0.5.  While at it, add some comments to better
explain the relevant bits of code.

Noticed by:	Christoph Kukulies <kuku@physik.rwth-aachen.de>
2003-04-14 11:24:53 +00:00
Tim J. Robbins
adfd6b312d Catch up with recent vfprintf.c changes. 2003-04-07 06:36:49 +00:00
Andrey A. Chernov
6f098a4811 __wcsconv(): free(convbuf) before returning NULL 2003-04-07 03:17:39 +00:00
David Schultz
d890afb84d Today just isn't my day. Remove some old commented out code that snuck
into the last commit.

Noticed by:	mike
2003-04-07 01:07:48 +00:00
David Schultz
3b204b7d09 - %e conversions with precision 0 should not cause a decimal point to
be printed.
- Fix %f conversions where the number of significant digits is < expt.
  This would be a one-line change were it not for thousands separators.
  Noticed by tjr.
- Remove some unnecessary code in the parsing of precision specifiers.
2003-04-07 00:42:19 +00:00
David Schultz
ebbad5ec5c Rework the floating point code in printf(). Significant changes:
- We used to round long double arguments to double.  Now we print
  them properly.

- Bugs involving '%F', corner cases of '#' and 'g' format
  specifiers, and the '.*' precision specifier have been
  fixed.

- Added support for the "'" specifier to print thousands' grouping
  characters in a locale-dependent manner.

- Implement the __vfprintf() side of hexadecimal floating point
  support.  All that is still needed is a routine to convert the
  mantissa to hex digits one nibble at a time in the style of ultoa().

Reviewed by:	silence on standards@
2003-04-05 22:11:42 +00:00
David Schultz
b936664e72 Add missing #include to unbreak previous commit. 2003-04-05 22:08:53 +00:00
David Schultz
38cac8f88b Correct some buffer sizes.
- __vfprintf()'s 'buf' has never been used for floating point, so
  don't define it in terms of (incorrect) constants describing
  floating point numbers.  The actual size needed depends on
  sizeof(uintmax_t) and locale details, so I slightly overestimated.

- We don't need a 308-character buffer to store the string "308".
  With long doubles and %a we need more than three characters, though.
2003-04-05 22:03:43 +00:00
Tim J. Robbins
ce7be15190 Merge vfprintf.c revision 1.52. 2003-03-14 08:50:43 +00:00
David Schultz
3ba6b6dd9d Kludge around a bug that results from printf() assuming that
dtoa() is buggy.  The bug would cause incorrect output to be
generated when format strings such as '%5.0f' were used with
nonzero numbers whose magnitude is less than 1.

Reported by:	df(1) by way of periodic(8)
Reviewed by:	mike
2003-03-14 04:48:09 +00:00
Tim J. Robbins
15a66d2798 Unexpand RCS tag. 2003-03-14 04:46:02 +00:00
Tim J. Robbins
48755f216d MFp4: Catch up to recent __dtoa() interface changes and removal of cvt()'s
last argument.
2003-03-13 05:49:09 +00:00
David Schultz
6a66acb565 Replace our ancient dtoa/strtod implementation with the gdtoa
package, a more recent, generalized set of routines.  Among the
changes:
- Declare strtof() and strtold() in stdlib.h.
- Add glue to libc to support these routines for all kinds
  of ``long double''.
- Update printf() to reflect the fact that dtoa works slightly
  differently now.

As soon as I see that nothing has blown up, I will kill
src/lib/libc/stdlib/strtod.c.  Soon printf() will be able
to use the new routines to output long doubles without loss
of precision, but numerous bugs in the existing code must
be addressed first.

Reviewed by:	bde (briefly), mike (mentor), obrien
2003-03-12 20:30:00 +00:00
Tim J. Robbins
be0ccb6800 MFp4: Add the standard "the {fgetws,fputws} function will fail if" text
to the Errors section.
2003-03-09 02:56:54 +00:00
Ruslan Ermilov
522ccf3f35 mdoc(7) police: markup laundry. 2003-02-23 01:47:49 +00:00
Gregory Neil Shapiro
8f3e32c2b6 Fix the description for mkdtemp(), which creates directories, not files.
Submitted by:	Murray S. Kucherawy <msk@blackops.org>
X-MFC after:	re approval
2003-02-19 04:40:30 +00:00
Jacques Vidrine
e0554a531f Eliminate 61 warnings emitted at WARNS=2 (leaving 53 to go).
Only warnings that could be fixed without changing the generated object
code and without restructuring the source code have been handled.

Reviewed by:	/sbin/md5
2003-02-16 17:29:11 +00:00
Mike Makonnen
e5b9245bfa Fix use of an uninitialized pointer introduced in a previous revision.
Approved by:	markm (mentor)(implicit)
2003-02-06 01:08:19 +00:00
Tim J. Robbins
56b9200d1f Back out previous. Many people disagreed with removing the warning. 2003-01-30 23:32:53 +00:00
Tim J. Robbins
8137227111 Remove runtime warning about gets(). 2003-01-30 12:00:26 +00:00
Tim J. Robbins
21d4d23958 Lock stdin on entry, unlock on return, use __sgetc() instead of getchar()
to avoid locking the stream for each character and to avoid input being
scattered among multiple threads.
2003-01-30 11:46:25 +00:00
Tim J. Robbins
21a1863da8 Remove part of my stateful locale patch that slipped into the previous rev. 2003-01-26 11:45:54 +00:00
Tim J. Robbins
c297498757 Initial implementation of the C99 feature whereby calling freopen() with
a NULL filename argument allows a stream's mode to be changed. At the
moment it just recycles the old file descriptor instead of storing the
filename somewhere and using that to reopen the file, as the standard
seems to require. Strictly conforming C99 applications probably can't
tell the difference but POSIX ones can.

PR:		46791
2003-01-26 10:01:59 +00:00
Tim J. Robbins
2c19171bc1 Lock the stream before calling __sfileno() to retrieve the file descriptor.
1003.1-2001 requires that fileno() behave as if it locks the stream.
2003-01-13 02:58:18 +00:00
Tim J. Robbins
83bb3b4979 Add missing word to "Return Values" section. 2003-01-13 01:29:14 +00:00
Tim J. Robbins
c24891e9e2 The macro versions of putc() and putchar() are gone. 2003-01-10 07:47:12 +00:00
Tim J. Robbins
9031030003 There is no macro version of getc() anymore. 2003-01-10 07:45:24 +00:00
Tim J. Robbins
72c9dabbb7 Bring the list of function-like macros up to date with reality. 2003-01-10 07:38:38 +00:00
Alfred Perlstein
d2b9b6b10c spell multiple correctly. 2003-01-10 06:52:19 +00:00
Tim J. Robbins
4549f62011 Document clearerr_unlocked(), feof_unlocked(), ferror_unlocked()
and fileno_unlocked().
2003-01-10 06:22:28 +00:00
Tim J. Robbins
4d844c09ac Add a manual page for flockfile(), ftrylockfile(), and funlockfile(). 2003-01-10 05:34:11 +00:00
Tim J. Robbins
cbee408df1 Document getc_unlocked(), getchar_unlocked(), putc_unlocked(),
and putchar_unlocked().
2003-01-10 04:56:20 +00:00
Tim J. Robbins
a5b0089e65 Add function versions of getchar_unlocked(), getc_unlocked(),
putchar_unlocked(), putc_unlocked(), feof_unlocked(), ferror_unlocked(),
clearerr_unlocked(), and fileno_unlocked(). The first four are required
by POSIX. The rest are provided for consistency.
2003-01-10 04:35:08 +00:00
Tim J. Robbins
16fdde11b7 Remove an unused variable: mbresult. 2003-01-07 06:20:47 +00:00