Commit Graph

39 Commits

Author SHA1 Message Date
Peter Wemm
1ec21d5930 Fix nasty bracketing/precedence bug. Every time something read (and
refilled) a file that was either line- or un-buffered, all files were
flushed.  According to the code comment, the flush (according to ANSI)
is supposed to happen on write + line buffered output files, not _all_
files.

Obtained from: OpenBSD / Theo de Raadt, possibly from proven@cygnus.com
1996-08-13 17:49:45 +00:00
Mike Pritchard
47cc13c104 Correct the paramter type of the second argument to fgets.
Obtained from: NetBSD-bugs mailing list
1996-08-06 22:34:44 +00:00
Peter Wemm
ef1c2ba16f Fix some of the problems that bde pointed out to me some time ago.
- buffer expansions were not working right due to a return code botch.
 - signed types instead of size_t's meant somebody else went and put
   casts in, I've changed the types to what they should have been.
1996-07-28 16:16:11 +00:00
James Raynard
ce51cf0392 Suggested by: Bruce Evans, Jeffrey Hsu, Gary Palmer
Added $Id$'s to files that were lacking them (gpalmer), made some
cosmetic changes to conform to style guidelines (bde) and checked
against NetBSD and Lite2 to remove unnecessary divergences (hsu, bde)

One last code cleanup:-

Removed spurious casts in fseek.c and stdio.c.
Added missing function argument in fwalk.c.
Added missing header include in flags.c and rget.c.
Put in casts where int's were being passed as size_t's.
Put in missing prototypes for static functions.
Changed second args of __sflags() inflags.c and writehook() in vasprintf.c
from char * to const char * to conform to prototypes.

This directory now compiles with no warnings with -Wall under
gcc-2.6.3 and with considerably less warnings than before with the
ultra-pedantic script I used for testing. (Most of the remaining ones
are due to const poisoning).
1996-06-22 10:34:15 +00:00
James Raynard
e2f892a7e7 Code cleanup:-
The usual stuff, adding missing function prototypes, argument types,
return values, etc.
1996-06-12 23:02:53 +00:00
James Raynard
45f6af0252 Code cleanup:-
The usual stuff, adding missing function prototypes, argument types,
return values, etc.

This directory now compiles with no warnings with -Wall on gcc2.6.3!
1996-06-12 22:59:55 +00:00
James Raynard
b83100194d Code cleanup:-
The usual stuff, adding missing function prototypes, argument types,
return values, etc. In mktemp.c, convert pid from u_int to pid_t, and
get rid of "extern int errno".
1996-06-12 22:58:21 +00:00
James Raynard
9915c09cf9 Code cleanup:-
The usual stuff, adding missing function prototypes, argument types,
return values, etc.
1996-06-12 22:56:41 +00:00
Joerg Wunsch
d230d4275a Reword the sentence about the required space for the result string.
Closes PR # 1303.-
1996-06-09 06:48:42 +00:00
Jordan K. Hubbard
941fbd30eb Fix bogus MLINKS line from vasprintf change. 1996-05-29 05:00:12 +00:00
Wolfram Schneider
01fc74a034 add manpage links
asprintf.3 -> printf.3
vasprintf -> printf.3
1996-05-29 01:00:00 +00:00
Peter Wemm
15aa00d597 Add an implementation of the gnu-ish asprintf() and vasprintf(). They are
not based on gpl'ed code, just prototype and usage.  I'm not 100% certain
they behave the same while the system is in trouble (eg: malloc() failing)
but in those circumstances all bets would be off anyway.

These routines work like sprintf() and vsprintf(), except that instead of
using a fixed buffer, they allocate memory and return it to the user
and it's the user's responsibility to free() it.  They have allocate as
much memory as they need (and can get), so the size of strings it can deal
with is limited only by the amount of memory it can malloc() on your
behalf.

There are a few gpl'ed programs starting to use this interface, and it's
becoming more common with the scares about security risks with sprintf().
I dont like the look of the code that the various programs (including
cvs, gdb, libg++, etc) provide if configure can't find it on the system.

It should be possible to modify the stdio core code to provide this
interface more efficiently, I was more worried about having something
that worked and was secure.  :-)  (I noticed that there was once intended
to be a smprintf() routine when our stdio was written for 4.4BSD, but it
looks pretty stillborn, and it's intended interface is not clear).  Since
Linux and gnu libc have this interface, it seemed silly to bring yet
another one onto the scene.
1996-05-27 10:49:43 +00:00
Mike Pritchard
712dc76e87 Fixed various problems: typos, grammer, missing include files
wrong function type declarations, and wrong argument type
declarations.
1996-05-23 01:05:25 +00:00
Mike Pritchard
417349c472 Fix a typo. 1996-05-01 22:49:36 +00:00
Mike Pritchard
20631f47f1 Correct a minor typo. Fixes part of PR#1000.
Submitted by:	Dave Glowacki <dglo@ssec.wisc.edu>
1996-04-09 21:48:21 +00:00
Mike Pritchard
064f007493 Added missing section numbers to a bunch of .Xr macros, or
converted them into .Fn macros where appropriate.  Also fixed
up some minor formatting problems.
1996-03-27 20:49:07 +00:00
Bruce Evans
1b5844118e Removed now-bogus casts that were to hide the inconsistency between the
nonstandard normal version and the standard threaded version.

Removed a bogus L in a constant.  fpos_t's aren't longs, and casting to
fpos_t would be verbose.
1996-03-27 18:07:29 +00:00
Bruce Evans
926bb1cf42 Fixed bogus cross references.
Reviewed by:	mpp
1996-03-27 17:54:40 +00:00
Bruce Evans
fe20c3b61c Say what happens to the buffer when fgets() returns NULL.
Fixed bogus cross references and a misordered line.
1996-03-27 17:43:38 +00:00
Andrey A. Chernov
06b47700ae Since n is int now, sanity check must be n <= 0, not simple n == 0 1996-03-25 12:03:11 +00:00
Paul Richards
880787f0fe Fix incorrect parameter types. 1996-03-24 15:49:34 +00:00
Bill Fenner
261a532a8b The 4.4-lite vfprintf counted the %# hex prefix and the sign in
the precision; ANSI X3J11 is not crystal clear but certainly says
that the precision specifies the number of /digits/, and signs
and "0x" aren't really digits.

NetBSD already has a similar patch.
1996-03-20 18:28:48 +00:00
Mike Pritchard
d428a98d6d Added a little NOTES section explaining that passing in a string that
resides in read-only memory is going to cause the program to core dump,
and this is commmon with older pre-ANSI C programs.

(I've scratched my head over this one at 3 in the morning before
while trying to port some ancient program)

Suggested by:	Gary Kline <kline@tera.com>
1996-02-15 05:02:16 +00:00
Mike Pritchard
a5ed710ccd Fix even more spelling errors in some more man pages. 1996-01-30 16:34:52 +00:00
Julian Elischer
f70177e76e Reviewed by: julian and (hsu?)
Submitted by:	 John Birrel(L?)

changes for threadsafe operations
1996-01-22 00:02:33 +00:00
Mike Pritchard
270d3d754a Fix a variety of minor typos and cross references in a bunch of
man pages.

Masanobu Saitoh <msaitoh@spa.is.uec.ac.jp>
Giles Lean <giles@nemeton.com.au>
<soda@sra.co.jp>
1996-01-20 07:29:11 +00:00
Poul-Henning Kamp
c0d41487f2 Minor cleanup, #include's and unused vars.
Added compile-time warning to an old funky function.
1995-10-22 14:52:30 +00:00
Peter Wemm
216b9a0d22 Make a link-time warning for the use of gets().
IMHO, the run-time warning should come out, but I'm not game to start that
fight yet...  This uses a feature of the gnu linker.

Inspired by:  NetBSD
1995-10-04 18:29:01 +00:00
Bruce Evans
372e515faa This gets() used \r\n, which is doggish. 1995-09-29 18:52:47 +00:00
Peter Wemm
fdf4460bf9 fgetline does not exist.. fgetln is in it's place. Correct the X-Ref.
Noticed by:	Brian Tao, Bruce Evans
1995-08-18 14:22:00 +00:00
Rodney W. Grimes
6c06b4e2aa Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
David Greenman
dbe38b75e5 Fixed typo. 1995-05-15 12:23:03 +00:00
Bruce Evans
ffe57f1a20 Obtained from: 1.1.5 (originally by jtc)
Fix printf("%g", 0.0) - print "0", not "0.".  The previous fixes in this
area had one non-cosmetic (non-)change that caused this bug.

Bruce
1995-04-06 16:28:15 +00:00
Bruce Evans
918bed7582 Remove `|| flags & ALT == 0' which was an obscure no-op, not a
parenthesization/precedence bug.
1995-03-12 13:53:51 +00:00
Bruce Evans
d26be6f09d Obtained from: 1.1.5. Originally by jtc. Cosmetically changed for this
commit by bde.

Fix bugs in floating point formatting.  The 4.4lite version is similar
to revision 1.3 in old-cvs and is missing all of jtc's fixes in revision
1.4 in old-cvs.  Revision 1.2 in ncvs fixed one of the old bugs but
introduced at least one new one (for %.0e).

old-cvs log:
revision 1.4
date: 1993/11/04 19:38:22;  author: jtc;  state: Exp;  lines: +33 -20
My work from NetBSD to make printf() & friends ANSI C compliant.
Fixes several bugs in floating point formatting:
  1. Trailing zeros were being stripped with %e format.
  2. %g/%G formats incorrect.
  3. Lots of other nits.
1995-03-12 13:26:49 +00:00
Doug Rabson
2cc220b6ed Fix handling of 'e' format floating point so that it prints trailing zeros
correctly.
1995-01-19 12:05:53 +00:00
Nate Williams
692a99c012 Date: Wed, 26 Oct 1994 15:44:49 -0600
From: Chris Torek <torek@bsdi.com>
Here is a semi-official patch (apply to /usr/src/lib/libc/stdio/fseek.c,
rebuild libc, install).  The current code fails when the seek:

  - is optimized, and
  - is to just past the end of the block currently in the buffer, and
  - is followed by another seek with no intervening read operation, and
  - the destination of subsequent seek is within the block left in the
    buffer (seeking to the beginning of a block does not force a read,
    so the buffer still contains the previous block)

so it is indeed rather obscure.

I may have a different `final' fix, as this one `loses' the buffer
contents on a seek that goes just past the end of the current block.

[Footnote: seeks are optimized only on read-only opens of regular
files that are buffered by the file's optimal I/O size.  This is
what you get with fopen(path, "r") and no call to setvbuf().]

Obtained from: [ BSDI mailing list ]
1994-11-05 18:49:34 +00:00
Garrett Wollman
2ceb2ce9ee First crack at making libc work with the new make macros. It compiles on
my machine, and a simple static (genassym) and shared (sysctl) executable
both work.  Still to be done: RPCand YP merge.
1994-08-05 01:19:12 +00:00
Rodney W. Grimes
58f0484fa2 BSD 4.4 Lite Lib Sources 1994-05-27 05:00:24 +00:00