Markup improvements. No need to mark up numbers as defined values, math
did the definition for us ages ago. Make HTML-ready.
This commit is contained in:
parent
42d3e7ca09
commit
f6b43a0c43
@ -1,4 +1,4 @@
|
|||||||
.\" $NetBSD: strtol.3,v 1.23 2009/05/20 22:01:34 christos Exp $
|
.\" $NetBSD: strtol.3,v 1.24 2009/05/21 09:13:35 wiz 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,7 +41,7 @@
|
|||||||
.Nm strtoll ,
|
.Nm strtoll ,
|
||||||
.Nm strtoimax ,
|
.Nm strtoimax ,
|
||||||
.Nm strtoq
|
.Nm strtoq
|
||||||
.Nd "convert string value to a long, long long, intmax_t or quad_t integer"
|
.Nd convert string value to a long, long long, intmax_t or quad_t integer
|
||||||
.Sh LIBRARY
|
.Sh LIBRARY
|
||||||
.Lb libc
|
.Lb libc
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
@ -68,7 +68,7 @@ function
|
|||||||
converts the string in
|
converts the string in
|
||||||
.Fa nptr
|
.Fa nptr
|
||||||
to a
|
to a
|
||||||
.Em long int
|
.Ft long int
|
||||||
value.
|
value.
|
||||||
The
|
The
|
||||||
.Fn strtoll
|
.Fn strtoll
|
||||||
@ -76,7 +76,7 @@ function
|
|||||||
converts the string in
|
converts the string in
|
||||||
.Fa nptr
|
.Fa nptr
|
||||||
to a
|
to a
|
||||||
.Em long long int
|
.Ft long long int
|
||||||
value.
|
value.
|
||||||
The
|
The
|
||||||
.Fn strtoimax
|
.Fn strtoimax
|
||||||
@ -84,7 +84,7 @@ function
|
|||||||
converts the string in
|
converts the string in
|
||||||
.Fa nptr
|
.Fa nptr
|
||||||
to an
|
to an
|
||||||
.Em intmax_t
|
.Ft intmax_t
|
||||||
value.
|
value.
|
||||||
The
|
The
|
||||||
.Fn strtoq
|
.Fn strtoq
|
||||||
@ -92,7 +92,7 @@ function
|
|||||||
converts the string in
|
converts the string in
|
||||||
.Fa nptr
|
.Fa nptr
|
||||||
to a
|
to a
|
||||||
.Em quad_t
|
.Ft quad_t
|
||||||
value.
|
value.
|
||||||
The conversion is done according to the given
|
The conversion is done according to the given
|
||||||
.Fa base ,
|
.Fa base ,
|
||||||
@ -135,7 +135,7 @@ representing 35.)
|
|||||||
.Pp
|
.Pp
|
||||||
If
|
If
|
||||||
.Fa endptr
|
.Fa endptr
|
||||||
is non nil,
|
is non-nil,
|
||||||
.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 .
|
||||||
@ -192,8 +192,7 @@ argument is not supported then
|
|||||||
.Va errno
|
.Va errno
|
||||||
is set to
|
is set to
|
||||||
.Er EINVAL
|
.Er EINVAL
|
||||||
and the functions return
|
and the functions return 0.
|
||||||
.Dv 0 .
|
|
||||||
.Sh EXAMPLES
|
.Sh EXAMPLES
|
||||||
Ensuring that a string is a valid number (i.e., in range and containing no
|
Ensuring that a string is a valid number (i.e., in range and containing no
|
||||||
trailing characters) requires clearing
|
trailing characters) requires clearing
|
||||||
@ -212,10 +211,10 @@ long lval;
|
|||||||
\&...
|
\&...
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
lval = strtol(buf, &ep, 10);
|
lval = strtol(buf, \*[Am]ep, 10);
|
||||||
if (buf[0] == '\e0' || *ep != '\e0')
|
if (buf[0] == '\e0' || *ep != '\e0')
|
||||||
goto not_a_number;
|
goto not_a_number;
|
||||||
if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
|
if (errno == ERANGE \*[Am]\*[Am] (lval == LONG_MAX || lval == LONG_MIN))
|
||||||
goto out_of_range;
|
goto out_of_range;
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
@ -248,25 +247,20 @@ long lval;
|
|||||||
\&...
|
\&...
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
lval = strtol(buf, &ep, 10);
|
lval = strtol(buf, \*[Am]ep, 10);
|
||||||
if (buf[0] == '\e0' || *ep != '\e0')
|
if (buf[0] == '\e0' || *ep != '\e0')
|
||||||
goto not_a_number;
|
goto not_a_number;
|
||||||
if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN)) ||
|
if ((errno == ERANGE \*[Am]\*[Am] (lval == LONG_MAX || lval == LONG_MIN)) ||
|
||||||
(lval > INT_MAX || lval < INT_MIN))
|
(lval \*[Gt] INT_MAX || lval \*[Lt] INT_MIN))
|
||||||
goto out_of_range;
|
goto out_of_range;
|
||||||
ival = lval;
|
ival = lval;
|
||||||
.Ed
|
.Ed
|
||||||
.Sh ERRORS
|
.Sh ERRORS
|
||||||
.Bl -tag -width Er
|
.Bl -tag -width Er
|
||||||
.It Bq Er EINVAL
|
.It Bq Er EINVAL
|
||||||
The
|
The
|
||||||
.Ar base
|
.Ar base
|
||||||
is not between
|
is not between 2 and 36 and does not contain the special value 0.
|
||||||
.Dv 2
|
|
||||||
and
|
|
||||||
.Dv 36
|
|
||||||
and does not contain the special value
|
|
||||||
.Dv 0.
|
|
||||||
.It Bq Er ERANGE
|
.It Bq Er ERANGE
|
||||||
The given string was out of range; the value converted has been clamped.
|
The given string was out of range; the value converted has been clamped.
|
||||||
.El
|
.El
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
.\" $NetBSD: strtoul.3,v 1.20 2009/05/20 22:01:34 christos Exp $
|
.\" $NetBSD: strtoul.3,v 1.21 2009/05/21 09:13:35 wiz 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,7 +41,7 @@
|
|||||||
.Nm strtoull ,
|
.Nm strtoull ,
|
||||||
.Nm strtoumax ,
|
.Nm strtoumax ,
|
||||||
.Nm strtouq
|
.Nm strtouq
|
||||||
.Nd "convert a string to an unsigned long, unsigned long long, uintmax_t or uquad_t integer"
|
.Nd convert a string to an unsigned long, unsigned long long, uintmax_t or uquad_t integer
|
||||||
.Sh LIBRARY
|
.Sh LIBRARY
|
||||||
.Lb libc
|
.Lb libc
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
@ -68,7 +68,7 @@ function
|
|||||||
converts the string in
|
converts the string in
|
||||||
.Fa nptr
|
.Fa nptr
|
||||||
to an
|
to an
|
||||||
.Em unsigned long int
|
.Ft unsigned long int
|
||||||
value.
|
value.
|
||||||
The
|
The
|
||||||
.Fn strtoull
|
.Fn strtoull
|
||||||
@ -76,7 +76,7 @@ function
|
|||||||
converts the string in
|
converts the string in
|
||||||
.Fa nptr
|
.Fa nptr
|
||||||
to an
|
to an
|
||||||
.Em unsigned long long int
|
.Ft unsigned long long int
|
||||||
value.
|
value.
|
||||||
The
|
The
|
||||||
.Fn strtoumax
|
.Fn strtoumax
|
||||||
@ -84,7 +84,7 @@ function
|
|||||||
converts the string in
|
converts the string in
|
||||||
.Fa nptr
|
.Fa nptr
|
||||||
to an
|
to an
|
||||||
.Em uintmax_t
|
.Ft uintmax_t
|
||||||
value.
|
value.
|
||||||
The
|
The
|
||||||
.Fn strtouq
|
.Fn strtouq
|
||||||
@ -92,7 +92,7 @@ function
|
|||||||
converts the string in
|
converts the string in
|
||||||
.Fa nptr
|
.Fa nptr
|
||||||
to a
|
to a
|
||||||
.Em u_quad_t
|
.Ft 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 ,
|
||||||
@ -136,7 +136,7 @@ representing 35.)
|
|||||||
.Pp
|
.Pp
|
||||||
If
|
If
|
||||||
.Fa endptr
|
.Fa endptr
|
||||||
is non nil,
|
is non-nil,
|
||||||
.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 .
|
||||||
@ -190,8 +190,7 @@ argument is not supported then
|
|||||||
.Va errno
|
.Va errno
|
||||||
is set to
|
is set to
|
||||||
.Er EINVAL
|
.Er EINVAL
|
||||||
and the functions return
|
and the functions return 0.
|
||||||
.Dv 0 .
|
|
||||||
.Sh EXAMPLES
|
.Sh EXAMPLES
|
||||||
Ensuring that a string is a valid number (i.e., in range and containing no
|
Ensuring that a string is a valid number (i.e., in range and containing no
|
||||||
trailing characters) requires clearing
|
trailing characters) requires clearing
|
||||||
@ -210,10 +209,10 @@ unsigned long ulval;
|
|||||||
\&...
|
\&...
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
ulval = strtoul(buf, &ep, 10);
|
ulval = strtoul(buf, \*[Am]ep, 10);
|
||||||
if (buf[0] == '\e0' || *ep != '\e0')
|
if (buf[0] == '\e0' || *ep != '\e0')
|
||||||
goto not_a_number;
|
goto not_a_number;
|
||||||
if (errno == ERANGE && ulval == ULONG_MAX)
|
if (errno == ERANGE \*[Am]\*[Am] ulval == ULONG_MAX)
|
||||||
goto out_of_range;
|
goto out_of_range;
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
@ -230,14 +229,9 @@ alternately, use
|
|||||||
.Sh ERRORS
|
.Sh ERRORS
|
||||||
.Bl -tag -width Er
|
.Bl -tag -width Er
|
||||||
.It Bq Er EINVAL
|
.It Bq Er EINVAL
|
||||||
The
|
The
|
||||||
.Ar base
|
.Ar base
|
||||||
is not between
|
is not between 2 and 36 and does not contain the special value 0.
|
||||||
.Dv 2
|
|
||||||
and
|
|
||||||
.Dv 36
|
|
||||||
and does not contain the special value
|
|
||||||
.Dv 0.
|
|
||||||
.It Bq Er ERANGE
|
.It Bq Er ERANGE
|
||||||
The given string was out of range; the value converted has been clamped.
|
The given string was out of range; the value converted has been clamped.
|
||||||
.El
|
.El
|
||||||
|
Loading…
Reference in New Issue
Block a user