Commit Graph

595 Commits

Author SHA1 Message Date
Roman Divacky
f27b1c064c Introduce a local variable and use it instead of passed in parameter
to get rid of restrict qualifier discarding. This lets libc compile
cleanly in gnu99 mode.

Suggested by:	kib, christoph.mallon at gmx.de
Approved by:	kib (mentor)
2009-01-15 18:53:52 +00:00
David Schultz
0a4926406a Reduce code duplication by moving functions that are identical in both
vfprintf.c and vfwprintf.c (except for char/wchar_t differences) to a
common header file.
2009-01-15 04:49:43 +00:00
David Schultz
814d1bc906 Convert the insidious macros that handle printf()'s buffering into
slightly less evil inline functions, and move the buffering state into
a struct. This will make it possible for helper routines to produce
output for printf() directly, making it possible to untangle the code
somewhat.

In wprintf(), use the same buffering mechanism to reduce diffs to
printf(). This has the side-effect of causing wprintf() to catch write
errors that it previously ignored.
2009-01-15 04:29:02 +00:00
David Schultz
0cab1fd236 Set the error indicator on an attempt to write to a read-only stream.
PR:		127335
MFC after:	2 weeks
2009-01-08 06:38:06 +00:00
David Schultz
e18701f4ac Consolidate some variable initializations. No substantive change. 2008-12-11 02:39:27 +00:00
David Schultz
33bff5d3e4 Move the xprintf hook to where it belongs; it shouldn't be in the
middle of vfprintf's variable declarations.
2008-12-10 02:32:06 +00:00
Ruslan Ermilov
e95f37bb69 Fix fread() to return a correct value on platforms where sizeof(int) !=
sizeof(size_t), i.e. on all 64-bit platforms.

Reported by:	Andrey V. Elsukov
MFC after:	3 days
2008-12-01 14:33:34 +00:00
Colin Percival
22d725b5d7 Initialize "nconv" to a reasonable value in all code paths. Prior to
this commit, sprintf("%s", "") could fail depending on what happened
to be on the stack.

Found by:	LLVM/Clang Static Checker
2008-08-04 06:55:42 +00:00
John Baldwin
e68d07ff16 Fix a few bugs with the _gettemp() routine which implements mkstemp(),
mkstemps(), and mkdtemp().
- Add proper range checking for the 'slen' parameter passed to mkstemps().
- Try all possible permutations of a template if a collision is encountered.
  Previously, once a single template character reached 'z', it would not wrap
  around to '0' and keep going until it encountered the original starting
  letter.  In the edge case that the randomly generated starting name used
  all 'z' characters, only that single name would be tried before giving up.

PR:		standards/66531
Submitted by:	Jim Luther
Obtained from:	Apple
MFC after:	1 week
2008-07-28 21:18:59 +00:00
Andrey A. Chernov
bc8541b1d1 Use arc4random_uniform(3) since modulo size is not power of 2 2008-07-22 15:08:50 +00:00
David Schultz
c4014b5086 Fix a bogon in the previous commit and add some missing error checks. 2008-06-29 23:46:06 +00:00
David Schultz
e62e5ff93f Correctly handle malloc() failure. While here, reduce the code size a
bit by removing some calls to the inline function addtype().
2008-06-29 22:54:26 +00:00
David Schultz
07bed96bd3 Factor out the code that builds the argument table. We don't need separate
normal and wide character versions of it.

No functional change.
2008-06-29 22:04:25 +00:00
David Schultz
2591efccfa Reduce the level of duplication between vfprintf() and vfwprintf()
by moving the positional argument handling code to a new file,
printf-pos.c, and moving common definitions to printflocal.h.
No functional change intended.
2008-06-29 21:52:40 +00:00
David Schultz
e5abb5e698 Begin de-spaghettifying the code that handles positional arguments.
In particular, encapsulate the state of the type table in a struct,
and add inline functions to initialize, free, and manipulate that
state. This replaces some ugly macros that made proper error handling
impossible.

While here, remove an unneeded test for NULL and a variable that is
initialized (many times!) but never used. The compiler didn't catch
these because of rampant use of the same variable to mean different
things in different places.

This commit should not cause any changes in functionality.
2008-06-29 21:01:27 +00:00
Antoine Brodin
27522528ea Remove useless call to getdtablesize(2) in fdopen(3) and its useless
variable nofile.

PR:		123109
Submitted by:	Christoph Mallon
Approved by:	rwatson (mentor)
MFC after:	1 month
2008-05-10 18:39:20 +00:00
John Baldwin
143b946188 Retire the __fgetcookie(), __fgetpendout(), and __fsetfileno() accessors
as we aren't hiding FILE's internals anymore.
2008-05-05 16:14:02 +00:00
John Baldwin
19e03ca803 Expose FILE's internals to the world again in all their glory. Restore
all the previous inline optimizations as well.  FILE is back to using
__mbstate_t, struct pthread *, and struct pthread_mutex *.
2008-05-05 16:03:52 +00:00
Marcel Moolenaar
201e72e716 Add __fgetcookie(), __fgetpendout() and __fsetfileno() to the private
name space.
2008-05-04 04:11:01 +00:00
Marcel Moolenaar
0aca787a7b Unbreak build: gnu sort has been configured to grope inside struct
__sFILE. It's opaque now, so add a function that returns the pending
output bytes.

Pointy hat: jhb
2008-05-03 23:36:00 +00:00
Marcel Moolenaar
430f2c8721 Unbreak build: libftpio gropes inside struct __sFILE. Implement
accessor functions for its benefit now thaat FILE is opaque.
I'm sure there's a better way. I leave that for people to work
on in a src tree that isn't broken.

Pointy hat: jhb
2008-05-03 20:09:44 +00:00
John Baldwin
c17bf9a9a5 Next round of stdio changes: Remove all inlining of stdio operations and
move the definition of the type backing FILE (struct __sFILE) into an
internal header.
- Remove macros to inline certain operations from stdio.h.  Applications
  will now always call the functions instead.
- Move the various foo_unlocked() functions from unlocked.c into foo.c.
  This lets some of the inlining macros (e.g. __sfeof()) move into
  foo.c.
- Update a few comments.
- struct __sFILE can now go back to using mbstate_t, pthread_t, and
  pthread_mutex_t instead of knowing about their private, backing types.

MFC after:	1 month
Reviewed by:	kan
2008-05-02 15:25:07 +00:00
John Baldwin
bc669a8c33 Fix a leak in the recent fixes for file descriptors > SHRT_MAX. In the
case of a file descriptor we can't handle, clear the FILE structure's flags
so it can be reused.

MFC after:	1 week
Reported by:	otto @ OpenBSD
2008-04-22 17:03:32 +00:00
John Baldwin
1e98f88776 Next stage of stdio cleanup: Retire __sFILEX and merge the fields back into
__sFILE.  This was supposed to be done in 6.0.  Some notes:
- Where possible I restored the various lines to their pre-__sFILEX state.
- Retire INITEXTRA() and just initialize the wchar bits (orientation and
  mbstate) explicitly instead.  The various places that used INITEXTRA
  didn't need the locking fields or _up initialized.  (Some places needed
  _up to exist and not be off the end of a NULL or garbage pointer, but
  they didn't require it to be initialized to a specific value.)
- For now, stdio.h "knows" that pthread_t is a 'struct pthread *' to
  avoid namespace pollution of including all the pthread types in stdio.h.
  Once we remove all the inlines and make __sFILE private it can go back
  to using pthread_t, etc.
- This does not remove any of the inlines currently and does not change
  any of the public ABI of 'FILE'.

MFC after:	1 month
Reviewed by:	peter
2008-04-17 22:17:54 +00:00
David Schultz
e058c00c40 Updates for changes in the way printf() handles hex floating point
numbers.
2008-04-12 03:11:56 +00:00
John Baldwin
fc9ab4f6da Add <limits.h> for SHRT_MAX.
Pointy hat to:	jhb
2008-02-27 21:25:19 +00:00
John Baldwin
c55d7e868a File descriptors are an int, but our stdio FILE object uses a short to hold
them.  Thus, any fd whose value is greater than SHRT_MAX is handled
incorrectly (the short value is sign-extended when converted to an int).
An unpleasant side effect is that if fopen() opens a file and gets a
backing fd that is greater than SHRT_MAX, fclose() will fail and the file
descriptor will be leaked.  Better handle this by fixing fopen(), fdopen(),
and freopen() to fail attempts to use a fd greater than SHRT_MAX with
EMFILE.

At some point in the future we should look at expanding the file descriptor
in FILE to an int, but that is a bit complicated due to ABI issues.

MFC after:	1 week
Discussed on:	arch
Reviewed by:	wollman
2008-02-27 19:02:02 +00:00
David Schultz
7ff4930d73 Move all the xprintf-related symbols to FBSDprivate_1.0.
Discussed with:	deischen, kan, phk
2007-12-18 23:49:05 +00:00
David Schultz
8da510f8f5 Catch up with vfprintf.c,v 1.77. 2007-12-18 01:20:33 +00:00
David Schultz
1b12fbb195 Remove some test instrumentation. (The Symbol.map changes broke it anyway.) 2007-12-09 21:00:12 +00:00
Andrey A. Chernov
b490b13584 Add rewind() to the list of functions which may fail and set errno 2007-06-18 02:13:04 +00:00
Andrey A. Chernov
ef0fddb70d Add mbstate clear missed in one of the cases.
Move overflow check for fseek as early as needed.
2007-06-18 02:09:08 +00:00
David Schultz
970a466c40 We should never zero-pad INF or NaN (yielding silly strings like "00inf")
even if the programmer asks for zero padding.
2007-05-08 03:08:28 +00:00
Daniel Eischen
5f864214bb Use C comments since we now preprocess these files with CPP. 2007-04-29 14:05:22 +00:00
Poul-Henning Kamp
9436c1bf4b Grammer correction from: emaste 2007-04-19 14:01:04 +00:00
Poul-Henning Kamp
a0c079b341 Loosen return value spec for fputs to be standards compliant so people
don't program against our more restrictive behaviour.
2007-04-19 09:38:31 +00:00
Maxim Konovalov
a0490929c3 o Add ENVIRONMENT section and mention there that TMPDIR is ignored
when issetugid(3) is true.

PR:		docs/108346
Obtained from:	OpenBSD
MFC after:	1 week
2007-03-16 21:46:24 +00:00
Warner Losh
7dcf45c07b Remove 3rd clause, renumber, ok per email 2007-01-12 07:31:30 +00:00
Warner Losh
c879ae3536 Per Regents of the University of Calfornia letter, remove advertising
clause.

# If I've done so improperly on a file, please let me know.
2007-01-09 00:28:16 +00:00
David Schultz
ac9913a749 Fix rounding of 0xf for hex fp formats.
PR:	90333
2007-01-03 04:57:58 +00:00
Konstantin Belousov
525cd732f9 Revert the rev. 1.4, it causes breakage on most arches except i386.
Remove the const qualifier from ap argument for __v2printf, that induced
that breakage, and seems to be the real reason for bad code. ap is modified
inside the __v2printf body by va_arg macro.

Pointy hat to:	kib
Approved by:	pjd (mentor)
2006-10-23 07:25:25 +00:00
Konstantin Belousov
129ccff2fb Workaround for (what seems to be) compiler error for gcc 3.4.6. On
i386 with default optimization level (-O2), va_list pointer ap in the
__v2printf function is advanced before the use. That cause argument
shift and garbage instead last argument in printf-family when xprintf is
activated.

The nsswitch is easy victim of the bug.

Reviewed by:	kan
Approved by:	kan (mentor)
MFC after:	1 week
2006-10-21 11:49:07 +00:00
Andrey A. Chernov
b0bf75c83c file == NULL:
Issue __sflush() before possible setting O_APPEND mode or ftruncate(),
write to wrong place may occurse oserwise.
Use simplified _sseek() to the start, if no O_APPEND is set, instead
of _fseeko() (_sseek() to the end, if O_APPEND, occurse later, as for
file != NULL).
Don't check seek error return, as original fopen() and freopen() never
does.

file != NULL:
Add missing _sseek() to the end.
2006-10-16 14:31:56 +00:00
Andrey A. Chernov
5a8d08f52b Honor errno obtained from __sflags
Move errno restoring after FUNLOCKFILE in one case
2006-10-16 09:57:15 +00:00
Andrey A. Chernov
6f8d08b39a Back out ftruncate error handling. There can some file tipes
f.e. sockets when ftruncate normally fail.
2006-10-16 09:39:15 +00:00
Andrey A. Chernov
b48be86ce1 Do real seek
Catch ftruncate errors

PR:             104295
Submitted by:   ru (seek)
2006-10-15 16:24:31 +00:00
Alexander Kabaev
500b77c7ed Use correct type in va_arg argument. 2006-09-21 14:40:20 +00:00
Ruslan Ermilov
a73a3ab56b Markup fixes. 2006-09-17 21:27:35 +00:00
Ruslan Ermilov
2b46c64c9c Remove alpha left-overs. 2006-08-22 08:03:01 +00:00
Daniel Eischen
babd660805 Oops, correct the weak reference (s/fclose/fcloseall).
Spotted by:	Antoine Brodin (antoine _dot_ brodin _at_ laposte _dot_ net)
2006-04-22 16:47:59 +00:00
Daniel Eischen
ca7f278f1d Now that libc has fcloseall(), remove _cleanup() from the list
of FreeBSD private symbols.
2006-04-22 15:11:33 +00:00
Daniel Eischen
b62c955c52 Add fcloseall() to libc. This removes the need to export _cleanup().
Linux also provides an fcloseall() implementation.

Discussed on:	arch
2006-04-22 15:09:15 +00:00
Poul-Henning Kamp
75239a017f Add missing #if's for NO_FLOATING_POINT 2006-04-01 19:06:54 +00:00
Daniel Eischen
4c6aab055d Add __collate_load_error and __collate_range_cmp to the list of
FBSDprivate locale symbols.  These functions are needed by
libcompat.

Add _cleanup to the list of stdio FBSDprivate symbols.  Some
third party applications use this.  This will be removed and
replaced by fcloseall() once libc version is bumped.

Add _res to the list of resolv symbols.

Found by:	portbuilder runs (thanks Kris!)
2006-03-30 04:37:08 +00:00
Daniel Eischen
6fad3aaf15 Add each directory's symbol map file to SYM_MAPS. 2006-03-13 01:15:01 +00:00
Daniel Eischen
cce72e8860 Add symbol maps and initial symbol version definitions to libc.
Reviewed by:	davidxu
2006-03-13 00:53:21 +00:00
Poul-Henning Kamp
981332f102 Fix the %Q printf extension to behave as expected 2006-03-02 08:53:45 +00:00
Poul-Henning Kamp
8dcefe6112 Remove spurious "union arg" from printf.h
Make sure to always print something in the alternate time format.
2006-02-04 14:35:01 +00:00
Poul-Henning Kamp
f0107b2c5d Add missing 's' suffix on alternate rendition of time. 2006-01-31 08:09:37 +00:00
Poul-Henning Kamp
6dbacee284 Make the %V{is} extension handle a NULL pointer like %s does: output "(null)"
Add %M{essage} extension which prints an errno value as the
corresponding string if possible or numerically otherwise.

It is not currently possible to do the syslog(3) like %m extension
because errno would need to get capatured on entry to the first
function in the printf family, so %M requires you to supply errno
as an argument.

Add %Q{uote} extension which will print a string in double quotes with
appropriate back-slash escapes (only) if necessary.
2006-01-25 12:45:24 +00:00
Olivier Houchard
80c276c1f5 Explicitely use a "signed char" instead of a "char", for those archs where
char defaults to unsigned.
2005-12-22 14:23:54 +00:00
Poul-Henning Kamp
75067f4f70 Add an extensible version of our *printf(3) implementation to libc
on probationary terms:  it may go away again if it transpires it is
a bad idea.

This extensible printf version will only be used if either
    environment variable USE_XPRINTF is defined
or
    one of the extension functions are called.
or
    the global variable __use_xprintf is set greater than zero.

In all other cases our traditional printf implementation will
be used.

The extensible version is slower than the default printf, mostly
because less opportunity for combining I/O operation exists when
faced with extensions.  The default printf on the other hand
is a bad case of spaghetti code.

The extension API has a GLIBC compatible part and a FreeBSD version
of same.  The FreeBSD version exists because the GLIBC version may
run afoul of our FILE * locking in multithreaded programs and it
even further eliminate the opportunities for combining I/O operations.

Include three demo extensions which can be enabled if desired: time
(%T), hexdump (%H) and strvis (%V).

%T can format time_t (%T), struct timeval (%lT) and struct timespec (%llT)
   in one of two human readable duration formats:
	"%.3llT" -> "20349.245"
	"%#.3llT" -> "5h39m9.245"

%H will hexdump a sequence of bytes and takes a pointer and a length
   argument.  The width specifies number of bytes per line.
	"%4H" -> "65 72 20 65"
	"%+4H" -> "0000 65 72 20 65"
	"%#4H" -> "65 72 20 65  |er e|"
	"%+#4H" -> "0000 65 72 20 65  |er e|"

%V will dump a string in strvis format.
	"%V" -> "Hello\tWor\377ld"	(C-style)
	"%0V" -> "Hello\011Wor\377ld"	(octal)
	"%+V" -> "Hello%09Wor%FFld"	(http-style)

Tests, comments, bugreports etc are most welcome.
2005-12-16 18:56:39 +00:00
David Xu
3b52e4d1b7 With current pthread implementations, a mutex initialization will
allocate a memory block. sscanf calls __svfscanf which in turn calls
fread, fread triggers mutex initialization but the mutex is not
destroyed in sscanf, this leads to memory leak. To avoid the memory
leak and performance issue, we create a none MT-safe version of fread:
__fread, and instead let __svfscanf call __fread.

PR: threads/90392
Patch submitted by: dhartmei
MFC after: 7 days
2005-12-16 02:50:53 +00:00
Poul-Henning Kamp
b384108ed6 /* You're not supposed to hit this problem */
For some denormalized long double values, a bug in __hldtoa() (called
from *printf()'s %A format) results in a base 16 digit being rounded
up from 0xf to 0x10.

When this digit is subsequently converted to string format, an index
of 10 reaches past the end of the uppper-case hex/char array, picking
up whatever the code segment happen to contain at that address.

This mostly seem to be some character from the upper half of the
byte range.

When using the %a format instead of %A, the first character past
the end of the lowercase hex/char table happens to be index 0 in
the uppercase hex/char table hextable and therefore the string
representation features a '0', which is supposedly correct.

This leads me to belive that the proper fix _may_ be as simple as
masking all but the lower four bits off after incrementing a hex-digit
in libc/gdtoa/_hdtoa.c:roundup().  I worry however that the upper
bit in 0x10 indicates a carry not carried.

Until das@ or bde@ finds time to visit this issue, extend the
hexdigit arrays with a 17th index containing '?' so that we get a
invalid but consistent and printable output in both %a and %A formats
whenever this bug strikes.

This unmasks the bug in the %a format therefore solving the real
issue may both become easier and more urgent.

Possibly related to:	PR 85080
With help by:		bde@
2005-12-13 13:23:27 +00:00
Ruslan Ermilov
8b79908889 Fix prototype. 2005-11-23 20:26:58 +00:00
Christian Brueffer
9dbf9a4dca Use the correct function name as .Nm argument.
PR:		86169
Submitted by:	Toby Peterson <toby@apple.com>
MFC after:	3 days
2005-09-18 15:40:03 +00:00
Stefan Farfeleder
2ba64027bc Move the declaration of __cleanup to libc_private.h as it is used in both
stdio/ and stdlib/.  Don't define __cleanup twice.
2005-09-12 13:46:32 +00:00
Tim J. Robbins
6595b51a7f Remove references to nonexistent "FreeBSD Security Architecture" document. 2005-09-05 09:49:33 +00:00
Stefan Farfeleder
d8f77b4529 Include <sys/types.h> and <limits.h> ourselves, don't assume they are included
through <pthread.h>.

gen/sem.c:		Prerequisite for <_semaphore.h>
net/getprotoent.c:	USHRT_MAX
net/getservent.c:	USHRT_MAX
stdio/ungetwc.c:	MB_LEN_MAX
stdio/vfwscanf.c:	MB_LEN_MAX
2005-08-20 07:59:13 +00:00
Tim J. Robbins
d48c77b534 Speed up __wcsconv() (and hence the printf() %ls format):
- use wcsrtombs() instead of a wcrtomb() loop where possible.
- avoid wcrtomb() loop when output precision is small.
2005-07-24 12:12:44 +00:00
Stefan Farfeleder
c29f424e01 The header glue.h should provide just a declaration for the variable
__sglue, not a definition.

PR:		80378
Submitted by:	John Engelhart <johne@zang.com>
MFC after:	1 week
2005-05-13 21:12:34 +00:00
Dag-Erling Smørgrav
bc8695dc6c The correct description for mode "w" is
(((truncate to zero length) or (create)) (text file)) (for writing)
and not
  ((truncate file to zero length) or (create text file)) (for writing)

MFC after:	1 week
2005-05-04 08:12:44 +00:00
David Schultz
1be5319a76 Be bug-for-bug compatible with the C standard with respect to
printf("%#.0o", 0).  Cite an amusing passage from a defect report.
2005-04-16 22:36:51 +00:00
Stefan Farfeleder
e413b7d2f8 Remove unused variable. 2005-04-08 20:58:47 +00:00
Max Khon
f1defde9d5 Fix EOVERFLOW detection in vswprintf(3)
Reviewed by:	tjr
MFC after:	2 weeks
2005-02-21 19:41:44 +00:00
Ruslan Ermilov
24a0682c64 Sort sections. 2005-01-20 09:17:07 +00:00
Ruslan Ermilov
2d82ac3110 Scheduled mdoc(7) sweep. 2005-01-11 20:50:51 +00:00
Stefan Farfeleder
df103a1515 Document that the length modifier l is ignored for floating point
conversion specifiers (a, A, e, E, f, F, g and G).
2004-10-16 16:00:01 +00:00
Stefan Farfeleder
4c86f66f52 Don't add integers to void pointers. 2004-10-03 15:48:32 +00:00
Dag-Erling Smørgrav
096ad1042a Don't forget to va_end() the va_list we get from va_copy().
Submitted by:	Sean McNeil <sean@mcneil.com>
MFC after:	3 days
2004-08-26 06:25:28 +00:00
Alfred Perlstein
3b28ee84a6 note that it is the caller's responsibility to free any buffer passed
to setvbuf(3) and friends.
2004-08-24 21:48:21 +00:00
Tim J. Robbins
91f18ef928 Fix an off-by-one bug that caused the first character of the buffer to
be uninitialized.
2004-08-06 17:00:09 +00:00
Tim J. Robbins
7d7287dc7d Read directly from the stdio buffer using the new __mbsnrtowcs() interface
instead of making repeated calls to __fgetwc().
2004-07-21 12:12:48 +00:00
Tim J. Robbins
1949a3470f Implement the GNU extensions of mbsnrtowcs() and wcsnrtombs(). These are
convenient when the source string isn't null-terminated.

Implement the other conversion functions (mbstowcs(), mbsrtowcs(), wcstombs(),
wcsrtombs()) in terms of these new functions.
2004-07-21 10:54:57 +00:00
Tim J. Robbins
2f2c1839f8 Use __wcsrtombs() and __sfvwrite() to convert and write the wide character
string instead of multiple calls to __fputwc().
2004-07-21 08:35:18 +00:00
Tim J. Robbins
f9ceea9bf1 Call __mbrtowc() and __wcrtomb() directly instead of taking detours
through mbrtowc() and wcrtomb().
2004-07-20 08:27:27 +00:00
Tim J. Robbins
2508f480c2 Add a cross reference to fgetwln(3). 2004-07-16 06:07:12 +00:00
Tim J. Robbins
9531ef0fc1 Add fgetwln(), a wide character version of fgetln(). 2004-07-16 06:06:09 +00:00
Tim J. Robbins
66d56cb7b8 Rename slbexpand() to __slbexpand() and make it available outside
of fgetln.c (non-static).
2004-07-16 05:52:51 +00:00
Tim J. Robbins
fcc5191787 Slightly reorganize and simplify. 2004-07-09 15:12:10 +00:00
Colin Percival
0a31135d11 Add commentary explaining why we return EBADF upon attempts to fflush() a
read-only file.

Discussed on:	-current
2004-07-04 20:17:00 +00:00
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