Browse Source

first round of repairs on stdlib

OPENBSD_2_6
aaron 25 years ago
parent
commit
5457e11d62
30 changed files with 182 additions and 150 deletions
  1. +40
    -19
      src/lib/libc/stdlib/a64l.3
  2. +2
    -2
      src/lib/libc/stdlib/abort.3
  3. +2
    -2
      src/lib/libc/stdlib/abs.3
  4. +3
    -3
      src/lib/libc/stdlib/alloca.3
  5. +3
    -3
      src/lib/libc/stdlib/atexit.3
  6. +3
    -3
      src/lib/libc/stdlib/atof.3
  7. +3
    -3
      src/lib/libc/stdlib/atoi.3
  8. +3
    -3
      src/lib/libc/stdlib/atol.3
  9. +3
    -3
      src/lib/libc/stdlib/bsearch.3
  10. +2
    -2
      src/lib/libc/stdlib/calloc.3
  11. +3
    -3
      src/lib/libc/stdlib/div.3
  12. +15
    -15
      src/lib/libc/stdlib/getenv.3
  13. +13
    -10
      src/lib/libc/stdlib/getopt.3
  14. +2
    -3
      src/lib/libc/stdlib/getsubopt.3
  15. +2
    -2
      src/lib/libc/stdlib/labs.3
  16. +6
    -6
      src/lib/libc/stdlib/ldiv.3
  17. +14
    -13
      src/lib/libc/stdlib/malloc.3
  18. +2
    -2
      src/lib/libc/stdlib/qabs.3
  19. +6
    -6
      src/lib/libc/stdlib/qdiv.3
  20. +2
    -2
      src/lib/libc/stdlib/qsort.3
  21. +6
    -5
      src/lib/libc/stdlib/radixsort.3
  22. +2
    -2
      src/lib/libc/stdlib/rand.3
  23. +2
    -2
      src/lib/libc/stdlib/rand48.3
  24. +7
    -7
      src/lib/libc/stdlib/random.3
  25. +2
    -2
      src/lib/libc/stdlib/realpath.3
  26. +4
    -4
      src/lib/libc/stdlib/strtod.3
  27. +4
    -4
      src/lib/libc/stdlib/strtol.3
  28. +4
    -4
      src/lib/libc/stdlib/strtoul.3
  29. +8
    -8
      src/lib/libc/stdlib/system.3
  30. +14
    -7
      src/lib/libc/stdlib/tsearch.3

+ 40
- 19
src/lib/libc/stdlib/a64l.3 View File

@ -24,7 +24,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: a64l.3,v 1.3 1999/02/27 21:55:53 deraadt Exp $
.\" $OpenBSD: a64l.3,v 1.4 1999/06/29 18:36:15 aaron Exp $
.\" .\"
.Dd August 17, 1997 .Dd August 17, 1997
.Dt A64L 3 .Dt A64L 3
@ -45,19 +45,36 @@ The
and and
.Fn l64a .Fn l64a
functions are used to maintain numbers stored in radix-64 functions are used to maintain numbers stored in radix-64
ASCII characters. This is a notation by which 32-bit integers
.Tn ASCII
characters. This is a notation by which 32-bit integers
can be represented by up to six characters; each character can be represented by up to six characters; each character
represents a "digit" in a radix-64 notation.
represents a
.Dq digit
in a radix-64 notation.
.Pp .Pp
The characters used to represent "digits" are '.' for 0, '/' for 1,
'0' through '9' for 2-11, 'A' through 'Z' for 12-37, and 'a' through
'z' for 38-63.
The characters used to represent digits are
.Ql \&.
for 0,
.Ql /
for 1,
.Ql 0
through
.Ql 9
for 2-11,
.Ql A
through
.Ql Z
for 12-37, and
.Ql a
through
.Ql z
for 38-63.
.Pp .Pp
The The
.Fn a64l .Fn a64l
function takes a pointer to a null-terminated radix-64 representation function takes a pointer to a null-terminated radix-64 representation
and returns a corresponding 32-bit value. If the string pointed to by and returns a corresponding 32-bit value. If the string pointed to by
.Ar s
.Fa s
contains more than six characters, contains more than six characters,
.Fn a64l .Fn a64l
will use the first six. will use the first six.
@ -68,35 +85,39 @@ larger than 32 bits, the return value will be sign-extended.
.Pp .Pp
.Fn l64a .Fn l64a
takes a long integer argument takes a long integer argument
.Ar l
.Fa l
and returns a pointer to the corresponding radix-64 representation. and returns a pointer to the corresponding radix-64 representation.
.Sh RETURN VALUES .Sh RETURN VALUES
On success, On success,
.Fn a64l .Fn a64l
returns a 32-bit representation of returns a 32-bit representation of
.Ar s .
.Fa s .
If If
.Ar s
is a NULL pointer or if it contains "digits" other than those described above,
.Fa s
is a null pointer or if it contains digits other than those described above.
.Fn a64l .Fn a64l
returns -1L and sets the global variable errno to
.Va EINVAL .
returns \-1 and sets the global variable
.Va errno
to
.Er EINVAL .
.Pp .Pp
On success, On success,
.Fn l64a .Fn l64a
returns a pointer to a string containing the radix-64 representation of returns a pointer to a string containing the radix-64 representation of
.Ar l .
.Fa l .
If If
.Ar l
.Fa l
is 0, is 0,
.Fn l64a .Fn l64a
returns a pointer to the empty string. returns a pointer to the empty string.
If If
.Ar l
.Fa l
is negative, is negative,
.Fn l64a .Fn l64a
returns a NULL pointer and sets the global variable errno to
.Va EINVAL .
returns a null pointer and sets the global variable
.Va errno
to
.Er EINVAL .
.Sh WARNINGS .Sh WARNINGS
The value returned by The value returned by
.Fn l64a .Fn l64a
@ -115,7 +136,7 @@ If a long integer is larger than 32 bits, only the low-order
32 bits are used. 32 bits are used.
.Sh STANDARDS .Sh STANDARDS
The The
.Fn a64l
.Fn a64l
and and
.Fn l64a .Fn l64a
functions conform to functions conform to


+ 2
- 2
src/lib/libc/stdlib/abort.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: abort.3,v 1.4 1997/07/17 07:39:41 deraadt Exp $
.\" $OpenBSD: abort.3,v 1.5 1999/06/29 18:36:17 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt ABORT 3 .Dt ABORT 3
@ -56,7 +56,7 @@ is being caught and the signal handler does not return.
Any open streams are flushed and closed. Any open streams are flushed and closed.
.Sh RETURN VALUES .Sh RETURN VALUES
The The
.Nm abort
.Fn abort
function function
never returns. never returns.
.Sh SEE ALSO .Sh SEE ALSO


+ 2
- 2
src/lib/libc/stdlib/abs.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: abs.3,v 1.3 1999/05/16 19:55:12 alex Exp $
.\" $OpenBSD: abs.3,v 1.4 1999/06/29 18:36:17 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt ABS 3 .Dt ABS 3
@ -51,7 +51,7 @@ The
function function
computes computes
the absolute value of the integer the absolute value of the integer
.Ar j .
.Fa j .
.Sh RETURN VALUES .Sh RETURN VALUES
The The
.Fn abs .Fn abs


+ 3
- 3
src/lib/libc/stdlib/alloca.3 View File

@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: alloca.3,v 1.6 1999/05/23 14:11:03 aaron Exp $
.\" $OpenBSD: alloca.3,v 1.7 1999/06/29 18:36:18 aaron Exp $
.\" .\"
.Dd May 2, 1991 .Dd May 2, 1991
.Dt ALLOCA 3 .Dt ALLOCA 3
@ -45,7 +45,7 @@
The The
.Fn alloca .Fn alloca
function function
allocates
allocates
.Fa size .Fa size
bytes of space in the stack frame of the caller. bytes of space in the stack frame of the caller.
This temporary space is automatically freed on This temporary space is automatically freed on
@ -70,6 +70,6 @@ is machine dependent; its use is discouraged.
.\" .Fn alloca .\" .Fn alloca
.\" function appeared in .\" function appeared in
.\" .Bx ?? . .\" .Bx ?? .
.\" The function appeared in 32v, pwb and pwb.2 and in 3bsd 4bsd
.\" The function appeared in 32v, pwb and pwb.2 and in 3bsd 4bsd
.\" The first man page (or link to a man page that I can find at the .\" The first man page (or link to a man page that I can find at the
.\" moment is 4.3... .\" moment is 4.3...

+ 3
- 3
src/lib/libc/stdlib/atexit.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: atexit.3,v 1.2 1996/08/19 08:33:22 tholo Exp $
.\" $OpenBSD: atexit.3,v 1.3 1999/06/29 18:36:18 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt ATEXIT 3 .Dt ATEXIT 3
@ -50,11 +50,11 @@ The
.Fn atexit .Fn atexit
function function
registers the given registers the given
.Ar function
.Fa function
to be called at program exit, whether via to be called at program exit, whether via
.Xr exit 3 .Xr exit 3
or via return from the program's or via return from the program's
.Em main .
.Fn main .
Functions so registered are called in reverse order; Functions so registered are called in reverse order;
no arguments are passed. no arguments are passed.
At least 32 functions can always be registered, At least 32 functions can always be registered,


+ 3
- 3
src/lib/libc/stdlib/atof.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: atof.3,v 1.2 1996/08/19 08:33:23 tholo Exp $
.\" $OpenBSD: atof.3,v 1.3 1999/06/29 18:36:18 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt ATOF 3 .Dt ATOF 3
@ -51,9 +51,9 @@ string to double
The The
.Fn atof .Fn atof
function converts the initial portion of the string pointed to by function converts the initial portion of the string pointed to by
.Ar nptr
.Fa nptr
to to
.Ar double
.Li double
representation. representation.
.Pp .Pp
It is equivalent to: It is equivalent to:


+ 3
- 3
src/lib/libc/stdlib/atoi.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: atoi.3,v 1.2 1996/08/10 04:51:31 tholo Exp $
.\" $OpenBSD: atoi.3,v 1.3 1999/06/29 18:36:18 aaron Exp $
.\" .\"
.Dd June 4, 1993 .Dd June 4, 1993
.Dt ATOI 3 .Dt ATOI 3
@ -51,9 +51,9 @@ string to integer
The The
.Fn atoi .Fn atoi
function converts the initial portion of the string pointed to by function converts the initial portion of the string pointed to by
.Em nptr
.Fa nptr
to to
.Em integer
.Li integer
representation. representation.
.Pp .Pp
It is equivalent to: It is equivalent to:


+ 3
- 3
src/lib/libc/stdlib/atol.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: atol.3,v 1.2 1996/08/19 08:33:25 tholo Exp $
.\" $OpenBSD: atol.3,v 1.3 1999/06/29 18:36:19 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt ATOL 3 .Dt ATOL 3
@ -51,9 +51,9 @@ string to long integer
The The
.Fn atol .Fn atol
function converts the initial portion of the string pointed to by function converts the initial portion of the string pointed to by
.Ar nptr
.Fa nptr
to to
.Em long integer
.Li long integer
representation. representation.
.Pp .Pp
It is equivalent to: It is equivalent to:


+ 3
- 3
src/lib/libc/stdlib/bsearch.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: bsearch.3,v 1.3 1997/06/13 23:41:35 deraadt Exp $
.\" $OpenBSD: bsearch.3,v 1.4 1999/06/29 18:36:19 aaron Exp $
.\" .\"
.Dd April 19, 1994 .Dd April 19, 1994
.Dt BSEARCH 3 .Dt BSEARCH 3
@ -50,12 +50,12 @@ The
.Fn bsearch .Fn bsearch
function searches an array of function searches an array of
.Fa nmemb .Fa nmemb
objects, the initial member of which is
objects, the initial member of which is
pointed to by pointed to by
.Fa base , .Fa base ,
for a member that matches the object pointed to by for a member that matches the object pointed to by
.Fa key . .Fa key .
The size of each member of the array is specified by
The size of each member of the array is specified by
.Fa size . .Fa size .
.Pp .Pp
The contents of the array should be in ascending sorted order according The contents of the array should be in ascending sorted order according


+ 2
- 2
src/lib/libc/stdlib/calloc.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: calloc.3,v 1.4 1999/05/16 19:55:13 alex Exp $
.\" $OpenBSD: calloc.3,v 1.5 1999/06/29 18:36:19 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt CALLOC 3 .Dt CALLOC 3
@ -48,7 +48,7 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn calloc .Fn calloc
function allocates space for an array of
function allocates space for an array of
.Fa nmemb .Fa nmemb
objects, each of whose size is objects, each of whose size is
.Fa size . .Fa size .


+ 3
- 3
src/lib/libc/stdlib/div.3 View File

@ -31,7 +31,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: div.3,v 1.3 1999/05/16 19:55:14 alex Exp $
.\" $OpenBSD: div.3,v 1.4 1999/06/29 18:36:19 aaron Exp $
.\" .\"
.Dd April 19, 1991 .Dd April 19, 1991
.Dt DIV 3 .Dt DIV 3
@ -48,11 +48,11 @@ The
.Fn div .Fn div
function function
computes the value computes the value
.Fa num/denom
.Fa num Ns No / Ns Fa denom
and returns the quotient and remainder in a structure named and returns the quotient and remainder in a structure named
.Fa div_t .Fa div_t
that contains two that contains two
.Em int
.Li int
members named members named
.Fa quot .Fa quot
and and


+ 15
- 15
src/lib/libc/stdlib/getenv.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: getenv.3,v 1.4 1999/05/25 13:06:46 aaron Exp $
.\" $OpenBSD: getenv.3,v 1.5 1999/06/29 18:36:20 aaron Exp $
.\" .\"
.Dd December 11, 1993 .Dd December 11, 1993
.Dt GETENV 3 .Dt GETENV 3
@ -60,10 +60,10 @@ host
.Em environment list . .Em environment list .
For compatibility with differing environment conventions, For compatibility with differing environment conventions,
the given arguments the given arguments
.Ar name
.Fa name
and and
.Ar value
may be appended and prepended,
.Fa value
may be appended and prepended,
respectively, respectively,
with an equal sign with an equal sign
.Dq Li \&= . .Dq Li \&= .
@ -71,30 +71,30 @@ with an equal sign
The The
.Fn getenv .Fn getenv
function obtains the current value of the environment variable, function obtains the current value of the environment variable,
.Ar name .
.Fa name .
If the variable If the variable
.Ar name
.Fa name
is not in the current environment, is not in the current environment,
a null pointer is returned. a null pointer is returned.
.Pp .Pp
The The
.Fn setenv .Fn setenv
function inserts or resets the environment variable function inserts or resets the environment variable
.Ar name
.Fa name
in the current environment list. in the current environment list.
If the variable If the variable
.Ar name
.Fa name
does not exist in the list, does not exist in the list,
it is inserted with the given it is inserted with the given
.Ar value .
.Fa value .
If the variable does exist, the argument If the variable does exist, the argument
.Ar overwrite
.Fa overwrite
is tested; if is tested; if
.Ar overwrite is
zero, the
variable is not reset, otherwise it is reset
.Fa overwrite
is zero,
the variable is not reset, otherwise it is reset
to the given to the given
.Ar value .
.Fa value .
.Pp .Pp
The The
.Fn putenv .Fn putenv
@ -122,7 +122,7 @@ is set to indicate the error and a
.Pp .Pp
If If
.Fn getenv .Fn getenv
is succesful, the string returned should be considered read-only.
is succesful, the string returned should be considered read-only.
.Sh ERRORS .Sh ERRORS
.Bl -tag -width [ENOMEM] .Bl -tag -width [ENOMEM]
.It Bq Er ENOMEM .It Bq Er ENOMEM


+ 13
- 10
src/lib/libc/stdlib/getopt.3 View File

@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: getopt.3,v 1.8 1999/05/27 13:09:09 aaron Exp $
.\" $OpenBSD: getopt.3,v 1.9 1999/06/29 18:36:20 aaron Exp $
.\" .\"
.Dd April 19, 1994 .Dd April 19, 1994
.Dt GETOPT 3 .Dt GETOPT 3
@ -132,22 +132,25 @@ When all options have been processed (i.e., up to the first non-option
argument), argument),
.Fn getopt .Fn getopt
returns \-1. returns \-1.
.Sh SEE ALSO
.Xr getopt 1 ,
.Xr getsubopt 3
.Sh DIAGNOSTICS .Sh DIAGNOSTICS
If the If the
.Fn getopt .Fn getopt
function encounters a character not found in the string function encounters a character not found in the string
.Va optstring .Va optstring
or detects or detects
a missing option argument it writes an error message to
.Em stderr
a missing option argument it writes an error message to
.Em stderr
and returns and returns
.Ql ? . .Ql ? .
Setting Setting
.Va opterr .Va opterr
to a zero will disable these error messages. to a zero will disable these error messages.
If If
.Va optstring
has a leading
.Va optstring
has a leading
.Ql \&: .Ql \&:
then a missing option argument causes a then a missing option argument causes a
.Ql \&: .Ql \&:
@ -202,17 +205,17 @@ function appeared
The The
.Fn getopt .Fn getopt
function was once specified to return function was once specified to return
.Dv EOF
.Dv EOF
instead of \-1. instead of \-1.
This was changed by This was changed by
.St -p1003.2-92 .St -p1003.2-92
to decouple
to decouple
.Fn getopt .Fn getopt
from
from
.Pa <stdio.h> . .Pa <stdio.h> .
.Pp .Pp
A single dash A single dash
.Dq Li -
.Pq Ql -
may be specified as a character in may be specified as a character in
.Fa optstring , .Fa optstring ,
however it should however it should
@ -221,7 +224,7 @@ have an argument associated with it.
This allows This allows
.Fn getopt .Fn getopt
to be used with programs that expect to be used with programs that expect
.Dq Li -
.Ql -
as an option flag. as an option flag.
This practice is wrong, and should not be used in any current development. This practice is wrong, and should not be used in any current development.
It is provided for backward compatibility It is provided for backward compatibility


+ 2
- 3
src/lib/libc/stdlib/getsubopt.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: getsubopt.3,v 1.2 1998/06/15 17:55:07 mickey Exp $
.\" $OpenBSD: getsubopt.3,v 1.3 1999/06/29 18:36:20 aaron Exp $
.\" .\"
.\" Copyright (c) 1990, 1991, 1993 .\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -60,8 +60,7 @@ The argument
is a pointer to a pointer to the string. is a pointer to a pointer to the string.
The argument The argument
.Fa tokens .Fa tokens
is a pointer to a
.Dv NULL Ns -terminated
is a pointer to a null-terminated
array of pointers to strings. array of pointers to strings.
.Pp .Pp
The The


+ 2
- 2
src/lib/libc/stdlib/labs.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: labs.3,v 1.3 1999/05/16 19:55:14 alex Exp $
.\" $OpenBSD: labs.3,v 1.4 1999/06/29 18:36:20 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt LABS 3 .Dt LABS 3
@ -50,7 +50,7 @@ The
.Fn labs .Fn labs
function function
returns the absolute value of the long integer returns the absolute value of the long integer
.Ar j .
.Fa j .
.Sh SEE ALSO .Sh SEE ALSO
.Xr abs 3 , .Xr abs 3 ,
.Xr cabs 3 , .Xr cabs 3 ,


+ 6
- 6
src/lib/libc/stdlib/ldiv.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: ldiv.3,v 1.3 1999/05/16 19:55:15 alex Exp $
.\" $OpenBSD: ldiv.3,v 1.4 1999/06/29 18:36:21 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt LDIV 3 .Dt LDIV 3
@ -50,15 +50,15 @@ The
.Fn ldiv .Fn ldiv
function function
computes the value computes the value
.Ar num/denom
.Fa num Ns No / Ns Fa denom
and returns the quotient and remainder in a structure named and returns the quotient and remainder in a structure named
.Ar ldiv_t
.Li ldiv_t
that contains two that contains two
.Em long integer
.Li long integer
members named members named
.Ar quot
.Fa quot
and and
.Ar rem .
.Fa rem .
.Sh SEE ALSO .Sh SEE ALSO
.Xr div 3 , .Xr div 3 ,
.Xr math 3 , .Xr math 3 ,


+ 14
- 13
src/lib/libc/stdlib/malloc.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: malloc.3,v 1.14 1999/05/27 20:49:35 aaron Exp $
.\" $OpenBSD: malloc.3,v 1.15 1999/06/29 18:36:21 aaron Exp $
.\" .\"
.Dd August 27, 1996 .Dd August 27, 1996
.Dt MALLOC 3 .Dt MALLOC 3
@ -113,9 +113,9 @@ If
is a null pointer, the is a null pointer, the
.Fn realloc .Fn realloc
function behaves like the function behaves like the
.Fn malloc
.Fn malloc
function for the specified size. function for the specified size.
If the space cannot be allocated, the object
If the space cannot be allocated, the object
pointed to by pointed to by
.Fa ptr .Fa ptr
is unchanged. is unchanged.
@ -137,7 +137,7 @@ if ((p = realloc(p, nsize)) == NULL)
.Pp .Pp
In most cases, this will result in a leak of memory. In most cases, this will result in a leak of memory.
As stated earlier, a return value of As stated earlier, a return value of
.Fa NULL
.Dv NULL
indicates that the old object still remains allocated. indicates that the old object still remains allocated.
Better code looks like this: Better code looks like this:
.Bd -literal -offset indent .Bd -literal -offset indent
@ -163,7 +163,7 @@ Flags are single letters, uppercase means on, lowercase means off.
``abort'' malloc will coredump the process, rather than tolerate failure. ``abort'' malloc will coredump the process, rather than tolerate failure.
This is a very handy debugging aid, since the core file will represent the This is a very handy debugging aid, since the core file will represent the
time of failure, time of failure,
rather than when the NULL pointer was accessed.
rather than when the null pointer was accessed.
.Pp .Pp
.It D .It D
``dump'' malloc will dump statistics in a file called ``malloc.out'' at exit. ``dump'' malloc will dump statistics in a file called ``malloc.out'' at exit.
@ -195,7 +195,7 @@ for all operations.
Consult the source for this one. Consult the source for this one.
.Pp .Pp
.It X .It X
``xmalloc''
``xmalloc''
rather than return failure, rather than return failure,
.Xr abort 3 .Xr abort 3
the program with a diagnostic message on stderr. the program with a diagnostic message on stderr.
@ -244,15 +244,15 @@ The
function a pointer to the possibly moved allocated space; function a pointer to the possibly moved allocated space;
otherwise a null pointer is returned. otherwise a null pointer is returned.
.Sh MESSAGES .Sh MESSAGES
If
If
.Fn malloc , .Fn malloc ,
.Fn free .Fn free
or
or
.Fn realloc .Fn realloc
detects an error or warning condition, detects an error or warning condition,
a message will be printed to filedescriptor a message will be printed to filedescriptor
2 (not using stdio). 2 (not using stdio).
Errors will always result in the process being
Errors will always result in the process being
.Xr abort 3 'ed. .Xr abort 3 'ed.
If the ``A'' option has been specified, warnings will also If the ``A'' option has been specified, warnings will also
.Xr abort 3 .Xr abort 3
@ -267,9 +267,10 @@ fishy in there. Consult sources and or wizards.
``allocation failed'' ``allocation failed''
if the ``A'' option is specified it is an error for if the ``A'' option is specified it is an error for
.Fn malloc .Fn malloc
or
or
.Fn realloc .Fn realloc
to return NULL.
to return
.Dv NULL .
.Pp .Pp
``mmap(2) failed, check limits.'' ``mmap(2) failed, check limits.''
This is a rather weird condition that is most likely to mean that This is a rather weird condition that is most likely to mean that
@ -287,7 +288,7 @@ A pointer to a free chunk is attempted freed again.
The pointer doesn't make sense. It's above the area of memory that The pointer doesn't make sense. It's above the area of memory that
malloc knows something about. malloc knows something about.
This could be a pointer from some This could be a pointer from some
.Xr mmap 2 'ed
.Xr mmap 2 'ed
memory. memory.
.Pp .Pp
``junk pointer, too low to make sense.'' ``junk pointer, too low to make sense.''
@ -344,7 +345,7 @@ secondary.
.Pp .Pp
The main difference from other malloc implementations are believed to be that The main difference from other malloc implementations are believed to be that
the free pages are not accessed until allocated. the free pages are not accessed until allocated.
Most malloc implementations will store a data structure containing a,
Most malloc implementations will store a data structure containing a,
possibly double-, linked list in the free chunks of memory, used to tie possibly double-, linked list in the free chunks of memory, used to tie
all the free memory together. all the free memory together.
That is a quite suboptimal thing to do. That is a quite suboptimal thing to do.


+ 2
- 2
src/lib/libc/stdlib/qabs.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: qabs.3,v 1.3 1999/05/16 19:55:16 alex Exp $
.\" $OpenBSD: qabs.3,v 1.4 1999/06/29 18:36:21 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt QABS 3 .Dt QABS 3
@ -50,7 +50,7 @@ The
.Fn qabs .Fn qabs
function function
returns the absolute value of the quad integer returns the absolute value of the quad integer
.Ar j .
.Fa j .
.Sh SEE ALSO .Sh SEE ALSO
.Xr abs 3 , .Xr abs 3 ,
.Xr cabs 3 , .Xr cabs 3 ,


+ 6
- 6
src/lib/libc/stdlib/qdiv.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: qdiv.3,v 1.2 1996/08/19 08:33:41 tholo Exp $
.\" $OpenBSD: qdiv.3,v 1.3 1999/06/29 18:36:21 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt QDIV 3 .Dt QDIV 3
@ -50,15 +50,15 @@ The
.Fn qdiv .Fn qdiv
function function
computes the value computes the value
.Ar num/denom
.Fa num Ns No / Ns Fa denom
and returns the quotient and remainder in a structure named and returns the quotient and remainder in a structure named
.Ar qdiv_t
.Li qdiv_t
that contains two that contains two
.Em quad integer
.Li quad integer
members named members named
.Ar quot
.Fa quot
and and
.Ar rem .
.Fa rem .
.Sh SEE ALSO .Sh SEE ALSO
.Xr div 3 , .Xr div 3 ,
.Xr ldiv 3 , .Xr ldiv 3 ,


+ 2
- 2
src/lib/libc/stdlib/qsort.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: qsort.3,v 1.3 1999/02/27 21:56:00 deraadt Exp $
.\" $OpenBSD: qsort.3,v 1.4 1999/06/29 18:36:22 aaron Exp $
.\" .\"
.Dd June 4, 1993 .Dd June 4, 1993
.Dt QSORT 3 .Dt QSORT 3
@ -131,7 +131,7 @@ The function
.Fn mergesort .Fn mergesort
requires additional memory of size requires additional memory of size
.Fa nmemb * .Fa nmemb *
.Fa size
.Fa size
bytes; it should be used only when space is not at a premium. bytes; it should be used only when space is not at a premium.
.Fn mergesort .Fn mergesort
is optimized for data with pre-existing order; its worst case is optimized for data with pre-existing order; its worst case


+ 6
- 5
src/lib/libc/stdlib/radixsort.3 View File

@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: radixsort.3,v 1.4 1998/06/15 17:55:08 mickey Exp $
.\" $OpenBSD: radixsort.3,v 1.5 1999/06/29 18:36:22 aaron Exp $
.\" .\"
.Dd January 27, 1994 .Dd January 27, 1994
.Dt RADIXSORT 3 .Dt RADIXSORT 3
@ -62,8 +62,7 @@ is denoted by the user-specified value
Applications may specify a sort order by providing the Applications may specify a sort order by providing the
.Fa table .Fa table
argument. argument.
If
.Pf non- Dv NULL ,
If non-null,
.Fa table .Fa table
must reference an array of must reference an array of
.Dv UCHAR_MAX .Dv UCHAR_MAX
@ -80,7 +79,9 @@ equally, for example, providing a table with the same weights
for A-Z as for a-z will result in a case-insensitive sort. for A-Z as for a-z will result in a case-insensitive sort.
If If
.Fa table .Fa table
is NULL, the contents of the array are sorted in ascending order
is
.Dv NULL ,
the contents of the array are sorted in ascending order
according to the according to the
.Tn ASCII .Tn ASCII
order of the byte strings they reference and order of the byte strings they reference and
@ -106,7 +107,7 @@ particular, see D.E. Knuth's Algorithm R and section 5.2.5, exercise 10.
They take linear time relative to the number of bytes in the strings. They take linear time relative to the number of bytes in the strings.
.Sh RETURN VALUES .Sh RETURN VALUES
Upon successful completion 0 is returned. Upon successful completion 0 is returned.
Otherwise, \-1 is returned and the global variable
Otherwise, \-1 is returned and the global variable
.Va errno .Va errno
is set to indicate the error. is set to indicate the error.
.Sh ERRORS .Sh ERRORS


+ 2
- 2
src/lib/libc/stdlib/rand.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: rand.3,v 1.5 1998/11/20 11:18:50 d Exp $
.\" $OpenBSD: rand.3,v 1.6 1999/06/29 18:36:22 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt RAND 3 .Dt RAND 3
@ -81,7 +81,7 @@ The
is a thread-safe version of is a thread-safe version of
.Fn rand . .Fn rand .
Storage for the seed must be provided through the Storage for the seed must be provided through the
.Ar seed
.Fa seed
argument, and needs to have been initialized by the caller. argument, and needs to have been initialized by the caller.
.Sh SEE ALSO .Sh SEE ALSO
.Xr arc4random 3 , .Xr arc4random 3 ,


+ 2
- 2
src/lib/libc/stdlib/rand48.3 View File

@ -9,7 +9,7 @@
.\" of any kind. I shall in no event be liable for anything that happens .\" of any kind. I shall in no event be liable for anything that happens
.\" to anyone/anything when using this software. .\" to anyone/anything when using this software.
.\" .\"
.\" $OpenBSD: rand48.3,v 1.4 1999/03/11 01:35:01 pjanzen Exp $
.\" $OpenBSD: rand48.3,v 1.5 1999/06/29 18:36:22 aaron Exp $
.\" .\"
.Dd October 8, 1993 .Dd October 8, 1993
.Dt RAND48 3 .Dt RAND48 3
@ -27,7 +27,7 @@
.Nd pseudo random number generators and initialization routines .Nd pseudo random number generators and initialization routines
.Sh SYNOPSIS .Sh SYNOPSIS
.Fd #include <stdlib.h> .Fd #include <stdlib.h>
.Ft double
.Ft double
.Fn drand48 void .Fn drand48 void
.Ft double .Ft double
.Fn erand48 "unsigned short xseed[3]" .Fn erand48 "unsigned short xseed[3]"


+ 7
- 7
src/lib/libc/stdlib/random.3 View File

@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: random.3,v 1.7 1999/05/23 14:11:03 aaron Exp $
.\" $OpenBSD: random.3,v 1.8 1999/06/29 18:36:23 aaron Exp $
.\" .\"
.Dd April 19, 1991 .Dd April 19, 1991
.Dt RANDOM 3 .Dt RANDOM 3
@ -42,7 +42,7 @@
.Nd better random number generator; routines for changing generators .Nd better random number generator; routines for changing generators
.Sh SYNOPSIS .Sh SYNOPSIS
.Fd #include <stdlib.h> .Fd #include <stdlib.h>
.Ft long
.Ft long
.Fn random void .Fn random void
.Ft void .Ft void
.Fn srandom "unsigned int seed" .Fn srandom "unsigned int seed"
@ -96,7 +96,7 @@ however,
will by default produce a sequence of numbers that can be duplicated will by default produce a sequence of numbers that can be duplicated
by calling by calling
.Fn srandom .Fn srandom
with
with
.Ql 1 .Ql 1
as the seed. as the seed.
.Pp .Pp
@ -167,16 +167,16 @@ messages are printed on the standard error output.
.Xr rand 3 .Xr rand 3
.Sh STANDARDS .Sh STANDARDS
The The
.Fn random ,
.Fn srandom ,
.Fn initstate ,
.Fn random ,
.Fn srandom ,
.Fn initstate ,
and and
.Fn setstate .Fn setstate
functions conform to functions conform to
.St -xpg4.2 . .St -xpg4.2 .
.Sh HISTORY .Sh HISTORY
These These
functions appeared in
functions appeared in
.Bx 4.2 . .Bx 4.2 .
.Sh BUGS .Sh BUGS
About 2/3 the speed of About 2/3 the speed of


+ 2
- 2
src/lib/libc/stdlib/realpath.3 View File

@ -32,7 +32,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: realpath.3,v 1.4 1999/05/28 01:57:36 aaron Exp $
.\" $OpenBSD: realpath.3,v 1.5 1999/06/29 18:36:23 aaron Exp $
.\" .\"
.Dd February, 16, 1994 .Dd February, 16, 1994
.Dt REALPATH 3 .Dt REALPATH 3
@ -67,7 +67,7 @@ refer to a buffer capable of storing at least
.Dv MAXPATHLEN .Dv MAXPATHLEN
characters. characters.
.Pp .Pp
The
The
.Fn realpath .Fn realpath
function will resolve both absolute and relative paths function will resolve both absolute and relative paths
and return the absolute pathname corresponding to and return the absolute pathname corresponding to


+ 4
- 4
src/lib/libc/stdlib/strtod.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: strtod.3,v 1.3 1999/05/27 20:49:35 aaron Exp $
.\" $OpenBSD: strtod.3,v 1.4 1999/06/29 18:36:23 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt STRTOD 3 .Dt STRTOD 3
@ -50,11 +50,11 @@ string to double
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn strtod .Fn strtod
function converts the initial portion of the string
function converts the initial portion of the string
pointed to by pointed to by
.Fa nptr .Fa nptr
to to
.Em double
.Li double
representation. representation.
.Pp .Pp
The expected form of the string is an optional plus (``+'') or minus The expected form of the string is an optional plus (``+'') or minus
@ -93,7 +93,7 @@ is stored in
If the correct value would cause underflow, zero is If the correct value would cause underflow, zero is
returned and returned and
.Dv ERANGE .Dv ERANGE
is stored in
is stored in
.Va errno . .Va errno .
.Sh ERRORS .Sh ERRORS
.Bl -tag -width Er .Bl -tag -width Er


+ 4
- 4
src/lib/libc/stdlib/strtol.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: strtol.3,v 1.3 1996/08/19 08:33:51 tholo Exp $
.\" $OpenBSD: strtol.3,v 1.4 1999/06/29 18:36:23 aaron Exp $
.\" .\"
.Dd June 25, 1992 .Dd June 25, 1992
.Dt STRTOL 3 .Dt STRTOL 3
@ -59,7 +59,7 @@ function
converts the string in converts the string in
.Fa nptr .Fa nptr
to a to a
.Em long
.Li long
value. value.
The The
.Fn strtoq .Fn strtoq
@ -67,7 +67,7 @@ function
converts the string in converts the string in
.Fa nptr .Fa nptr
to a to a
.Em quad_t
.Li quad_t
value. value.
The conversion is done according to the given The conversion is done according to the given
.Fa base , .Fa base ,
@ -95,7 +95,7 @@ is taken as 10 (decimal) unless the next character is
in which case it is taken as 8 (octal). in which case it is taken as 8 (octal).
.Pp .Pp
The remainder of the string is converted to a The remainder of the string is converted to a
.Em long
.Li long
value in the obvious manner, value in the obvious manner,
stopping at the first character which is not a valid digit stopping at the first character which is not a valid digit
in the given base. in the given base.


+ 4
- 4
src/lib/libc/stdlib/strtoul.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: strtoul.3,v 1.2 1996/08/19 08:33:52 tholo Exp $
.\" $OpenBSD: strtoul.3,v 1.3 1999/06/29 18:36:24 aaron Exp $
.\" .\"
.Dd June 25, 1992 .Dd June 25, 1992
.Dt STRTOUL 3 .Dt STRTOUL 3
@ -59,7 +59,7 @@ function
converts the string in converts the string in
.Fa nptr .Fa nptr
to an to an
.Em unsigned long
.Li unsigned long
value. value.
The The
.Fn strtouq .Fn strtouq
@ -67,7 +67,7 @@ function
converts the string in converts the string in
.Fa nptr .Fa nptr
to a to a
.Em u_quad_t
.Li u_quad_t
value. value.
The conversion is done according to the given The conversion is done according to the given
.Fa base , .Fa base ,
@ -95,7 +95,7 @@ is taken as 10 (decimal) unless the next character is
in which case it is taken as 8 (octal). in which case it is taken as 8 (octal).
.Pp .Pp
The remainder of the string is converted to an The remainder of the string is converted to an
.Em unsigned long
.Li unsigned long
value in the obvious manner, value in the obvious manner,
stopping at the end of the string stopping at the end of the string
or at the first character that does not produce a valid digit or at the first character that does not produce a valid digit


+ 8
- 8
src/lib/libc/stdlib/system.3 View File

@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: system.3,v 1.5 1996/12/11 23:09:53 tholo Exp $
.\" $OpenBSD: system.3,v 1.6 1999/06/29 18:36:24 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt SYSTEM 3 .Dt SYSTEM 3
@ -70,18 +70,18 @@ pointer,
will return non-zero. will return non-zero.
Otherwise, Otherwise,
.Fn system .Fn system
returns the termination status of the shell in the format specified by
returns the termination status of the shell in the format specified by
.Xr waitpid 2 . .Xr waitpid 2 .
.Sh RETURN VALUES
.Sh RETURN VALUES
If a child process cannot be created, or the termination status of If a child process cannot be created, or the termination status of
the shell cannot be obtained,
the shell cannot be obtained,
.Fn system .Fn system
returns -1 and sets
returns \-1 and sets
.Va errno .Va errno
to indicate the error. to indicate the error.
If execution of the shell fails,
If execution of the shell fails,
.Fn system .Fn system
returns the termination status for a program that terminates with a call of
returns the termination status for a program that terminates with a call of
.Fn exit 127 . .Fn exit 127 .
.Sh SEE ALSO .Sh SEE ALSO
.Xr sh 1 , .Xr sh 1 ,
@ -93,6 +93,6 @@ The
.Fn system .Fn system
function function
conforms to conforms to
.St -ansiC
.St -ansiC
and and
.St -p1003.2-92 . .St -p1003.2-92 .

+ 14
- 7
src/lib/libc/stdlib/tsearch.3 View File

@ -23,7 +23,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: tsearch.3,v 1.4 1999/05/10 17:56:28 aaron Exp $
.\" $OpenBSD: tsearch.3,v 1.5 1999/06/29 18:36:24 aaron Exp $
.\" .\"
.Dd June 15, 1997 .Dd June 15, 1997
.Dt TSEARCH 3 .Dt TSEARCH 3
@ -58,7 +58,8 @@ searches for the datum matched by the argument
.Fa key .Fa key
in the binary tree rooted at in the binary tree rooted at
.Fa rootp , .Fa rootp ,
returning a pointer to the datum if it is found and NULL
returning a pointer to the datum if it is found and
.Dv NULL
if it is not. if it is not.
.Pp .Pp
.Fn tsearch .Fn tsearch
@ -68,7 +69,7 @@ except that if no match is found,
.Fa key .Fa key
is inserted into the tree and a pointer to it is returned. If is inserted into the tree and a pointer to it is returned. If
.Fa rootp .Fa rootp
points to a NULL value a new binary search tree is created.
points to a null value a new binary search tree is created.
.Pp .Pp
.Fn tdelete .Fn tdelete
deletes a node from the specified binary search tree and returns deletes a node from the specified binary search tree and returns
@ -89,7 +90,7 @@ and calls the function
on each node. on each node.
.Fa action .Fa action
is called with three arguments: a pointer to the current node, is called with three arguments: a pointer to the current node,
a value from the enum
a value from the enum
.Sy "typedef enum { preorder, postorder, endorder, leaf } VISIT;" .Sy "typedef enum { preorder, postorder, endorder, leaf } VISIT;"
specifying the traversal type, and a node level (where level specifying the traversal type, and a node level (where level
zero is the root of the tree). zero is the root of the tree).
@ -99,16 +100,22 @@ zero is the root of the tree).
.Sh RETURN VALUES .Sh RETURN VALUES
The The
.Fn tsearch .Fn tsearch
function returns NULL if allocation of a new node fails (usually
function returns
.Dv NULL
if allocation of a new node fails (usually
due to a lack of free memory). due to a lack of free memory).
.Pp .Pp
.Fn tfind , .Fn tfind ,
.Fn tsearch , .Fn tsearch ,
and and
.Fn tdelete .Fn tdelete
return NULL if
return
.Dv NULL
if
.Fa rootp .Fa rootp
is NULL or the datum cannot be found.
is
.Dv NULL
or the datum cannot be found.
.Pp .Pp
The The
.Fn twalk .Fn twalk


Loading…
Cancel
Save