diff options
Diffstat (limited to 'src/lib/libc/stdlib')
| -rw-r--r-- | src/lib/libc/stdlib/getopt.3 | 25 | ||||
| -rw-r--r-- | src/lib/libc/stdlib/getopt_long.3 | 29 |
2 files changed, 52 insertions, 2 deletions
diff --git a/src/lib/libc/stdlib/getopt.3 b/src/lib/libc/stdlib/getopt.3 index f261edcab7..0a28fa9e60 100644 --- a/src/lib/libc/stdlib/getopt.3 +++ b/src/lib/libc/stdlib/getopt.3 | |||
| @@ -29,7 +29,7 @@ | |||
| 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 30 | .\" SUCH DAMAGE. | 30 | .\" SUCH DAMAGE. |
| 31 | .\" | 31 | .\" |
| 32 | .\" $OpenBSD: getopt.3,v 1.18 2002/12/04 20:31:30 millert Exp $ | 32 | .\" $OpenBSD: getopt.3,v 1.19 2002/12/04 21:42:22 millert Exp $ |
| 33 | .\" | 33 | .\" |
| 34 | .Dd April 19, 1994 | 34 | .Dd April 19, 1994 |
| 35 | .Dt GETOPT 3 | 35 | .Dt GETOPT 3 |
| @@ -126,6 +126,29 @@ When all options have been processed (i.e., up to the first non-option | |||
| 126 | argument), | 126 | argument), |
| 127 | .Fn getopt | 127 | .Fn getopt |
| 128 | returns \-1. | 128 | returns \-1. |
| 129 | .Sh RETURN VALUES | ||
| 130 | The | ||
| 131 | .Fn getopt | ||
| 132 | function returns the next known option character in | ||
| 133 | .Fa optstring . | ||
| 134 | If | ||
| 135 | .Fn getopt | ||
| 136 | encounters a character not found in | ||
| 137 | .Fa optstring | ||
| 138 | or if it detects a missing option argument, | ||
| 139 | it returns | ||
| 140 | .Sq ? . | ||
| 141 | If | ||
| 142 | .Fa optstring | ||
| 143 | has a leading | ||
| 144 | .Sq \: | ||
| 145 | then a missing option argument causes | ||
| 146 | .Sq \: | ||
| 147 | to be returned instead of | ||
| 148 | .Sq ? . | ||
| 149 | The | ||
| 150 | .Fn getopt | ||
| 151 | function returns \-1 when the argument list is exhausted. | ||
| 129 | .Sh EXAMPLES | 152 | .Sh EXAMPLES |
| 130 | .Bd -literal -compact | 153 | .Bd -literal -compact |
| 131 | int bflag, ch, fd; | 154 | int bflag, ch, fd; |
diff --git a/src/lib/libc/stdlib/getopt_long.3 b/src/lib/libc/stdlib/getopt_long.3 index d55f4ead53..cfbe255e6c 100644 --- a/src/lib/libc/stdlib/getopt_long.3 +++ b/src/lib/libc/stdlib/getopt_long.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $OpenBSD: getopt_long.3,v 1.1 2002/12/03 20:24:30 millert Exp $ | 1 | .\" $OpenBSD: getopt_long.3,v 1.2 2002/12/04 21:42:22 millert Exp $ |
| 2 | .\" $NetBSD: getopt_long.3,v 1.11 2002/10/02 10:54:19 wiz Exp $ | 2 | .\" $NetBSD: getopt_long.3,v 1.11 2002/10/02 10:54:19 wiz Exp $ |
| 3 | .\" | 3 | .\" |
| 4 | .\" Copyright (c) 1988, 1991, 1993 | 4 | .\" Copyright (c) 1988, 1991, 1993 |
| @@ -163,6 +163,33 @@ If an option starting with | |||
| 163 | .Sq - | 163 | .Sq - |
| 164 | does not match a long option but does match a single-character option, | 164 | does not match a long option but does match a single-character option, |
| 165 | the single-character option is returned. | 165 | the single-character option is returned. |
| 166 | .Sh RETURN VALUES | ||
| 167 | If the | ||
| 168 | .Fa flag | ||
| 169 | field in | ||
| 170 | .Li struct option | ||
| 171 | is | ||
| 172 | .Dv NULL , | ||
| 173 | .Fn getopt_long | ||
| 174 | and | ||
| 175 | .Fn getopt_long_only | ||
| 176 | return the value specified in the | ||
| 177 | .Fa val | ||
| 178 | field, which is usually just the corresponding short option. | ||
| 179 | If | ||
| 180 | .Fa flag | ||
| 181 | is not | ||
| 182 | .Dv NULL , | ||
| 183 | these functions return 0 and store | ||
| 184 | .Fa val | ||
| 185 | in the location pointed to by | ||
| 186 | .Fa flag . | ||
| 187 | These functions return | ||
| 188 | .Sq \: | ||
| 189 | if there was a missing option argument, | ||
| 190 | .Sq ? | ||
| 191 | if the user specified an unknown or ambiguous option, and | ||
| 192 | \-1 when the argument list has been exhausted. | ||
| 166 | .Sh EXAMPLES | 193 | .Sh EXAMPLES |
| 167 | .Bd -literal -compact | 194 | .Bd -literal -compact |
| 168 | int bflag, ch, fd; | 195 | int bflag, ch, fd; |
