Commit Graph

443 Commits

Author SHA1 Message Date
obrien
08cf798f1d Remove bogus FBSDID. 2004-05-02 20:13:29 +00:00
obrien
c9b83bd8c1 Fix damaged FBSDID. 2004-05-02 20:09:14 +00:00
das
0342c52a18 Merge vfscanf.c, v1.37:
- s/#ifdef FLOATING_POINT/#ifndef NO_FLOATING_POINT/
2004-05-02 10:56:26 +00:00
das
370a72c150 Merge vfprintf.c, v1.65:
- s/#ifdef FLOATING_POINT/#ifndef NO_FLOATING_POINT/
- Remove HEXFLOAT
2004-05-02 10:56:17 +00:00
das
94b1a9eeaf - To make it easier to compile *printf() and *scanf() without
floating-point support, remove default definition of FLOATING_POINT
  from the source, and change the compile-time option to
  NO_FLOATING_POINT.
- Remove the HEXFLOAT option.  It saves an insignificant amount of
  space (<0.1% of the size of libc on i386) and complicates vfprintf()
  and checkfmt().
2004-05-02 10:55:06 +00:00
tjr
2d6eafdb97 Use the correct size to allocate, copy and clear argument type tables
after their change from an array of char to an array of enum.
This fixes problems that occurred when using positional arguments in
format strings, particularly with more than STATIC_ARG_TBL_SIZE (8)
of them.

PR:		65841
Submitted by:	Steven Smith (mostly)
2004-04-22 11:35:12 +00:00
tjr
1c584f59a5 Prepare to handle trivial state-dependent encodings. Full support for
state-dependent encodings with locking shifts will come later if there
is demand for it.
2004-04-07 09:55:05 +00:00
tjr
023efa65f4 Mention that funopen() uses fpos_t incorrectly in the BUGS section. 2004-03-20 08:41:12 +00:00
tjr
55f1dd7399 Improve documentation for fgetpos() and fsetpos(), and discourage
users from assuming that fpos_t is an integral type.
2004-03-20 08:38:27 +00:00
tjr
b893e6c496 Do not redundantly set the stream orientation in getc(), putc(), and
related functions - __sgetc() and __sputc() will set it when necessary.
2004-03-19 09:04:56 +00:00
tjr
41709fbe79 Update list of macros defined in <stdio.h>. 2004-03-17 12:54:06 +00:00
tjr
dab1ed1529 Re-add description of putc() macro (back out rev. 1.13.) 2004-03-17 12:46:17 +00:00
tjr
430cbeb954 Re-add text that says getc() is a macro (back out rev. 1.16.) 2004-03-17 12:37:28 +00:00
tjr
b4d98c6855 Re-add macro versions of getc(), getchar(), putc(), putchar(), feof(),
ferror(), fileno() and clearerr(), using the value of __isthreaded to
decide between the fast inline single-threaded code and the more
general function equivalent. This gives most of the performance
benefits of the old unsafe macros while preserving thread safety.
2004-03-17 01:43:08 +00:00
tjr
feae82b01a Refer to "wide characters" instead of "wide-characters". 2004-03-16 13:30:11 +00:00
tjr
00bce96751 Set stream orientation in ungetc() instead of __ungetc(). This avoids
setting it redundantly when called from ungetwc(), vfscanf() etc.,
which already set the orientation.
2004-03-10 12:41:11 +00:00
tjr
76708e58aa Remove duplicate check for EOF from ungetc(); __ungetc() already checks. 2004-03-10 11:13:23 +00:00
tjr
26739bcc23 Call __sputc() directly in fputc() instead of taking an expensive
detour through putc().
2004-03-10 10:49:45 +00:00
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