Commit graph

454 commits

Author SHA1 Message Date
Ruslan Ermilov 30950a21e1 Eliminate double whitespace. 2004-07-03 22:30:10 +00:00
Ruslan Ermilov 1a0a934547 Mechanically kill hard sentence breaks. 2004-07-02 23:52:20 +00:00
Ruslan Ermilov 33992dc0ed Markup, grammar, and spelling fixes. 2004-06-30 20:09:10 +00:00
Mike Pritchard 14243126c5 Spelling fixes. 2004-06-21 19:38:25 +00:00
Stefan Farfeleder cf6fc3417a The third operand of the conditional operator should have type void too.
Approved by:	das (mentor)
2004-06-08 12:03:48 +00:00
David Schultz 92a5b2ee71 Rename cantwrite() to prepwrite(). The latter is less confusing,
since the macro isn't really a predicate, and it has side-effects.
Also, don't set errno if prepwrite() fails, since this is done in
prepwrite() now.
2004-06-08 05:45:48 +00:00
David Schultz 52183d4654 Rename cantwrite() to prepwrite(). The latter is less confusing,
since the macro isn't really a predicate, and it has side-effects.
2004-06-08 05:45:32 +00:00
David Schultz 325d97d0d1 Set errno to EBADF on attempts to write to a stream that is not
writable.  Affected callers include fwrite(), put?(), and *printf().
The issue of whether this is the right errno for funopened streams is
unresolved, but that's an obscure case, and some errno is better than
no errno.

Discussed with:	bde, jkh
2004-06-08 05:44:52 +00:00
Tim J. Robbins e7e4715db2 Provide trivial macro implementations of getwc(), getwchar(), putwc() and
putwchar() to reduce function call overhead.
2004-05-25 10:42:52 +00:00
Tim J. Robbins d6ed810a67 Perform conversions straight from the stream buffer instead of scanning
through byte by byte with mbrtowc(). In the usual case (buffer is big
enough to contain the multibyte character, character does not straddle
buffer boundary) this results in only one call to mbrtowc() for each
wide character read.
2004-05-22 15:41:03 +00:00
Tim J. Robbins 87275e436a Associate a multibyte conversion state object with each stream. Reset it
to the initial state when a stream is opened or seeked upon. Use the
stream's conversion state object instead of a freshly-zeroed one in
fgetwc(), fputwc() and ungetwc().

This is only a performance improvement for now, but it would also be
required in order to support state-dependent encodings.
2004-05-22 15:19:41 +00:00
David E. O'Brien 253f85d3c9 Remove bogus FBSDID. 2004-05-02 20:13:29 +00:00
David E. O'Brien af15264014 Fix damaged FBSDID. 2004-05-02 20:09:14 +00:00
David Schultz 30d3088041 Merge vfscanf.c, v1.37:
- s/#ifdef FLOATING_POINT/#ifndef NO_FLOATING_POINT/
2004-05-02 10:56:26 +00:00
David Schultz ce2551ad29 Merge vfprintf.c, v1.65:
- s/#ifdef FLOATING_POINT/#ifndef NO_FLOATING_POINT/
- Remove HEXFLOAT
2004-05-02 10:56:17 +00:00
David Schultz 8de9e89719 - 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
Tim J. Robbins ccc8c6c31f 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
Tim J. Robbins 93996f6d58 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
Tim J. Robbins 6eb5892c2b Mention that funopen() uses fpos_t incorrectly in the BUGS section. 2004-03-20 08:41:12 +00:00
Tim J. Robbins 1e709c9cb5 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
Tim J. Robbins f639538c20 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
Tim J. Robbins 3236e08bf8 Update list of macros defined in <stdio.h>. 2004-03-17 12:54:06 +00:00
Tim J. Robbins 7a0fae27c9 Re-add description of putc() macro (back out rev. 1.13.) 2004-03-17 12:46:17 +00:00
Tim J. Robbins 0ac162b7cc Re-add text that says getc() is a macro (back out rev. 1.16.) 2004-03-17 12:37:28 +00:00
Tim J. Robbins 567d74a5ec 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
Tim J. Robbins 34d72a66ad Refer to "wide characters" instead of "wide-characters". 2004-03-16 13:30:11 +00:00
Tim J. Robbins 85fa6736d8 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
Tim J. Robbins 4124f7c013 Remove duplicate check for EOF from ungetc(); __ungetc() already checks. 2004-03-10 11:13:23 +00:00
Tim J. Robbins a6a9f0cde3 Call __sputc() directly in fputc() instead of taking an expensive
detour through putc().
2004-03-10 10:49:45 +00:00
Tim J. Robbins 2df1baf643 Call __sgetc() directly in getchar() instead of taking an expensive
detour through getc().
2004-03-10 10:24:15 +00:00
Tim J. Robbins 87a6c90a99 Set the stream orientation explicitly in fgetln() instead of relying on
__srefill() to do it.
2004-03-10 09:28:38 +00:00
Tim J. Robbins d17235e59f Set stream orientation in puts(). 2004-03-10 09:15:38 +00:00
John Birrell 44fce14365 Backout the previous revision due to objections. 2004-03-09 04:51:58 +00:00
John Birrell 59fac1825f 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
Jordan K. Hubbard 1b629e865e 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
Brian Feldman d1cd079e12 Document dependence of mktemp(3) on the non-reentrant arc4random(3). 2004-02-20 04:08:28 +00:00
David Schultz 01623eaad2 Merge vfscanf.c,v 1.35. 2004-01-31 23:18:53 +00:00
David Schultz ff81345642 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
David Schultz 7b7e350998 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
David Schultz e18c6616e2 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
David Schultz 8f59277300 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
David Schultz 06c89bd55b Prototype __hdtoa() and __hldtoa(). 2004-01-18 08:28:47 +00:00
David Schultz 904322a502 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
Jacques Vidrine 27a97dffc1 Make intentions explicit with additional parenthesis. 2004-01-06 18:32:24 +00:00
Jacques Vidrine 84d9142f58 Remove unused variables and function declarations. Add missing headers. 2004-01-06 18:26:15 +00:00
Tim J. Robbins 5745b7c5af Fix prototype for getchar_unlocked(). 2003-12-07 05:12:51 +00:00
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