Browse Source

Flesh out stdlib function man pages.

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

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

@ -1,4 +1,3 @@
.\"
.\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> .\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
.\" All rights reserved. .\" All rights reserved.
.\" .\"
@ -24,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: a64l.3,v 1.4 1999/06/29 18:36:15 aaron Exp $
.\" $OpenBSD: a64l.3,v 1.5 2000/04/20 13:50:01 aaron Exp $
.\" .\"
.Dd August 17, 1997 .Dd August 17, 1997
.Dt A64L 3 .Dt A64L 3
@ -46,9 +45,9 @@ 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
.Tn ASCII .Tn ASCII
characters. This is a notation by which 32-bit integers
can be represented by up to six characters; each character
represents a
characters.
This is a notation by which 32-bit integers
can be represented by up to six characters; each character represents a
.Dq digit .Dq digit
in a radix-64 notation. in a radix-64 notation.
.Pp .Pp
@ -73,14 +72,16 @@ for 38-63.
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
.Fa 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.
.Fn a64l .Fn a64l
scans the character string from left to right, decoding scans the character string from left to right, decoding
each character as a 6-bit radix-64 number. If a long integer is
each character as a 6-bit radix-64 number.
If a long integer is
larger than 32 bits, the return value will be sign-extended. larger than 32 bits, the return value will be sign-extended.
.Pp .Pp
.Fn l64a .Fn l64a


+ 4
- 7
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.5 1999/06/29 18:36:17 aaron Exp $
.\" $OpenBSD: abort.3,v 1.6 2000/04/20 13:50:01 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt ABORT 3 .Dt ABORT 3
@ -48,8 +48,7 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn abort .Fn abort
function causes abnormal program termination to occur, unless the
signal
function causes abnormal program termination to occur, unless the signal
.Dv SIGABRT .Dv SIGABRT
is being caught and the signal handler does not return. is being caught and the signal handler does not return.
.Pp .Pp
@ -57,14 +56,12 @@ Any open streams are flushed and closed.
.Sh RETURN VALUES .Sh RETURN VALUES
The The
.Fn abort .Fn abort
function
never returns.
function never returns.
.Sh SEE ALSO .Sh SEE ALSO
.Xr sigaction 2 , .Xr sigaction 2 ,
.Xr exit 3 .Xr exit 3
.Sh STANDARDS .Sh STANDARDS
The The
.Fn abort .Fn abort
function
conforms to
function conforms to
.St -p1003.1-90 . .St -p1003.1-90 .

+ 3
- 7
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.4 1999/06/29 18:36:17 aaron Exp $
.\" $OpenBSD: abs.3,v 1.5 2000/04/20 13:50:01 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt ABS 3 .Dt ABS 3
@ -48,16 +48,12 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn abs .Fn abs
function
computes
the absolute value of the integer
function computes the absolute value of the integer
.Fa j . .Fa j .
.Sh RETURN VALUES .Sh RETURN VALUES
The The
.Fn abs .Fn abs
function
returns
the absolute value.
function returns the absolute value.
.Sh SEE ALSO .Sh SEE ALSO
.Xr cabs 3 , .Xr cabs 3 ,
.Xr floor 3 , .Xr floor 3 ,


+ 4
- 7
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.7 1999/06/29 18:36:18 aaron Exp $
.\" $OpenBSD: alloca.3,v 1.8 2000/04/20 13:50:01 aaron Exp $
.\" .\"
.Dd May 2, 1991 .Dd May 2, 1991
.Dt ALLOCA 3 .Dt ALLOCA 3
@ -44,12 +44,10 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn alloca .Fn alloca
function
allocates
function 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
return.
This temporary space is automatically freed on return.
.Sh RETURN VALUES .Sh RETURN VALUES
The The
.Fn alloca .Fn alloca
@ -63,8 +61,7 @@ function returns a pointer to the beginning of the allocated space.
.Sh BUGS .Sh BUGS
The The
.Fn alloca .Fn alloca
function
is machine dependent; its use is discouraged.
function is machine dependent; its use is discouraged.
.\" .Sh HISTORY .\" .Sh HISTORY
.\" The .\" The
.\" .Fn alloca .\" .Fn alloca


+ 3
- 5
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.3 1999/06/29 18:36:18 aaron Exp $
.\" $OpenBSD: atexit.3,v 1.4 2000/04/20 13:50:01 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt ATEXIT 3 .Dt ATEXIT 3
@ -48,8 +48,7 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn atexit .Fn atexit
function
registers the given
function registers the given
.Fa 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
@ -72,6 +71,5 @@ The existing list of functions is unmodified.
.Sh STANDARDS .Sh STANDARDS
The The
.Fn atexit .Fn atexit
function
conforms to
function conforms to
.St -ansiC . .St -ansiC .

+ 3
- 2
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.4 1999/09/13 07:14:13 deraadt Exp $
.\" $OpenBSD: atoi.3,v 1.5 2000/04/20 13:50:01 aaron Exp $
.\" .\"
.Dd June 4, 1993 .Dd June 4, 1993
.Dt ATOI 3 .Dt ATOI 3
@ -66,7 +66,8 @@ does no overflow checking, handles unsigned numbers poorly,
and handles strings containing trailing extra characters and handles strings containing trailing extra characters
(like (like
.Dq "123abc" Ns ) .Dq "123abc" Ns )
poorly. Careful use of
poorly.
Careful use of
.Xr strtol 3 .Xr strtol 3
and and
.Xr strtoul 3 .Xr strtoul 3


+ 2
- 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.3 1999/06/29 18:36:19 aaron Exp $
.\" $OpenBSD: atol.3,v 1.4 2000/04/20 13:50:01 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt ATOL 3 .Dt ATOL 3
@ -69,6 +69,5 @@ strtol(nptr, (char **)NULL, 10);
.Sh STANDARDS .Sh STANDARDS
The The
.Fn atol .Fn atol
function
conforms to
function conforms to
.St -ansiC . .St -ansiC .

+ 2
- 4
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.4 1999/06/29 18:36:19 aaron Exp $
.\" $OpenBSD: bsearch.3,v 1.5 2000/04/20 13:50:01 aaron Exp $
.\" .\"
.Dd April 19, 1994 .Dd April 19, 1994
.Dt BSEARCH 3 .Dt BSEARCH 3
@ -63,9 +63,7 @@ to the comparison function referenced by
.Fa compar . .Fa compar .
The The
.Fa compar .Fa compar
routine
is expected to have
two arguments which point to the
routine is expected to have two arguments which point to the
.Fa key .Fa key
object and to an array member, in that order, and should return an integer object and to an array member, in that order, and should return an integer
less than, equal to, or greater than zero if the less than, equal to, or greater than zero if the


+ 3
- 5
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.4 1999/06/29 18:36:19 aaron Exp $
.\" $OpenBSD: div.3,v 1.5 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd April 19, 1991 .Dd April 19, 1991
.Dt DIV 3 .Dt DIV 3
@ -46,8 +46,7 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn div .Fn div
function
computes the value
function computes the value
.Fa num Ns No / Ns Fa 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
@ -64,6 +63,5 @@ and
.Sh STANDARDS .Sh STANDARDS
The The
.Fn div .Fn div
function
conforms to
function conforms to
.St -ansiC . .St -ansiC .

+ 5
- 6
src/lib/libc/stdlib/exit.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: exit.3,v 1.3 1999/02/27 21:55:55 deraadt Exp $
.\" $OpenBSD: exit.3,v 1.4 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt EXIT 3 .Dt EXIT 3
@ -46,8 +46,9 @@
.Ft void .Ft void
.Fn exit "int status" .Fn exit "int status"
.Sh DESCRIPTION .Sh DESCRIPTION
The
.Fn exit .Fn exit
terminates a process.
function terminates a process.
.Pp .Pp
Before termination it performs the following functions in the Before termination it performs the following functions in the
order listed: order listed:
@ -68,8 +69,7 @@ function.
.Sh RETURN VALUES .Sh RETURN VALUES
The The
.Fn exit .Fn exit
function
never returns.
function never returns.
.Sh SEE ALSO .Sh SEE ALSO
.Xr _exit 2 , .Xr _exit 2 ,
.Xr atexit 3 , .Xr atexit 3 ,
@ -78,6 +78,5 @@ never returns.
.Sh STANDARDS .Sh STANDARDS
The The
.Fn exit .Fn exit
function
conforms to
function conforms to
.St -ansiC . .St -ansiC .

+ 12
- 21
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.6 1999/09/06 23:26:30 aaron Exp $
.\" $OpenBSD: getenv.3,v 1.7 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd December 11, 1993 .Dd December 11, 1993
.Dt GETENV 3 .Dt GETENV 3
@ -55,17 +55,13 @@
.Ft void .Ft void
.Fn unsetenv "const char *name" .Fn unsetenv "const char *name"
.Sh DESCRIPTION .Sh DESCRIPTION
These functions set, unset and fetch environment variables from the
host
These functions set, unset, and fetch environment variables from the host
.Em environment list . .Em environment list .
For compatibility with differing environment conventions,
the given arguments
For compatibility with differing environment conventions, the given arguments
.Fa name .Fa name
and and
.Fa value .Fa value
may be appended and prepended,
respectively,
with an equal sign
may be appended and prepended, respectively, with an equal sign
.Dq Li \&= . .Dq Li \&= .
.Pp .Pp
The The
@ -74,8 +70,7 @@ function obtains the current value of the environment variable,
.Fa name . .Fa name .
If the variable If the variable
.Fa name .Fa name
is not in the current environment,
a null pointer is returned.
is not in the current environment, a null pointer is returned.
.Pp .Pp
The The
.Fn setenv .Fn setenv
@ -84,30 +79,27 @@ function inserts or resets the environment variable
in the current environment list. in the current environment list.
If the variable If the variable
.Fa name .Fa name
does not exist in the list,
it is inserted with the given
does not exist in the list, it is inserted with the given
.Fa value . .Fa value .
If the variable does exist, the argument If the variable does exist, the argument
.Fa overwrite .Fa overwrite
is tested; if is tested; if
.Fa overwrite .Fa overwrite
is zero,
the variable is not reset, otherwise it is reset
to the given
is zero, the variable is not reset, otherwise it is reset to the given
.Fa value . .Fa value .
.Pp .Pp
The The
.Fn putenv .Fn putenv
function takes an argument of the form ``name=value'' and is
equivalent to:
function takes an argument of the form
.Ar name Ns No = Ns Ar value
and is equivalent to:
.Bd -literal -offset indent .Bd -literal -offset indent
setenv(name, value, 1); setenv(name, value, 1);
.Ed .Ed
.Pp .Pp
The The
.Fn unsetenv .Fn unsetenv
function
deletes all instances of the variable name pointed to by
function deletes all instances of the variable name pointed to by
.Fa name .Fa name
from the list. from the list.
.Sh RETURN VALUES .Sh RETURN VALUES
@ -117,8 +109,7 @@ and
.Fn putenv .Fn putenv
return zero if successful; otherwise the global variable return zero if successful; otherwise the global variable
.Va errno .Va errno
is set to indicate the error and a
\-1 is returned.
is set to indicate the error and \-1 is returned.
.Pp .Pp
If If
.Fn getenv .Fn getenv


+ 13
- 20
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.12 2000/03/04 22:19:31 aaron Exp $
.\" $OpenBSD: getopt.3,v 1.13 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd April 19, 1994 .Dd April 19, 1994
.Dt GETOPT 3 .Dt GETOPT 3
@ -51,27 +51,25 @@ The
.Fn getopt .Fn getopt
function incrementally parses a command line argument list function incrementally parses a command line argument list
.Fa argv .Fa argv
and returns the next
.Em known
option character.
and returns the next known option character.
An option character is An option character is
.Em known
.Dq known
if it has been specified in the string of accepted option characters, if it has been specified in the string of accepted option characters,
.Fa optstring . .Fa optstring .
.Pp .Pp
The option string The option string
.Fa optstring .Fa optstring
may contain the following elements: individual characters, and
may contain the following elements: individual characters and
characters followed by a colon to indicate an option argument characters followed by a colon to indicate an option argument
is to follow. is to follow.
For example, an option string For example, an option string
.Li "\&""x""
.Qq x
recognizes an option recognizes an option
.Dq Fl x ,
.Fl x ,
and an option string and an option string
.Li "\&""x:""
.Qq Li x:
recognizes an option and argument recognizes an option and argument
.Dq Fl x Ar argument .
.Fl x Ar argument .
It does not matter to It does not matter to
.Fn getopt .Fn getopt
if a following argument has leading whitespace. if a following argument has leading whitespace.
@ -89,12 +87,10 @@ to
.Fn getopt . .Fn getopt .
The variable The variable
.Va optopt .Va optopt
saves the last
.Em known
option character returned by
saves the last known option character returned by
.Fn getopt . .Fn getopt .
.Pp .Pp
The variable
The variables
.Va opterr .Va opterr
and and
.Va optind .Va optind
@ -119,9 +115,7 @@ must be reinitialized.
.Pp .Pp
The The
.Fn getopt .Fn getopt
function
returns \-1
when the argument list is exhausted.
function returns \-1 when the argument list is exhausted.
The interpretation of options in the argument list may be cancelled The interpretation of options in the argument list may be cancelled
by the option by the option
.Ql -- .Ql --
@ -157,9 +151,8 @@ then a missing option argument causes a
to be returned in addition to suppressing any error messages. to be returned in addition to suppressing any error messages.
.Pp .Pp
Option arguments are allowed to begin with Option arguments are allowed to begin with
.Dq Li \- ;
this is reasonable but
reduces the amount of error checking possible.
.Ql - ;
this is reasonable but reduces the amount of error checking possible.
.Sh EXTENSIONS .Sh EXTENSIONS
The The
.Va optreset .Va optreset


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

@ -1,4 +1,4 @@
.\" $OpenBSD: getsubopt.3,v 1.3 1999/06/29 18:36:20 aaron Exp $
.\" $OpenBSD: getsubopt.3,v 1.4 2000/04/20 13:50:02 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.
@ -41,15 +41,14 @@
.Nd get sub options from an argument .Nd get sub options from an argument
.Sh SYNOPSIS .Sh SYNOPSIS
.Fd #include <stdlib.h> .Fd #include <stdlib.h>
.Vt extern char *suboptarg
.Vt extern char *suboptarg;
.Ft int .Ft int
.Fn getsubopt "char **optionp" "char * const *tokens" "char **valuep" .Fn getsubopt "char **optionp" "char * const *tokens" "char **valuep"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn getsubopt .Fn getsubopt
function
parses a string containing tokens delimited by one or more tab, space or
comma
function parses a string containing tokens delimited by one or more
tab, space or comma
.Pq Ql \&, .Pq Ql \&,
characters. characters.
It is intended for use in parsing groups of option arguments provided It is intended for use in parsing groups of option arguments provided
@ -60,22 +59,24 @@ 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 null-terminated
array of pointers to strings.
is a pointer to a null-terminated array of pointers to strings.
.Pp .Pp
The The
.Fn getsubopt .Fn getsubopt
function
returns the zero-based offset of the pointer in the
function returns the zero-based offset of the pointer in the
.Fa tokens .Fa tokens
array referencing a string which matches the first token array referencing a string which matches the first token
in the string, or, \-1 if the string contains no tokens or in the string, or, \-1 if the string contains no tokens or
.Fa tokens .Fa tokens
does not contain a matching string. does not contain a matching string.
.Pp .Pp
If the token is of the form ``name=value'', the location referenced by
If the token is of the form
.Ar name Ns No = Ns Ar value ,
the location referenced by
.Fa valuep .Fa valuep
will be set to point to the start of the ``value'' portion of the token.
will be set to point to the start of the
.Dq value
portion of the token.
.Pp .Pp
On return from On return from
.Fn getsubopt , .Fn getsubopt ,
@ -86,13 +87,12 @@ The external variable
.Fa suboptarg .Fa suboptarg
will be set to point to the start of the current token, or will be set to point to the start of the current token, or
.Dv NULL .Dv NULL
if no
tokens were present.
if no tokens were present.
The argument The argument
.Fa valuep .Fa valuep
will be set to point to the ``value'' portion of the token, or
will be set to point to the value portion of the token, or
.Dv NULL .Dv NULL
if no ``value'' portion was present.
if no value portion was present.
.Sh EXAMPLE .Sh EXAMPLE
.Bd -literal -compact .Bd -literal -compact
char *tokens[] = { char *tokens[] = {


+ 3
- 5
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.4 1999/06/29 18:36:20 aaron Exp $
.\" $OpenBSD: labs.3,v 1.5 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt LABS 3 .Dt LABS 3
@ -48,8 +48,7 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn labs .Fn labs
function
returns the absolute value of the long integer
function returns the absolute value of the long integer
.Fa j . .Fa j .
.Sh SEE ALSO .Sh SEE ALSO
.Xr abs 3 , .Xr abs 3 ,
@ -59,8 +58,7 @@ returns the absolute value of the long integer
.Sh STANDARDS .Sh STANDARDS
The The
.Fn labs .Fn labs
function
conforms to
function conforms to
.St -ansiC . .St -ansiC .
.Sh BUGS .Sh BUGS
The absolute value of the most negative integer remains negative. The absolute value of the most negative integer remains negative.

+ 3
- 5
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.4 1999/06/29 18:36:21 aaron Exp $
.\" $OpenBSD: ldiv.3,v 1.5 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt LDIV 3 .Dt LDIV 3
@ -48,8 +48,7 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn ldiv .Fn ldiv
function
computes the value
function computes the value
.Fa num Ns No / Ns Fa 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
.Li ldiv_t .Li ldiv_t
@ -66,6 +65,5 @@ and
.Sh STANDARDS .Sh STANDARDS
The The
.Fn ldiv .Fn ldiv
function
conforms to
function conforms to
.St -ansiC . .St -ansiC .

+ 3
- 4
src/lib/libc/stdlib/memory.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: memory.3,v 1.4 1999/05/23 14:11:03 aaron Exp $
.\" $OpenBSD: memory.3,v 1.5 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd May 2, 1991 .Dd May 2, 1991
.Dt MEMORY 3 .Dt MEMORY 3
@ -55,8 +55,7 @@
.Fn alloca "size_t size" .Fn alloca "size_t size"
.Sh DESCRIPTION .Sh DESCRIPTION
These functions allocate and free memory for the calling process. These functions allocate and free memory for the calling process.
They are described in the
individual manual pages.
They are described in the individual man pages.
.Sh SEE ALSO .Sh SEE ALSO
.Xr alloca 3 , .Xr alloca 3 ,
.Xr calloc 3 , .Xr calloc 3 ,
@ -65,6 +64,6 @@ individual manual pages.
.Xr realloc 3 .Xr realloc 3
.Sh STANDARDS .Sh STANDARDS
These functions, with the exception of These functions, with the exception of
.Fn alloca
.Fn alloca ,
conform to conform to
.St -ansiC . .St -ansiC .

+ 2
- 3
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.4 1999/06/29 18:36:21 aaron Exp $
.\" $OpenBSD: qabs.3,v 1.5 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt QABS 3 .Dt QABS 3
@ -48,8 +48,7 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn qabs .Fn qabs
function
returns the absolute value of the quad integer
function returns the absolute value of the quad integer
.Fa j . .Fa j .
.Sh SEE ALSO .Sh SEE ALSO
.Xr abs 3 , .Xr abs 3 ,


+ 11
- 11
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.4 1999/06/29 18:36:22 aaron Exp $
.\" $OpenBSD: qsort.3,v 1.5 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd June 4, 1993 .Dd June 4, 1993
.Dt QSORT 3 .Dt QSORT 3
@ -105,7 +105,9 @@ is stable.
.Pp .Pp
The The
.Fn qsort .Fn qsort
function is an implementation of C.A.R. Hoare's ``quicksort'' algorithm,
function is an implementation of C.A.R. Hoare's
.Dq quicksort
algorithm,
a variant of partition-exchange sorting; in particular, see D.E. Knuth's a variant of partition-exchange sorting; in particular, see D.E. Knuth's
Algorithm Q. Algorithm Q.
.Fn qsort .Fn qsort
@ -115,7 +117,9 @@ O N**2 worst-case behavior.
.Pp .Pp
The The
.Fn heapsort .Fn heapsort
function is an implementation of J.W.J. William's ``heapsort'' algorithm,
function is an implementation of J.W.J. William's
.Dq heapsort
algorithm,
a variant of selection sorting; in particular, see D.E. Knuth's Algorithm H. a variant of selection sorting; in particular, see D.E. Knuth's Algorithm H.
.Fn heapsort .Fn heapsort
takes O N lg N worst-case time. takes O N lg N worst-case time.
@ -143,13 +147,11 @@ is faster than
.Fn mergesort .Fn mergesort
is faster than is faster than
.Fn heapsort . .Fn heapsort .
Memory availability and pre-existing order in the data can make this
untrue.
Memory availability and pre-existing order in the data can make this untrue.
.Sh RETURN VALUES .Sh RETURN VALUES
The The
.Fn qsort .Fn qsort
function
returns no value.
function returns no value.
.Pp .Pp
Upon successful completion, Upon successful completion,
.Fn heapsort .Fn heapsort
@ -167,8 +169,7 @@ function succeeds unless:
.It Bq Er EINVAL .It Bq Er EINVAL
The The
.Fa size .Fa size
argument is zero, or,
the
argument is zero, or, the
.Fa size .Fa size
argument to argument to
.Fn mergesort .Fn mergesort
@ -228,6 +229,5 @@ This is no longer true.
.Sh STANDARDS .Sh STANDARDS
The The
.Fn qsort .Fn qsort
function
conforms to
function conforms to
.St -ansiC . .St -ansiC .

+ 6
- 11
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.5 1999/06/29 18:36:22 aaron Exp $
.\" $OpenBSD: radixsort.3,v 1.6 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd January 27, 1994 .Dd January 27, 1994
.Dt RADIXSORT 3 .Dt RADIXSORT 3
@ -49,8 +49,7 @@ The
.Fn radixsort .Fn radixsort
and and
.Fn sradixsort .Fn sradixsort
functions
are implementations of radix sort.
functions are implementations of radix sort.
.Pp .Pp
These functions sort an array of pointers to byte strings, the initial These functions sort an array of pointers to byte strings, the initial
member of which is referenced by member of which is referenced by
@ -66,23 +65,20 @@ If non-null,
.Fa table .Fa table
must reference an array of must reference an array of
.Dv UCHAR_MAX .Dv UCHAR_MAX
+ 1 bytes which contains the sort
weight of each possible byte value.
+ 1 bytes which contains the sort weight of each possible byte value.
The end-of-string byte must have a sort weight of 0 or 255 The end-of-string byte must have a sort weight of 0 or 255
(for sorting in reverse order). (for sorting in reverse order).
More than one byte may have the same sort weight. More than one byte may have the same sort weight.
The The
.Fa table .Fa table
argument
is useful for applications which wish to sort different characters
argument is useful for applications which wish to sort different characters
equally, for example, providing a table with the same weights 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 is
.Dv NULL , .Dv NULL ,
the contents of the array are sorted in ascending order
according to the
the contents of the array are sorted in ascending order according to the
.Tn ASCII .Tn ASCII
order of the byte strings they reference and order of the byte strings they reference and
.Fa endbyte .Fa endbyte
@ -122,8 +118,7 @@ is not 0 or 255.
.Pp .Pp
Additionally, the Additionally, the
.Fn sradixsort .Fn sradixsort
function
may fail and set
function may fail and set
.Va errno .Va errno
for any of the errors specified for the library routine for any of the errors specified for the library routine
.Xr malloc 3 . .Xr malloc 3 .


+ 3
- 5
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.6 1999/06/29 18:36:22 aaron Exp $
.\" $OpenBSD: rand.3,v 1.7 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt RAND 3 .Dt RAND 3
@ -92,13 +92,11 @@ The
.Fn rand .Fn rand
and and
.Fn srand .Fn srand
functions
conform to
functions conform to
.St -ansiC . .St -ansiC .
.Pp .Pp
The The
.Fn rand_r .Fn rand_r
function
conforms to ISO/IEC 9945-1 ANSI/IEEE
function conforms to ISO/IEC 9945-1 ANSI/IEEE
.Pq Dq Tn POSIX .Pq Dq Tn POSIX
Std 1003.1c Draft 10. Std 1003.1c Draft 10.

+ 15
- 11
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.6 1999/09/27 02:00:13 aaron Exp $
.\" $OpenBSD: rand48.3,v 1.7 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd October 8, 1993 .Dd October 8, 1993
.Dt RAND48 3 .Dt RAND48 3
@ -49,12 +49,13 @@
The The
.Fn rand48 .Fn rand48
family of functions generates pseudo-random numbers using a linear family of functions generates pseudo-random numbers using a linear
congruential algorithm working on integers 48 bits in size. The
particular formula employed is
congruential algorithm working on integers 48 bits in size.
The particular formula employed is
r(n+1) = (a * r(n) + c) mod m r(n+1) = (a * r(n) + c) mod m
where the default values are where the default values are
for the multiplicand a = 0xfdeece66d = 25214903917 and for the multiplicand a = 0xfdeece66d = 25214903917 and
the addend c = 0xb = 11. The modulus is always fixed at m = 2 ** 48.
the addend c = 0xb = 11.
The modulus is always fixed at m = 2 ** 48.
r(n) is called the seed of the random number generator. r(n) is called the seed of the random number generator.
.Pp .Pp
For all the six generator routines described next, the first For all the six generator routines described next, the first
@ -63,7 +64,8 @@ computational step is to perform a single iteration of the algorithm.
.Fn drand48 .Fn drand48
and and
.Fn erand48 .Fn erand48
return values of type double. The full 48 bits of r(n+1) are
return values of type double.
The full 48 bits of r(n+1) are
loaded into the mantissa of the returned value, with the exponent set loaded into the mantissa of the returned value, with the exponent set
such that the values produced lie in the interval [0.0, 1.0). such that the values produced lie in the interval [0.0, 1.0).
.Pp .Pp
@ -71,7 +73,8 @@ such that the values produced lie in the interval [0.0, 1.0).
and and
.Fn nrand48 .Fn nrand48
return values of type long in the range return values of type long in the range
[0, 2**31-1]. The high-order (31) bits of
[0, 2**31-1].
The high-order (31) bits of
r(n+1) are loaded into the lower bits of the returned value, with r(n+1) are loaded into the lower bits of the returned value, with
the topmost (sign) bit set to zero. the topmost (sign) bit set to zero.
.Pp .Pp
@ -79,14 +82,15 @@ the topmost (sign) bit set to zero.
and and
.Fn jrand48 .Fn jrand48
return values of type long in the range return values of type long in the range
[-2**31, 2**31-1]. The high-order (32) bits of
r(n+1) are loaded into the returned value.
[-2**31, 2**31-1].
The high-order (32) bits of r(n+1) are loaded into the returned value.
.Pp .Pp
.Fn drand48 , .Fn drand48 ,
.Fn lrand48 , .Fn lrand48 ,
and and
.Fn mrand48 .Fn mrand48
use an internal buffer to store r(n). For these functions
use an internal buffer to store r(n).
For these functions
the initial value of r(0) = 0x1234abcd330e = 20017429951246. the initial value of r(0) = 0x1234abcd330e = 20017429951246.
.Pp .Pp
On the other hand, On the other hand,
@ -118,8 +122,8 @@ also initializes the internal buffer r(n) of
and and
.Fn mrand48 , .Fn mrand48 ,
but here all 48 bits of the seed can be specified in an array of 3 shorts, but here all 48 bits of the seed can be specified in an array of 3 shorts,
where the zeroth member specifies the lowest bits. Again,
the constant multiplicand and addend of the algorithm are
where the zeroth member specifies the lowest bits.
Again, the constant multiplicand and addend of the algorithm are
reset to the default values given above. reset to the default values given above.
.Fn seed48 .Fn seed48
returns a pointer to an array of 3 shorts which contains the old seed. returns a pointer to an array of 3 shorts which contains the old seed.


+ 22
- 17
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.11 2000/04/03 23:23:48 millert Exp $
.\" $OpenBSD: random.3,v 1.12 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd April 19, 1991 .Dd April 19, 1991
.Dt RANDOM 3 .Dt RANDOM 3
@ -56,23 +56,27 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn random .Fn random
function
uses a non-linear additive feedback random number generator employing a
default table of size 31 long integers to return successive pseudo-random
function uses a non-linear additive feedback random number generator employing
a default table of size 31 long integers to return successive pseudo-random
numbers in the range from 0 to (2**31)\-1. numbers in the range from 0 to (2**31)\-1.
The period of this random number generator is very large, approximately The period of this random number generator is very large, approximately
16*((2**31)\-1. 16*((2**31)\-1.
.Pp .Pp
The The
.Fn random Ns / Fn srandom
have (almost) the same calling sequence and initialization properties as
.Fn random
and
.Fn srandom
functions have (almost) the same calling sequence and initialization
properties as
.Xr rand 3 Ns / Xr srand 3 . .Xr rand 3 Ns / Xr srand 3 .
The difference is that The difference is that
.Xr rand .Xr rand
produces a much less random sequence \(em in fact, the low dozen bits produces a much less random sequence \(em in fact, the low dozen bits
generated by rand go through a cyclic pattern. All the bits generated by
generated by rand go through a cyclic pattern.
All the bits generated by
.Fn random .Fn random
are usable. For example,
are usable.
For example,
.Sq Li random()&01 .Sq Li random()&01
will produce a random binary will produce a random binary
value. value.
@ -81,9 +85,10 @@ Unlike
.Xr srand , .Xr srand ,
.Fn srandom .Fn srandom
does not return the old seed; the reason for this is that the amount of does not return the old seed; the reason for this is that the amount of
state information used is much more than a single word. (Two other
routines are provided to deal with restarting/changing random
number generators). Like
state information used is much more than a single word.
(Two other routines are provided to deal with restarting/changing random
number generators).
Like
.Xr rand 3 , .Xr rand 3 ,
however, however,
.Fn random .Fn random
@ -110,28 +115,28 @@ a fixed seed.
The The
.Fn initstate .Fn initstate
routine allows a state array, passed in as an argument, to be initialized routine allows a state array, passed in as an argument, to be initialized
for future use. The size of the state array (in bytes) is used by
for future use.
The size of the state array (in bytes) is used by
.Fn initstate .Fn initstate
to decide how sophisticated a random number generator it should use \(em the to decide how sophisticated a random number generator it should use \(em the
more state, the better the random numbers will be. more state, the better the random numbers will be.
(Current "optimal" values for the amount of state information are (Current "optimal" values for the amount of state information are
8, 32, 64, 128, and 256 bytes; other amounts will be rounded down to 8, 32, 64, 128, and 256 bytes; other amounts will be rounded down to
the nearest known amount. Using less than 8 bytes will cause an error.)
the nearest known amount.
Using less than 8 bytes will cause an error.)
The seed for the initialization (which specifies a starting point for The seed for the initialization (which specifies a starting point for
the random number sequence, and provides for restarting at the same the random number sequence, and provides for restarting at the same
point) is also an argument. point) is also an argument.
The The
.Fn initstate .Fn initstate
function
returns a pointer to the previous state information array.
function returns a pointer to the previous state information array.
.Pp .Pp
Once a state has been initialized, the Once a state has been initialized, the
.Fn setstate .Fn setstate
routine provides for rapid switching between states. routine provides for rapid switching between states.
The The
.Fn setstate .Fn setstate
function
returns a pointer to the previous state array; its
function returns a pointer to the previous state array; its
argument state array is used for further random number generation argument state array is used for further random number generation
until the next call to until the next call to
.Fn initstate .Fn initstate


+ 3
- 4
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.6 1999/07/02 16:57:49 aaron Exp $
.\" $OpenBSD: realpath.3,v 1.7 2000/04/20 13:50:02 aaron Exp $
.\" .\"
.Dd February 16, 1994 .Dd February 16, 1994
.Dt REALPATH 3 .Dt REALPATH 3
@ -56,8 +56,7 @@ and
.Pa /../ .Pa /../
in in
.Fa pathname , .Fa pathname ,
and copies the resulting absolute pathname into
the memory referenced by
and copies the resulting absolute pathname into the memory referenced by
.Fa resolvedname . .Fa resolvedname .
The The
.Fa resolvedname .Fa resolvedname
@ -101,7 +100,7 @@ for any of the errors specified for the library functions
.Xr fchdir 2 , .Xr fchdir 2 ,
.Xr lstat 2 , .Xr lstat 2 ,
.Xr open 2 , .Xr open 2 ,
.Xr readlink 2
.Xr readlink 2 ,
and and
.Xr getcwd 3 . .Xr getcwd 3 .
.Sh CAVEATS .Sh CAVEATS


+ 14
- 11
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.6 2000/03/04 22:19:31 aaron Exp $
.\" $OpenBSD: strtod.3,v 1.7 2000/04/20 13:50:03 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt STRTOD 3 .Dt STRTOD 3
@ -50,18 +50,23 @@ string to double
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn strtod .Fn strtod
function converts the initial portion of the string
pointed to by
function converts the initial portion of the string pointed to by
.Fa nptr .Fa nptr
to to
.Li double .Li double
representation. representation.
.Pp .Pp
The expected form of the string is an optional plus (``+'') or minus
sign (``-'') followed by a sequence of digits optionally containing
The expected form of the string is an optional plus
.Pq Ql +
or minus sign
.Pq Ql -
followed by a sequence of digits optionally containing
a decimal-point character, optionally followed by an exponent. a decimal-point character, optionally followed by an exponent.
An exponent consists of an ``E'' or ``e'', followed by an optional plus
or minus sign, followed by a sequence of digits.
An exponent consists of an
.Sq E
or
.Sq e ,
followed by an optional plus or minus sign, followed by a sequence of digits.
.Pp .Pp
Leading whitespace characters in the string (as defined by the Leading whitespace characters in the string (as defined by the
.Xr isspace 3 .Xr isspace 3
@ -90,8 +95,7 @@ is returned (according to the sign of the value), and
.Er ERANGE .Er ERANGE
is stored in is stored in
.Va errno . .Va errno .
If the correct value would cause underflow, zero is
returned and
If the correct value would cause underflow, zero is returned and
.Er ERANGE .Er ERANGE
is stored in is stored in
.Va errno . .Va errno .
@ -109,6 +113,5 @@ Overflow or underflow occurred.
.Sh STANDARDS .Sh STANDARDS
The The
.Fn strtod .Fn strtod
function
conforms to
function conforms to
.St -ansiC . .St -ansiC .

+ 13
- 21
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.7 2000/03/04 22:19:31 aaron Exp $
.\" $OpenBSD: strtol.3,v 1.8 2000/04/20 13:50:03 aaron Exp $
.\" .\"
.Dd June 25, 1992 .Dd June 25, 1992
.Dt STRTOL 3 .Dt STRTOL 3
@ -46,7 +46,7 @@
.Fd #include <limits.h> .Fd #include <limits.h>
.Ft long .Ft long
.Fn strtol "const char *nptr" "char **endptr" "int base" .Fn strtol "const char *nptr" "char **endptr" "int base"
.Pp
.Fd #include <sys/types.h> .Fd #include <sys/types.h>
.Fd #include <stdlib.h> .Fd #include <stdlib.h>
.Fd #include <limits.h> .Fd #include <limits.h>
@ -55,24 +55,21 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn strtol .Fn strtol
function
converts the string in
function converts the string in
.Fa nptr .Fa nptr
to a to a
.Li long .Li long
value. value.
The The
.Fn strtoq .Fn strtoq
function
converts the string in
function converts the string in
.Fa nptr .Fa nptr
to a to a
.Li 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 ,
which must be a number between 2 and 36 inclusive
or the special value 0.
which must be a number between 2 and 36 inclusive or the special value 0.
.Pp .Pp
The string may begin with an arbitrary amount of whitespace The string may begin with an arbitrary amount of whitespace
(as determined by (as determined by
@ -84,11 +81,9 @@ or
sign. sign.
If If
.Fa base .Fa base
is zero or 16,
the string may then include a
is zero or 16, the string may then include a
.Ql 0x .Ql 0x
prefix,
and the number will be read in base 16; otherwise, a zero
prefix, and the number will be read in base 16; otherwise, a zero
.Fa base .Fa base
is taken as 10 (decimal) unless the next character is is taken as 10 (decimal) unless the next character is
.Ql 0 , .Ql 0 ,
@ -101,8 +96,7 @@ stopping at the first character which is not a valid digit
in the given base. in the given base.
(In bases above 10, the letter (In bases above 10, the letter
.Ql A .Ql A
in either upper or lower case
represents 10,
in either upper or lower case represents 10,
.Ql B .Ql B
represents 11, and so forth, with represents 11, and so forth, with
.Ql Z .Ql Z
@ -110,7 +104,7 @@ representing 35.)
.Pp .Pp
If If
.Fa endptr .Fa endptr
is non nil,
is non-null,
.Fn strtol .Fn strtol
stores the address of the first invalid character in stores the address of the first invalid character in
.Fa *endptr . .Fa *endptr .
@ -132,8 +126,7 @@ on return, the entire string was valid.)
.Sh RETURN VALUES .Sh RETURN VALUES
The The
.Fn strtol .Fn strtol
function
returns the result of the conversion,
function returns the result of the conversion,
unless the value would underflow or overflow. unless the value would underflow or overflow.
If an underflow occurs, If an underflow occurs,
.Fn strtol .Fn strtol
@ -191,8 +184,8 @@ error checking is further complicated because the desired return value is an
.Li int .Li int
rather than a rather than a
.Li long ; .Li long ;
however, on some architectures integers and long integers are the same
size. Thus the following is necessary:
however, on some architectures integers and long integers are the same size.
Thus the following is necessary:
.Bd -literal -offset indent .Bd -literal -offset indent
char *ep; char *ep;
int ival; int ival;
@ -224,8 +217,7 @@ The given string was out of range; the value converted has been clamped.
.Sh STANDARDS .Sh STANDARDS
The The
.Fn strtol .Fn strtol
function
conforms to
function conforms to
.St -ansiC . .St -ansiC .
.Sh BUGS .Sh BUGS
Ignores the current locale. Ignores the current locale.

+ 10
- 18
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.6 2000/03/04 22:19:31 aaron Exp $
.\" $OpenBSD: strtoul.3,v 1.7 2000/04/20 13:50:03 aaron Exp $
.\" .\"
.Dd June 25, 1992 .Dd June 25, 1992
.Dt STRTOUL 3 .Dt STRTOUL 3
@ -55,16 +55,14 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn strtoul .Fn strtoul
function
converts the string in
function converts the string in
.Fa nptr .Fa nptr
to an to an
.Li unsigned long .Li unsigned long
value. value.
The The
.Fn strtouq .Fn strtouq
function
converts the string in
function converts the string in
.Fa nptr .Fa nptr
to a to a
.Li u_quad_t .Li u_quad_t
@ -84,11 +82,9 @@ or
sign. sign.
If If
.Fa base .Fa base
is zero or 16,
the string may then include a
is zero or 16, the string may then include a
.Ql 0x .Ql 0x
prefix,
and the number will be read in base 16; otherwise, a zero
prefix, and the number will be read in base 16; otherwise, a zero
.Fa base .Fa base
is taken as 10 (decimal) unless the next character is is taken as 10 (decimal) unless the next character is
.Ql 0 , .Ql 0 ,
@ -96,14 +92,12 @@ 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
.Li unsigned long .Li unsigned long
value in the obvious manner,
stopping at the end of the string
value in the obvious manner, 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
in the given base. in the given base.
(In bases above 10, the letter (In bases above 10, the letter
.Ql A .Ql A
in either upper or lower case
represents 10,
in either upper or lower case represents 10,
.Ql B .Ql B
represents 11, and so forth, with represents 11, and so forth, with
.Ql Z .Ql Z
@ -111,7 +105,7 @@ representing 35.)
.Pp .Pp
If If
.Fa endptr .Fa endptr
is non nil,
is non-null,
.Fn strtoul .Fn strtoul
stores the address of the first invalid character in stores the address of the first invalid character in
.Fa *endptr . .Fa *endptr .
@ -133,8 +127,7 @@ on return, the entire string was valid.)
.Sh RETURN VALUES .Sh RETURN VALUES
The The
.Fn strtoul .Fn strtoul
function
returns the result of the conversion,
function returns the result of the conversion,
unless the value would overflow, in which case unless the value would overflow, in which case
.Dv ULONG_MAX .Dv ULONG_MAX
is returned and is returned and
@ -206,8 +199,7 @@ The given string was out of range; the value converted has been clamped.
.Sh STANDARDS .Sh STANDARDS
The The
.Fn strtoul .Fn strtoul
function
conforms to
function conforms to
.St -ansiC . .St -ansiC .
.Sh BUGS .Sh BUGS
Ignores the current locale. Ignores the current locale.

+ 5
- 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.6 1999/06/29 18:36:24 aaron Exp $
.\" $OpenBSD: system.3,v 1.7 2000/04/20 13:50:03 aaron Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt SYSTEM 3 .Dt SYSTEM 3
@ -48,8 +48,7 @@
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn system .Fn system
function
hands the argument
function hands the argument
.Fa string .Fa string
to the command interpreter to the command interpreter
.Xr sh 1 . .Xr sh 1 .
@ -63,9 +62,8 @@ and blocking
.Pp .Pp
If If
.Fa string .Fa string
is a
.Dv NULL
pointer,
is
.Dv NULL ,
.Fn system .Fn system
will return non-zero. will return non-zero.
Otherwise, Otherwise,
@ -91,8 +89,7 @@ returns the termination status for a program that terminates with a call of
.Sh STANDARDS .Sh STANDARDS
The The
.Fn system .Fn system
function
conforms to
function conforms to
.St -ansiC .St -ansiC
and and
.St -p1003.2-92 . .St -p1003.2-92 .

+ 5
- 3
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.7 2000/02/25 07:53:09 deraadt Exp $
.\" $OpenBSD: tsearch.3,v 1.8 2000/04/20 13:50:03 aaron Exp $
.\" .\"
.Dd June 15, 1997 .Dd June 15, 1997
.Dt TSEARCH 3 .Dt TSEARCH 3
@ -49,7 +49,8 @@ The
and and
.Fn twalk .Fn twalk
functions manage binary search trees based on algorithms T and D functions manage binary search trees based on algorithms T and D
from Knuth (6.2.2). The comparison function passed in by
from Knuth (6.2.2).
The comparison function passed in by
the user has the same style of return values as the user has the same style of return values as
.Xr strcmp 3 . .Xr strcmp 3 .
.Pp .Pp
@ -67,7 +68,8 @@ is identical to
.Fn tfind .Fn tfind
except that if no match is found, 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


Loading…
Cancel
Save