Commit Graph

425 Commits

Author SHA1 Message Date
tjr
d856ced836 Call __sgetc() directly in getchar() instead of taking an expensive
detour through getc().
2004-03-10 10:24:15 +00:00
tjr
c1542ae485 Set the stream orientation explicitly in fgetln() instead of relying on
__srefill() to do it.
2004-03-10 09:28:38 +00:00
tjr
d27994efb7 Set stream orientation in puts(). 2004-03-10 09:15:38 +00:00
jb
c50fc65e96 Backout the previous revision due to objections. 2004-03-09 04:51:58 +00:00
jb
e9062915d3 On 4.X it was possible for an application to initialise a local FILE
structure and call stdio functions. In 5.X this was broken when FILE
locking was introduced into libc.

This change makes most (relevant) stdio functions work again when the
_extra file in FILE isn't initialised (and can't be without a libc
function to do it since the __sFILEX structure is private to libc).
2004-03-09 02:44:59 +00:00
jkh
5a199c908b If handed a file pointer we can't write to, set errno properly to EBADF
in order to get SUSv2 conformant behavior in higher level calls like
fputs() and puts().

Reviewed by:	bde
2004-03-02 19:43:51 +00:00
green
bf4ea3aa0d Document dependence of mktemp(3) on the non-reentrant arc4random(3). 2004-02-20 04:08:28 +00:00
das
a3a1377ebf Merge vfscanf.c,v 1.35. 2004-01-31 23:18:53 +00:00
das
f042400fb5 Fix the handling of negative hexadecimal numbers in integer formats.
Note that this bug is unrelated to recent work in this area; it seems
to have been present since revision 1.1.

Obtained from:	NetBSD
2004-01-31 23:16:09 +00:00
das
041f2e6f18 Merge vfprintf.c, v1.61 and 1.62. For compatibility with __hdtoa()
and to reduce diffs between vfprintf.c and vfwprintf.c, declare xdigs*
to be char arrays rather than wchar_t arrays.

In collaboration with:	tjr
2004-01-23 22:48:16 +00:00
das
100a99f4f7 Bring the *printf(3) documentation up to date with the code:
- Update and improve the documentation for %[aA]
  o Like %[eE], %[aA] may round the result if a precision is specified.
  o Grammar police: Fix a split infinitive.
  o The FreeBSD implementation does better than the minimum required
    by C99 (literal translation of the mantissa).  The digit before
    the hexadecimal-point is never 0 unless the number itself is 0.
  o Clarify that the exponent field represents a decimal exponent of 2.
  o Discuss the fact that multiple valid representations are possible.
  o Remove the entry in the BUGS section claiming that %[aA] is not
    implemented.

- Remove the entry in the BUGS section claiming that the ' flag for
  printing thousands separators is unimplemented for floating-point.

- Remove the entry in the BUGS section claiming that the L modifier
  reduces the precision to "double" before conversion.
2004-01-19 08:28:30 +00:00
das
06e5503ed1 Implement __hdtoa() and __hldtoa() and enable printf() support for %a
and %A, which print floating-point numbers in hexadecimal.
2004-01-18 10:32:49 +00:00
das
40c56bf93f Prototype __hdtoa() and __hldtoa(). 2004-01-18 08:28:47 +00:00
das
aa64e11b02 Fix some bugs affecting the %a and %A format specifiers. Since
these are not fully implemented and ifdef'd out, the bugs have
never manifested themselves.  Specifically:

	- Fix a memory leak in the case where %a follows another
	  floating-point format.
	- Make the %a/%A code behave like %e/%E with respect to
	  precision.
	- It is no longer valid to assume that '-' and '0x' are
	  mutually exclusive.
	- Address other minor issues.
2004-01-18 08:28:32 +00:00
nectar
a455b2e93e Make intentions explicit with additional parenthesis. 2004-01-06 18:32:24 +00:00
nectar
c281d0e2ea Remove unused variables and function declarations. Add missing headers. 2004-01-06 18:26:15 +00:00
tjr
9ef7fe6cd5 Fix prototype for getchar_unlocked(). 2003-12-07 05:12:51 +00:00
tjr
7a8b48f087 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
tjr
736d21ee30 Pass NULL instead of a pointer to a zeroed mbstate_t object. 2003-11-05 08:20:45 +00:00
tjr
46a574efa9 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
tjr
f34fc0c744 Fix a typo that caused the optimized single-byte locale path not to be taken. 2003-11-01 08:18:18 +00:00
ru
1c23ef339b mdoc(7): Use the new feature of the .In macro. 2003-09-08 19:57:22 +00:00
tjr
36cc2a99e1 Add more useful cross-references to the SEE ALSO section. 2003-07-05 07:55:34 +00:00
tjr
6b15b2e031 Catch up with recent FP-related changes to scanf.3 and vfwscanf.c. 2003-07-05 07:47:55 +00:00
tjr
8f7372609c 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
tjr
c80ccf2b5d Merge recent floating point conversion changes from vfscanf.c. 2003-07-05 02:35:06 +00:00
jkh
6703655ca0 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
das
8ec19d5954 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
das
395c7a4e3a 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
charnier
9f754871d1 Add or correct section number in .Xr. Use .Vt or .Fn
instead of .Xr when needed
2003-06-08 10:01:52 +00:00
ru
9bcac8799e Assorted mdoc(7) fixes.
Approved by:	re (blanket)
2003-05-22 13:02:28 +00:00
das
30c051657a %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
tjr
bb06bbb4a0 Merge in vfprintf.c rev. 1.58. 2003-04-14 12:15:59 +00:00
das
c01851b648 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
tjr
7714c81b08 Catch up with recent vfprintf.c changes. 2003-04-07 06:36:49 +00:00
ache
c0bef0ac8a __wcsconv(): free(convbuf) before returning NULL 2003-04-07 03:17:39 +00:00
das
cd640e57f7 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
das
0a3b47a120 - %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
das
541451f14d 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
das
3a31325651 Add missing #include to unbreak previous commit. 2003-04-05 22:08:53 +00:00
das
c0e486bd07 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
tjr
d91d5d0610 Merge vfprintf.c revision 1.52. 2003-03-14 08:50:43 +00:00
das
1859ac4c25 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
tjr
4ffbd7a7a7 Unexpand RCS tag. 2003-03-14 04:46:02 +00:00
tjr
91582a7223 MFp4: Catch up to recent __dtoa() interface changes and removal of cvt()'s
last argument.
2003-03-13 05:49:09 +00:00
das
d02cfc3692 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
tjr
519d3ae8c7 MFp4: Add the standard "the {fgetws,fputws} function will fail if" text
to the Errors section.
2003-03-09 02:56:54 +00:00
ru
8b5b8ec6a7 mdoc(7) police: markup laundry. 2003-02-23 01:47:49 +00:00
gshapiro
b72619cecb 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
nectar
832e8b7f9a 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