Commit Graph

611 Commits

Author SHA1 Message Date
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
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
Tim J. Robbins
0b4b7b65ed #include <stdlib.h> for free()'s prototype. 2003-01-07 06:17:13 +00:00
Tim J. Robbins
e2b090f34f Note that the printf(3) and scanf(3) family of functions don't deal with
multibyte characters in the format string correctly.
2003-01-06 06:19:19 +00:00
Tim J. Robbins
43a240930c #include "local.h" to make __svfscanf()'s prototype visible. 2003-01-03 23:27:27 +00:00
Tim J. Robbins
276ba5b4fa Reset the stream orientation to 0 (unoriented) in freopen(), as required
by the C standard.
2003-01-03 12:27:19 +00:00
Ruslan Ermilov
facc67676f mdoc(7) police: Deal with self-xrefs. 2002-12-24 13:41:48 +00:00
Tim J. Robbins
4aca04ee5c Document the fact that the printf() family of functions return negative
values (EOF in our case) on error, and some of the possible errno values
in an Errors section.

PR:		39257
2002-12-20 08:28:10 +00:00
Tim J. Robbins
5a7405be50 C99 standardised the vscanf() family of functions, update Standards
section to reflect this.
2002-12-20 07:46:01 +00:00
Tim J. Robbins
37d2356335 Write the message to stderr, not file descriptor 2, so that perror()
writes to the correct stream if stderr has been redirected with freopen().
2002-12-19 09:53:26 +00:00
Tim J. Robbins
a207a8e3f1 Use strerror_r() to format the error message so that strerror()'s static
buffer does not get clobbered.

ISO/IEC 9899:1999 7.21.6.2 3:
"The implementation shall behave as if no library function calls the
strerror function."
2002-12-19 09:50:10 +00:00
Ruslan Ermilov
2efeeba554 mdoc(7) police: "The .Fa argument.". 2002-12-19 09:40:28 +00:00
Ruslan Ermilov
5c564bae0a mdoc(7) police: Fixed abuses of the .Ar and .Em macros. 2002-12-18 13:33:04 +00:00
Ruslan Ermilov
1fae73b137 mdoc(7) police: "The .Fn function". 2002-12-18 12:45:11 +00:00
Ruslan Ermilov
a9a15f3ea4 mdoc(7) police: tiny nits.
Approved by:	re
2002-12-09 14:11:37 +00:00
Ruslan Ermilov
ae82896268 Consistently mark std(in|out|err) with .Dv, because that's how they
are marked up in stdio(3), and because they are defined expressions
of type "FILE *".

Approved by:	re
2002-12-04 18:57:46 +00:00
Ruslan Ermilov
898f520da8 mdoc(7) police: markup overhaul.
Approved by:	re
2002-12-04 17:49:15 +00:00
Ruslan Ermilov
1798791d24 mdoc(7) police: formatting nits.
Approved by:	re
2002-11-29 15:57:50 +00:00
Ruslan Ermilov
c51d717f0c libc_r wasn't so tied to libc for 22 months. 2002-11-18 09:50:57 +00:00
Warner Losh
cf04ed1bdf bde points out that the LIBC_MAJOR macro doesn't exist and requests
that we not use it here.  In its place I've put a comment about the
current state of play.

Submitted by: bde
2002-11-14 14:06:14 +00:00
Warner Losh
c906b66373 Restore Peter's version of static __sF. There's too much pain for it
to be static for 5.0.  I may remove this for 5.1 or 5.2.  No more
binaries or libarires will be generated with __sF starting as of
yesterday.  Originally the plan had been to eliminate this for 5.0,
but we didn't get the __std{in,out,err}p changes merged into -stable
until yesterday (rather than in September 2001 like it should have
been).  Given that didn't happen on time, we can't do the other part
of the scheme now.

# Please do not change this without talking to me first.
2002-11-10 08:44:38 +00:00
Alfred Perlstein
ac1cc6ee11 Backout "compatibility hack" for __sF.
Requested by: Steve Kargl <sgk@troutmask.apl.washington.edu> (submitter)
2002-11-04 03:23:56 +00:00
Alfred Perlstein
0fc25b925d Provide a hook to make __sF visible outside of libc for commercial apps
if WANT_COMPAT4_STDIO is defined when compiling libc.

Submitted by: Steve Kargl <sgk@troutmask.apl.washington.edu>
2002-11-02 19:47:53 +00:00
Tim J. Robbins
14ffdae94d No need to include floatio.h here: vfscanf() no longer uses anything
it defines.
2002-11-01 05:13:01 +00:00
Alfred Perlstein
c313cb2abf Make __sF static. This can not be allowed to exist in 5.x. 2002-10-31 01:54:27 +00:00
Tim J. Robbins
ae95ea1a26 Cross-reference putc(3). 2002-10-28 10:35:18 +00:00
Tim J. Robbins
79db40061f The ORIENTLOCK macro is no longer needed since all functions use
FLOCKFILE/FUNLOCKFILE explicitly.
2002-10-25 07:01:56 +00:00
Tim J. Robbins
9619813de9 Cross-reference fmtcheck(3). 2002-10-20 03:56:37 +00:00
Peter Wemm
d7dd6ae7ec Give in on the __sF stuff. I have a better fix in mind that is future
proof, but this should buy me some time for now.
2002-10-19 22:28:07 +00:00
Tim J. Robbins
118bb75e02 Indent code example with one tab, not two, for consistency with the rest. 2002-10-19 13:48:45 +00:00
Tim J. Robbins
0145ba86d1 Fix off-by-one error when pushing back a multibyte sequence in
wide character class (%l[) and wide string (%ls) conversions.
2002-10-17 13:04:00 +00:00
Tim J. Robbins
63b01047f4 Make part of the previous change clearer; check flags for SUPPRESS directly
instead of checking whether we're using a temporary buffer.
2002-10-17 12:06:29 +00:00
Tim J. Robbins
bd25c6f476 The field width for single-byte string conversions (%c, %s, %[) is the
maximum number of bytes that may be stored in the array, not the maximum
number of wide characters to read. The wording of the standard unfortunately
does not make this clear.
2002-10-17 12:02:36 +00:00
Tim J. Robbins
35739e072b Count field width correctly for suppressed multibyte fields (%*lc,
%*ls, %*l[).
2002-10-16 14:07:08 +00:00
Tim J. Robbins
6180233fd8 Set the error bit on the stream if an encoding error occurs. Improve
handling of multibyte sequences representing null wide characters.
2002-10-16 12:09:43 +00:00
Tim J. Robbins
927ecbf313 Add support for the XSI %C and %S formats, which are the same as %lc
and %ls.
2002-10-16 03:55:53 +00:00
Tim J. Robbins
af1c9c0e4d Use a weak reference instead of a macro to make vfscanf an alias
for __vfscanf.
2002-10-14 11:18:21 +00:00
Kris Kennaway
61bdf123c3 Ignore TMPDIR if the application is setugid.
MFC after:	2 weeks
2002-10-13 11:22:16 +00:00
Mike Barcroft
54e4e385de Add restrict type-qualifier. 2002-10-12 16:13:41 +00:00
Tim J. Robbins
419c442678 Describe the restrictions on seeking on wide character streams, and also
point out that fseek() clears the ungetwc() buffer.
2002-10-12 09:22:25 +00:00
Peter Wemm
74a4ba21f7 Zap the early-adopter transition aid before we get into serious
5.0-R territory, as threatened.  This only affects antique 5.0
systems that have not had a 'make world' done for well over a year.
2002-10-11 22:38:17 +00:00
Tim J. Robbins
ce04c11001 Cross-reference between byte and wide-character stdio functions. Remove
references to fputwc() and fgetwc() being macros while I'm at it.
2002-10-10 04:12:40 +00:00
Tim J. Robbins
3619568a64 Remove masking macros for getwc(), putwc(), putwchar() and getwchar().
Although there was nothing wrong with getwc() and putwc(), getwchar()
and putwchar() assumed that <stdio.h> had been included before <wchar.h>,
which is not allowed by the standard.
2002-09-28 07:43:44 +00:00
Tim J. Robbins
27a29543f3 Back out previous, free the buffer when __vfprintf() fails and don't bother
trying to shrink the buffer with realloc() before returning it.
2002-09-26 13:11:24 +00:00
Tim J. Robbins
344141d1fd Back out previous and solve the problems a different way: move va_start/
va_end closer to the __vfprintf() call, free the buffer when __vfprintf()
fails and don't bother trying to shrink the buffer with realloc() before
returning it.

Submitted by:	bde
2002-09-26 13:09:48 +00:00
Tim J. Robbins
23b6f7902d Correctly handle the case where __vfwprintf() fails because it runs out
of memory.
2002-09-26 08:26:16 +00:00
Tim J. Robbins
3383deca89 Sync with OpenBSD: avoid memory leak when __vfprintf() fails because it
runs out of memory, always call va_end.
2002-09-26 07:55:18 +00:00
Tim J. Robbins
38b5abad06 Add cross-references between wide character and single-byte character
versions of printf() and scanf().
2002-09-24 09:22:47 +00:00
Tim J. Robbins
89265cb899 Remove an unneeded call to _sfrefill() that was missed in the conversion
from vfscanf() to vfwscanf(). It doesn't hurt to have it there, but it's
redundant since __fgetwc() will refill the buffer if it needs to.
2002-09-24 09:18:32 +00:00
Tim J. Robbins
d07090a880 Use the new va_copy macro to copy variable argument lists instead of
assignment. This is needed on powerpc but is also more correct for the
other ports.

Submitted by:	grehan
Tested on:	alpha, i386, sparc64
2002-09-24 00:47:27 +00:00
Tim J. Robbins
1f4ff8506a Add implementations of wscanf() and related functions: fwscanf(), swscanf(),
vfwscanf(), vswscanf(), vwscanf(). As the name suggests, these are wide-
character versions of the scanf() family of functions.
2002-09-23 12:40:06 +00:00
Tim J. Robbins
4712aa3b59 Implement the %lc, %ls and %[ conversions, which read sequences of wide
characters, non-whitespace wide character strings and wide character
strings in a scanset.
2002-09-23 11:35:50 +00:00
Tim J. Robbins
adc106840c The character argument for __ungetwc() should be wint_t instead of wchar_t. 2002-09-23 11:31:18 +00:00
Tim J. Robbins
5f147b57ac Add an unlocked version of ungetwc(), __ungetwc(), that __vfwscanf()
will need to use.
2002-09-22 05:59:00 +00:00
Tim J. Robbins
0e2e10070d Delete stray reference to vsnprintf(). 2002-09-21 14:25:58 +00:00
Tim J. Robbins
c5604d0a50 Add implementations of the wprintf() family of functions, which perform
formatted wide-character output.
2002-09-21 13:00:30 +00:00
Tim J. Robbins
7591ae56ae Lock the file once per call and use the unlocked fgetwc()/fputwc() variants. 2002-09-20 13:25:40 +00:00
Tim J. Robbins
9260341650 Lock and unlock the file once per call and use the unlocked version of
ungetc() instead of having ungetc() recurse on the lock.
2002-09-20 13:23:26 +00:00
Tim J. Robbins
8f030a44b8 Introduce unlocked versions of fputwc() and fgetwc() called __fputwc()
and __fgetwc() which can be used when we know the file is locked.
2002-09-20 13:20:41 +00:00
Tim J. Robbins
b9aac30810 Implement the %ls and %lc conversions for printing wide character strings
and wide characters. These were already documented in the manual page,
with an entry mentioning that they were not implemented yet. The XSI
%S and %C synoyms have not been added.
2002-09-19 12:50:28 +00:00
Tim J. Robbins
0b7bc80226 Optimise the common case where no special encoding is in use (LC_CTYPE is "C"
or "POSIX", other European locales). Use __sgetc() and __sputc() where
possible to avoid a wasteful lock and unlock for each byte and to avoid
function call overhead.
2002-09-18 12:17:28 +00:00
Tim J. Robbins
bddc6280f2 Logic error in previous: don't exit the loop when an incomplete multibyte
sequence is detected.
2002-09-18 10:21:41 +00:00
Tim J. Robbins
24990dfad0 Reimplement the functionality of fgetrune(), fputrune(), and fungetrune()
here in terms of mbrtowc(), wcrtomb(), and the single-byte I/O functions.
The rune I/O functions are about to become deprecated in favour of the
ones provided by ISO C90 Amd. 1 and C99.
2002-09-18 05:58:11 +00:00
Maxim Konovalov
48eaac247f Fix vsnprintf(3) memory leak for size == 0.
PR:             bin/36175
Obtained from:  OpenBSD
Reviewed by:    silence on -audit
MFC after:      5 days
2002-09-17 11:28:24 +00:00
Tim J. Robbins
4d783ded07 Convert eight space indents to tabs in the "*" format handling code. 2002-09-16 12:07:13 +00:00
Tim J. Robbins
58d38e2520 Style: One space between "restrict" qualifier and "*". 2002-09-06 11:24:06 +00:00
Jens Schweikhardt
3dd657600a Print a '-' sign for negative zero. Tested with
#include <stdio.h>
	int main(void)
	{
		printf("%+f\n", -0.0);
		printf("%+f\n", +0.0);
		printf("%+f\n",  0.0);
		return 0;
	}

to output
-0.000000
+0.000000
+0.000000

PR:		bin/41823
Submitted by:	GOTO Kentaro <gotoken@notwork.org>
Liked by:	bde
MFC after:	3 weeks
2002-08-27 20:11:08 +00:00
Mike Barcroft
abbd890233 o Merge <machine/ansi.h> and <machine/types.h> into a new header
called <machine/_types.h>.
o <machine/ansi.h> will continue to live so it can define MD clock
  macros, which are only MD because of gratuitous differences between
  architectures.
o Change all headers to make use of this.  This mainly involves
  changing:
    #ifdef _BSD_FOO_T_
    typedef	_BSD_FOO_T_	foo_t;
    #undef _BSD_FOO_T_
    #endif
  to:
    #ifndef _FOO_T_DECLARED
    typedef	__foo_t	foo_t;
    #define	_FOO_T_DECLARED
    #endif

Concept by:	bde
Reviewed by:	jake, obrien
2002-08-21 16:20:02 +00:00
Juli Mallett
6879bea818 Leave room for a trailing NUL not a NULL, that's not an ASCII character. 2002-08-19 03:52:36 +00:00
Robert Drehmel
f8418db73e - For compliance with IEEE Std 1003.1-2001, add the 'restrict'
qualifier to function prototypes and definitions where
   appropriate using the '__restrict' macro.
 - Update the manual page.
2002-08-15 10:28:52 +00:00
Robert Drehmel
71a00a449f - Introduce the 'restrict' qualifier to function prototypes and
definitions to comply with IEEE Std 1003.1-2001.
 - Update the manual pages.
2002-08-15 09:47:10 +00:00
Robert Drehmel
3248d0a517 - Add the 'restrict' qualifier to the function definitions and
public prototypes of setbuf(3) and setvbuf(3) using the
   '__restrict' macro from <sys/cdefs.h> to be compliant with
   IEEE Std 1003.1-2001.
 - Replace the K&R with ANSI-C function definitions.
 - Bring the manual page up-to-date.
2002-08-14 23:45:42 +00:00
Poul-Henning Kamp
209c34ba95 Unbreak one of the most confusing breaks of the tree I've seen.
The last commit cannot possibly have been tested.
2002-08-13 18:55:51 +00:00
Tim J. Robbins
439cb19e04 Tidy up SRCS and MAN assignments. 2002-08-13 11:56:02 +00:00
Tim J. Robbins
73ab4b2b33 Remove the Bugs section, which is not relevant to FreeBSD: there is no
one-character ungetwc(3) buffer limit.
2002-08-13 10:50:22 +00:00
Tim J. Robbins
46624699bd FreeBSD-ify: use In macro for header files in Synopsis, St C-99 instead of
St C99 in Standards section.
2002-08-13 10:47:17 +00:00
Tim J. Robbins
e74101e4ef Basic support for wide character I/O: getwc(), fgetwc(), getwchar(),
putwc(), fputwc(), putwchar(), ungetwc(), fwide().
2002-08-13 09:30:41 +00:00
Tim J. Robbins
01533af5a0 Manual pages for fwide(), getwc(), fgetwc(), getwchar(), putwc(), fputwc(),
putwchar(), ungetwc() from NetBSD and Citrus Project, unmodified except
for the addition of $FreeBSD$.

Obtained from:	NetBSD, Citrus Project
2002-08-12 13:23:12 +00:00
Jens Schweikhardt
2b239dd118 Fix typos; each file has at least one s/seperat/separat/
(I skipped those in contrib/, gnu/ and crypto/)
While I was at it, fixed a lot more found by ispell that I
could identify with certainty to be errors. All of these
were in comments or text, not in actual code.

Suggested by:	bde
MFC after:	3 days
2002-08-11 13:05:30 +00:00
Ruslan Ermilov
a8272f7106 mdoc(7) police: punctuation. 2002-08-09 11:24:21 +00:00
Garrett Wollman
c98a4bf3fb Don't claim to fully implement C99 in the STANDARDS section and then disclaim
compliance in the BUGS section immediately below.
2002-07-15 19:46:06 +00:00
Garrett Wollman
647e4efd97 Note that fseeko() and ftello() are standard in 1003.1-2001.
(Prefer the more-encompassing POSIX standard to SUSv2.)
2002-07-15 19:42:25 +00:00
Chris Costello
1b5c321d3f Fix style and wording bugs introduced in my last commit.
Sponsored by:	DARPA, NAI Labs
2002-06-18 08:55:17 +00:00
Chris Costello
5f9c048ce7 o Move more information from BUGS into SECURITY CONSIDERATIONS and
condense the redundant bits.
o Provide an example for using snprintf over sprintf.  This may be
  supplemented with an asprintf() example soon.

Sponsored by:	DARPA, NAI Labs
2002-06-15 06:00:56 +00:00
Chris Costello
7bc7869122 Include information on the dangers of passing a user-supplied string as
a format string.  This will later on be changed to a reference to the
FreeBSD Security Architecture after it has been committed.

PR:		docs/39320
Sposnored by:	DARPA, NAI Labs
2002-06-13 23:35:22 +00:00
Archie Cobbs
6accdce98b Grammar fix: "contents" is plural.
MFC after:	1 day
2002-05-31 05:01:17 +00:00
Ruslan Ermilov
432e57ebfa mdoc(7) police: markup nits. 2002-05-30 09:53:47 +00:00
Ruslan Ermilov
16fb684936 mdoc(7) police: fix markup for types. 2002-05-29 15:42:59 +00:00
Alfred Perlstein
a82bbc730e Assume __STDC__, remove non-__STDC__ code.
Submitted by: keramida
2002-05-28 17:03:12 +00:00
Robert Drehmel
6e818f06aa Correct a check for NUL.
Spotted by: bde
2002-05-27 19:27:43 +00:00
Robert Drehmel
fb08c0489d - Move the loop conditional into the "for" header.
- Remove redundant "? :" construct.
style(9):
 - Place a space after return statements.
 - Compare pointers to NULL.
 - Do not use ! to compare a character to nul.
2002-05-27 11:01:30 +00:00
Robert Drehmel
ccccc4e1c3 Avoid wandering over the beginning of the actual buffer
if the passed template string contains only 'X' characters.

Submitted by:	Mark Andrews <marka@isc.org> (patch modified)
PR:		38402
2002-05-23 14:21:02 +00:00
Tony Finch
cfad593dbd Clarify that the value of getc() etc. is an unsigned char converted
to an int (as per the C standard) i.e. it can be passed straight to
isalpha() etc.

Approved by:	dwmalone (mentor)
MFC after:	3 days
2002-05-15 16:55:58 +00:00
Bill Fenner
946b2d0057 Implement several of the c99 updates to scanf(3):
- New length modifiers: hh, j, ll, t, z.

Still to do:
 - %C, %S, %lc, %ls (wide character support)
 - %a/%A (exact hex representation of floating-point numbers)

Removed old compatability equivalents:
 - %D for %ld, %O for %lo, %X for %lx, %E and %F for %le & %lf (these
   were buggy anyway, since they should have represented %Le & %Lf).
 - %[unknown uppercase char] for %ld, %[unknown lowercase char] for %d
2002-04-20 17:00:56 +00:00
Tom Rhodes
7d358b9a2a scanf.3 has an obsolete ``this release''.
PR:		35610
MFC after:	2 days
2002-04-10 20:52:49 +00:00
David E. O'Brien
1114a754ed Fix the style of the SCM ID's.
I believe have made all of libc .h's as consistent as possible.
2002-03-22 23:42:05 +00:00
David E. O'Brien
333fc21e3c Fix the style of the SCM ID's.
I believe have made all of libc .c's as consistent as possible.
2002-03-22 21:53:29 +00:00
David E. O'Brien
1372519b15 Remove multi-line __P() usage. 2002-03-22 09:22:15 +00:00
David E. O'Brien
c05ac53b8b Remove __P() usage. 2002-03-21 22:49:10 +00:00
David E. O'Brien
8fb3f3f682 Remove 'register' keyword. 2002-03-21 18:49:23 +00:00
Dima Dorfman
38261ac8d6 Don't refer the reader to look for a word that doesn't exist anywhere
else in the page.

PR:		35623
Submitted by:	Gary W. Swearingen <swear@blarg.net>
2002-03-10 09:20:28 +00:00
Ruslan Ermilov
ce9df6eefc mdoc(7) police:
Stop abusing the .%J macro for where the .Pa macro should have been used.
2002-01-09 14:01:22 +00:00
Chris Costello
6ba681a185 All information from the "BUGS" section not belonging in "SECURITY
CONSIDERATIONS" moved to "COMPATIBILITY".

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, NAI Labs
2002-01-06 21:48:37 +00:00
Chris Costello
e125c135a8 Add new "SECURITY CONSIDERATIONS" sections.
Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, NAI Labs
2002-01-06 21:16:41 +00:00
Alexey Zelkin
2e394b2fc1 Fix some style bugs
Prompted by:	mike
2001-12-17 15:11:29 +00:00
Alexey Zelkin
243e90d646 Also fix cases when thousands separator should be put before number. For
example before for grouping sequence "\003\003" number 123456 was formated
as ",123,456", now "123,456".
2001-12-13 21:05:27 +00:00
Alexey Zelkin
98ee763522 Respect locale while handling of \' flag.
In original version grouping was hardcoded. It assumed that thousands
separator should be inserted to separate each 3 numbers. I.e. grouping
string "\003" was assumed for all cases. In correct case (per POSIX)
vfprintf should respect locale defined non-monetary (LC_NUMERIC
category) grouping sequence.

Also simplify thousands_sep handling.
2001-12-13 19:45:41 +00:00
Ruslan Ermilov
2554caf28c mdoc(7) police: Minor formatting nits and optimizations to rev. 1.34. 2001-12-12 14:36:28 +00:00
Alexey Zelkin
7ae5c6791e * localeconv() usage is not FLOATING_POINT specific anymore (due to "'" flag
addition) so move locale.h inclusion out of FLOATING_POINT ifdef's.
* add more comments
2001-12-07 12:38:47 +00:00
Bill Fenner
828829cda5 Remove blank line. 2001-12-07 03:25:26 +00:00
Bill Fenner
7735bb0f64 Implement several of the c99 updates to printf(3):
- New length modifiers: hh, j, t, z.
 - New flag: '.  Note that %'f is not yet implemented.
 - Use "inf"/"nan" for efg formats, "INF"/"NAN" for EFG formats.
 - Implemented %q in terms of %ll; if "quad_t" is not "long long"
   %q will break.

Still to do:
 - %C, %S, %lc, %ls (wide character support)
 - %'f (thousands in integer portion of %f)
 - %a/%A (exact hex representation of floating-point numbers)

Garrett Wollman wrote the first version of the vfprintf.c update;
Mike Barcroft wrote the first version of the printf.3 changes.
2001-11-30 06:12:15 +00:00
Andrey A. Chernov
2209d8a27c Back out national digits support, POSIX explicetely disallows it:
The definition of character class digit requires that only ten characters
-the ones defining digits- can be specified; alternate digits (for
example, Hindi or Kanji) cannot be specified here. However, the encoding
may vary if an implementation supports more than one encoding.

The definition of character class xdigit requires that the characters
included in character class digit are included here also and allows for
different symbols for the hexadecimal digits 10 through 15.
2001-11-29 03:03:55 +00:00
Andrey A. Chernov
87c25490c8 Don't ever assume that isdigit() is always subset of isxdigit() 2001-11-28 06:06:27 +00:00
Andrey A. Chernov
997aec5b67 Allow national (non-ASCII) digits 2001-11-28 04:57:48 +00:00
Ruslan Ermilov
2f52231c66 mdoc(7) police: sort xrefs. 2001-11-20 13:58:21 +00:00
Murray Stokely
ac8b27d2ab Cross-reference the fdopen and fileno manpages.
PR:		docs/31866
Submitted by:	W. Campbell <wcampbel@botbay.net>
2001-11-14 16:24:51 +00:00
Andrey A. Chernov
7686e760b5 In > LONG_MAX test use sseek return value and not _offset which can be not
active.
2001-10-25 22:56:04 +00:00
Andrey A. Chernov
e41febc84b Help to recover from bad seek (i.e. negative or too big) happens beyond
our pre-check control. Do the same way as refill.c does when it set __SERR,
i.e. clear read and ungetc buffers. Clear EOF flag too.
2001-10-24 17:25:49 +00:00
Andrey A. Chernov
3f498bf72b Back out read buffer invalidating via __SMOD.
It was correct, but not needed because internal buffer cleared on each seek
outside of it.
2001-10-23 23:52:11 +00:00
Andrey A. Chernov
0502fac881 Change comment explaining another usage of __SMOD 2001-10-23 23:05:15 +00:00
Andrey A. Chernov
751fc77994 Disallow fseek() optimization in internal read buffer, if pointer is moved by
seek. It means that beginning of read buffer becomes not the same as current
file position.
2001-10-23 22:48:00 +00:00
Bruce Evans
18ca70d12d Fixed style bugs in previous commit. 2001-10-15 04:29:06 +00:00
Doug Rabson
a387081c63 Make this compile on ia64. 2001-10-14 13:45:33 +00:00
Ruslan Ermilov
32eef9aeb1 mdoc(7) police: Use the new .In macro for #include statements. 2001-10-01 16:09:29 +00:00
Andrey A. Chernov
1b89a29689 1) If __SAPP stream is not seekable, remove __SAPP flag on first call instead
of repeating unsuccessful lseek call on each write (original stdio bug).

2) Save errno accross _sseek call in _swrite to not touch it in case write
success (original stdio bug).

3) Add _sseek error checking back, but only for __SOPT mode now.
2001-09-07 17:16:02 +00:00
Andrey A. Chernov
ac206f37a1 For now just back out seek error checking in __SAPP case, it cause problems
with non-seekable streams.  Now here is what here was originally, but it is
ugly, producing unneded seek syscall on each non-seekable stream write.  I'll
think about proper solution later.
2001-09-07 02:13:11 +00:00
Andrey A. Chernov
347a15b2ab When __SOPT is cleared, clear __SOFF too.
NOTE: original stdio bug.
2001-09-03 02:35:10 +00:00
Andrey A. Chernov
5e00917d95 Re-arrange my funopen(3) fix to minimize differences with original stdio code,
no functional changes.

Add fp->_offset optimization in _SAPP+_SOPT case
2001-09-03 02:24:37 +00:00
Andrey A. Chernov
aeb7f4bac4 Internal seeks are overoptimized. They should remember fp->_offset only for
plain regular files, i.e. files with __SOPT flag set. Fix it, so ftell(stdout)
always returns the same as lseek(1, 0, 1) now.

NOTE: this bug was in original stdio code
2001-09-02 21:22:00 +00:00
Andrey A. Chernov
778d840e50 Fix bug in off_t overflow checking: if fp->_offset overflows, just remove
__SOFF flag (i.e. we don't have offset) instead of returning EOVERFLOW.
It allows again continious reading from non-stop stream.
2001-09-02 19:52:09 +00:00
Andrey A. Chernov
bf351925f7 Typo seek(2) -> lseek(2) 2001-09-02 19:24:07 +00:00
Andrey A. Chernov
924888f977 Move all stdio internal flags processing and setting out of __sread(),
__swrite() and __sseek() to higher level. According to funopen(3) they all
are just wrappers to something like standard read(2), write(2) and
lseek(2), i.e. must not touch stdio internals because they are replaceable
with any other functions knows nothing about stdio internals. See example
of funopen(3) usage in sendmail sources f.e.

NOTE: this is original stdio bug, not result of my range checkin added.
2001-09-02 19:10:10 +00:00
Andrey A. Chernov
35e1a550de Save errno before function call and restore it on success (because many
internal functions there may fail and set (i.e. overwrite) errno in normal
(not error) situation). In original variant errno testing after call
(as POSIX suggest) is wrong when errno overwrite happens.
2001-09-01 15:28:24 +00:00
Andrey A. Chernov
d911eb4536 Remove even more unneded checks, original code can't overflows in that place 2001-09-01 15:01:37 +00:00
Andrey A. Chernov
4fd8a4cf24 Remove two checks unneeded now (can't happens) 2001-09-01 14:48:45 +00:00
Andrey A. Chernov
45892fd855 Make fseek(... SEEK_CUR) fails if current file-position is unspecified. 2001-09-01 14:40:01 +00:00
Andrey A. Chernov
3c4d9468b0 Note that prev. commit addition is for ftell/ftello 2001-09-01 14:23:30 +00:00
Andrey A. Chernov
2f5eadff6b Describe ESPIPE as result of unspecified file-position indicator value.
Add more to SEE ALSO section.
2001-09-01 14:11:53 +00:00
Andrey A. Chernov
a914951d68 Describe file-position behaviour from POSIX 2001-09-01 14:01:52 +00:00
Andrey A. Chernov
6ff604a73a Strict in the POSIX sence, if file position is unspecified after ungetc() at
0, return that we can't specify it, i.e. error with ESPIPE.
(hint from: "Peter S. Housel" <housel@acm.org>)

Back out sinit() addition, not needed after various code simplifications.
2001-09-01 12:13:33 +00:00
Andrey A. Chernov
6946977c36 If lseek to wrong value sucessfully happens despite all pre-checks, set __SERR
to indicate that stream becomes inconsistent.
2001-09-01 11:21:28 +00:00
Andrey A. Chernov
b13ed88361 If position is underflowed, don't try to hide that fact by recovery, just
return EIO and set __SERR to mark stream as inconsistent.
2001-09-01 11:18:53 +00:00
Andrey A. Chernov
65efd81290 Back out disabling ungetc() at 0, use different solution:
keep negative offset internally, but return 0 externally in ftell*()
I.e. use 0 now as 'unspecified value' per POSIX ungetc() description.
2001-09-01 01:56:54 +00:00
Andrey A. Chernov
598bb4cb30 Add originally missing __sinit() call. 2001-08-31 20:36:19 +00:00
Andrey A. Chernov
c4b2cc78e3 Simplify offset underflow checks even more 2001-08-31 20:17:32 +00:00
Andrey A. Chernov
711b11769d Describe that we disallow ungetc at offset 0 now. 2001-08-31 20:03:49 +00:00
Andrey A. Chernov
4db40fd143 Disallow ungetc at offset 0 (to prevent negative offset happens), so simplify
checks in ftell.
2001-08-31 19:50:25 +00:00
Andrey A. Chernov
7cf30ace84 Drop buffer first, _then_ ask for real position 2001-08-31 18:54:44 +00:00
Andrey A. Chernov
2ff678f5bb The same big piece of ftell code repeated in 3 places. Simplify things moving
it into one subfunction instead.
Try to use real offset in strange cases.
2001-08-31 18:23:29 +00:00
Andrey A. Chernov
ee75810413 If file offset is smaller than internal buffer character left count, just drop
internal buffer and trust offset, not return error.
2001-08-31 14:11:14 +00:00
Andrey A. Chernov
1dfa423639 Initialize _offset to 0 in fopen(), it helps to optimize fseek/ftell 2001-08-31 13:14:49 +00:00
Andrey A. Chernov
ca934ebcae Detect fp->_offset overflow on read
Use errno to catch negative seek with -1 offset
2001-08-31 12:55:22 +00:00
Ruslan Ermilov
d6002fef6f Use ``.Rv -std'' wherever possible.
Submitted by:	yar
2001-08-31 09:57:38 +00:00
Andrey A. Chernov
57935eeb3d Try to discard some ungetc data in saved internal buffer checks too,
if offset tends to be negative.
2001-08-30 20:49:47 +00:00
Andrey A. Chernov
77f71bc5ac goto dumb; if can't obtain curoff for whence != SEEK_CUR cases, as supposed 2001-08-30 20:19:45 +00:00
Andrey A. Chernov
e54bc118c1 Add more EOVERFLOW checks.
When file offset tends to be negative due to internal and ungetc buffers
additions counted, try to discard some ungetc data first, then return EBADF.
Later one can happens if lseek(fileno(fd),...) called f.e. POSIX says that
ungetc beyond beginning of the file results are undefined, so we can just
discard some of ungetc data in that case.

Don't rely on gcc cast when checking for overflow, use OFF_MAX.

Cosmetique.
2001-08-30 19:54:04 +00:00
Andrey A. Chernov
b0eeb07b5b Cosmetique fixes from bde 2001-08-26 10:38:29 +00:00
Andrey A. Chernov
f0d5097e06 Cosmetique: correct English in comments 2001-08-23 14:49:02 +00:00
Kris Kennaway
6dac8ac9e5 Mark some functions as __printflike() and/or taking const char * arguments
instead of char *.

MFC after:	2 weeks
2001-08-20 12:53:36 +00:00
Andrey A. Chernov
c5981656ea Add about rewind+errno, describe ESPIPE, minor formatting. 2001-08-19 08:24:50 +00:00
Andrey A. Chernov
98aa5183a2 Simplify overflow calculations a bit 2001-08-17 11:08:56 +00:00
Andrey A. Chernov
4a9f1ee4e5 Remove extra check, already done in upper level caller, i.e. in
_fseeko()
2001-08-17 10:43:03 +00:00
Andrey A. Chernov
5fdaf178ae Mention ftell & ftello in EOVERFLOW section too. 2001-08-17 10:29:09 +00:00
Andrey A. Chernov
b98ba4224b Add more overflow checks in case of fseek() 2001-08-17 10:22:03 +00:00
Andrey A. Chernov
68ce9bfb10 Don't clear "we have offset" flag even if long is overflow for fseek(),
there is no harm to have it, it will reduce next call efforts.
2001-08-17 10:06:46 +00:00
Andrey A. Chernov
71b5a4326d fseek.c:
Resulting fseek() offset must fit in long, required by POSIX (pointed by bde),
so add LONG_MAX and final tests for it.

rewind.c:
1) add missing __sinit() as in fseek() it pretends to be.
2) use clearerr_unlocked() since we already lock stream before _fseeko()
3) don't zero errno at the end, it explicitely required by POSIX as the
only one method to test rewind() error condition.
4) don't clearerr() if error happens in _fseeko()
2001-08-17 09:57:11 +00:00
Dima Dorfman
7bc6682520 Explain the relation of getchar() to getc() in less words.
Submitted by:	ru
2001-08-16 03:09:33 +00:00
Andrey A. Chernov
74b2772824 Use smarter overflow tests
Suggested by: bde
2001-08-15 20:10:38 +00:00
Andrey A. Chernov
d9e3eff33a 1) Disallow negative seek as POSIX require for fseek{o} (but not for lseek):
"[EINVAL] ... The resulting file-position indicator would be set to a
negative value."

Moreover, in real life negative seek in stdio cause EOF indicator cleared
and not set again forever even if EOF returned.

2) Catch few possible off_t overflows.

Reviewed by:	arch discussion
2001-08-15 02:07:47 +00:00
Peter Wemm
2b618987fe Rip out the old __stdin/out/err stuff. It was completely 100% useless. :-(
It was foiled because of dynamic copy relocations that caused compile-time
space to be reserved in .bss and at run time a blob of data was copied to
that space and everything used the .bss version..  The problem is that
the space is reserved at compile time, not runtime... So we *still* could
not change the size of FILE.  Sigh.  :-(

Replace it with something that does actually work and really does let us
make 'FILE' extendable.  It also happens to be the same as Linux does in
glibc, but has the slight cost of a pointer.  Note that this is the
same cost that 'fp = fopen(), fprintf(fp, ...); fclose(fp);' has.
Fortunately, actual references to stdin/out/err are not all that common
since we have implicit stdin/out/err-using versions of functions
(printf() vs. fprintf()).
2001-08-13 21:48:44 +00:00
Dima Dorfman
7f55e48eb1 Use .Fn, .Fa, and .Dv where appropriate. 2001-08-10 20:49:38 +00:00
Yaroslav Tykhiy
b1250632c5 Use the ``.Rv -std'' mdoc(7) macro in appropriate cases.
Reviewed by:	ru
2001-08-09 13:32:13 +00:00
Ruslan Ermilov
c4d9468ea0 mdoc(7) police:
Avoid using parenthesis enclosure macros (.Pq and .Po/.Pc) with plain text.
Not only this slows down the mdoc(7) processing significantly, but it also
has an undesired (in this case) effect of disabling hyphenation within the
entire enclosed block.
2001-08-07 15:48:51 +00:00
Sheldon Hearn
549c291915 Avoid any chance of being misunderstood as having libelled developers
or developers' vendors without compromising the importance of warning
against bad practice.

Reported by:	mjacob
MFC after:	1 week
2001-07-29 15:08:14 +00:00
Dima Dorfman
7ebcc426ef Remove whitespace at EOL. 2001-07-15 07:53:42 +00:00
Ruslan Ermilov
a307d59838 mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 13:41:46 +00:00
Dima Dorfman
70d51341bf mdoc(7) police: remove extraneous .Pp before and/or after .Sh. 2001-07-09 09:54:33 +00:00
Mike Heffner
0bada8603d Attempt to use the environment variable TMPDIR for the temporary
directory, defaulting to /tmp.

PR:		bin/16924
Reviewed by:	dd
MFC after:	2 weeks
2001-07-07 04:08:32 +00:00
Ruslan Ermilov
4988599f44 mdoc(7) police: fixed/simplified formatting. 2001-07-04 11:59:14 +00:00
Assar Westerlund
1866adc54f (cantwrite): do not allocate memory for a NULL string
PR:		misc/26044

MFC after:	1 week

Submitted by:	bde
2001-06-18 04:44:23 +00:00
Assar Westerlund
a52532c91a revert freeing of memory that gets allocated when str == NULL
(this will be fixed in a better way)

PR:		misc/26044
2001-06-18 04:40:52 +00:00
Assar Westerlund
207d92d043 free memory that gets allocated by vfprintf when str == NULL
PR:		misc/26044

MFC after:	1 week
2001-06-16 05:37:57 +00:00
Jens Schweikhardt
32b21f091e Add description for the 'll' modifier for long long. In essence a copy
from the 'l' description with s/long/long long/g.

PR:		27017
Submitted by:	Guy Harris <guy@alum.mit.edu>
MFC after:	2 weeks
2001-06-13 19:05:12 +00:00
Warner Losh
656f411d33 Back out my changes describing how snprintf nul terminates. It
was from the iso standard.  Keep the sentence that says it is always
NUL terminated to make sure that people understand that.

Requested by: bde
2001-06-05 23:39:45 +00:00
Warner Losh
890d5b436d Minor improvements:
o Explain snprintf's return value better.
o Document snprintf, et al, were defined in C-99
o Warn against %n.
2001-06-05 04:22:30 +00:00
Daniel Eischen
fcd70a7565 Properly initialize a temporary FILE that is allocated off the stack.
The change to reuse _up from FILE (to allow FILE to grow without changing
size) overlooked FILE being allocated off the stack.

Approved by:	sobomax
2001-06-04 12:36:07 +00:00
Gregory Neil Shapiro
1259dd85eb Correct the documentation for snprintf() and vsprintf() which actually
return the number of characters that would have been in the new string.

Obtained from:	OpenBSD
MFC after:	3 days
2001-05-30 23:47:14 +00:00
Eric Melville
2de2196026 Add warnings about trusting user-supplied data.
Reviewed by:	ru
Approved by:	murray
Obtained from:	OpenBSD
2001-05-25 20:42:40 +00:00
Ruslan Ermilov
2d105f1659 mdoc(7) police: fix markup. 2001-04-18 13:16:47 +00:00
Daniel Eischen
54fd7f685f To be consistent, use the __weak_reference macro from <sys/cdefs.h>
instead of #pragma weak to create weak definitions.  This macro is
improperly named, though, since a weak definition is not the same
thing as a weak reference.

Suggested by:	bde
2001-04-10 04:11:50 +00:00
Ruslan Ermilov
4a558355e5 MAN[1-9] -> MAN. 2001-03-27 17:27:19 +00:00
David E. O'Brien
eed5465d4e Fix style nit. 2001-03-05 11:10:12 +00:00
David E. O'Brien
2c4b10dd85 Fix style breakage. 2001-03-05 11:06:18 +00:00
Daniel Eischen
45d8008748 Hide the definition of struct __sFILEX and add the needed
lock definitions to it.  flockfile state is now allocated
along with the rest of FILE.  This eliminates the need for a
separate allocation of flockfile state as well as eliminating
the mutex/lock used to serialize its allocation.
2001-03-01 05:22:14 +00:00
Ruslan Ermilov
588a200ce1 .St -ansiC -> .St -isoC 2001-02-26 13:23:47 +00:00
Brian Feldman
75d4fd11cb Correctly handle the race itself, too (don't leave it locked).
This is about to be replaced anyway by initialization explicitly
instead of lazily, and reducing the complexity of it.  As it is
now, this will work fine, however.
2001-02-23 17:55:01 +00:00
Brian Feldman
93f9377a7c Use the right names to call pthread_mutex_{,un}lock so that things
work in both the libc only and libc/libc_r case.
2001-02-23 06:26:22 +00:00
Brian Feldman
4524204190 Fix the problems I (and others, undoubtedly) have been having for a
while with threaded software in -CURRENT acting very "weird".  It has
seemed, for example, in Mozilla that threads attempting to do host
lookups have been locking up.  That's exactly the case.

There was a race condition in the implementation of the initialization
of the mutex used to protect FILE operations, first of all: multiple
instances of FLOCKFILE() in libc could occur on the same FILE at
the same time and cause strange behavior by overwriting eachothers'
creation of the mutex and the rest of the file lock.

Secondly, it's not appropriate to test the "validity" of the file
descriptor referenced by the FILE; if the code is calling FLOCKFILE()
or FUNLOCKFILE(), it wants the FILE to be locked or unlocked, not
to be locked or unlocked on the condition that _file is >= 0.  This
also could quite easily cause leaks by failing to perform the lock or
unlock operation when it actually is needed.

Mozilla now works again on -CURRENT when linked to libc_r.so.5 and
libc.so.5.
2001-02-23 04:59:12 +00:00
Peter Wemm
3d92fc05aa Place some hooks (__stdin, __stdout, __stderr) into libc for a future
ABI change.  There is some serious evilness here to work around some
gcc weaknesses.  We need to know the sizeof(FILE) manually until __sF
goes away in the next major bump.  We have the size for Alpha and i386,
missing is ia64, ppc and sparc* (and i386 with 64 bit longs).
At some point down the track we can change the stdin etc #defines to
stop hard coding the size of FILE into application binaries.

Lots of head scratching and ideas and testing by: green, imp
2001-02-20 01:56:52 +00:00