summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/getsubopt.3
diff options
context:
space:
mode:
authorjaredy <>2005-10-11 01:23:41 +0000
committerjaredy <>2005-10-11 01:23:41 +0000
commite1d1b24354f52fc5c2530e9ea0bb3b597ad92fc5 (patch)
tree95ce29f3d0d95146fb733032126b399636d5c963 /src/lib/libc/stdlib/getsubopt.3
parent532c08f68e843a46a28fff0ae07e92866af2da42 (diff)
downloadopenbsd-e1d1b24354f52fc5c2530e9ea0bb3b597ad92fc5.tar.gz
openbsd-e1d1b24354f52fc5c2530e9ea0bb3b597ad92fc5.tar.bz2
openbsd-e1d1b24354f52fc5c2530e9ea0bb3b597ad92fc5.zip
tidy up examples
- use err() for error handling - add lint hints - spacing nits and missing braces ok otto
Diffstat (limited to 'src/lib/libc/stdlib/getsubopt.3')
-rw-r--r--src/lib/libc/stdlib/getsubopt.312
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lib/libc/stdlib/getsubopt.3 b/src/lib/libc/stdlib/getsubopt.3
index d0308e2d50..6a7c28ff4d 100644
--- a/src/lib/libc/stdlib/getsubopt.3
+++ b/src/lib/libc/stdlib/getsubopt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: getsubopt.3,v 1.10 2005/07/26 04:20:23 jaredy Exp $ 1.\" $OpenBSD: getsubopt.3,v 1.11 2005/10/11 01:23:41 jaredy Exp $
2.\" 2.\"
3.\" Copyright (c) 1990, 1991, 1993 3.\" Copyright (c) 1990, 1991, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
@@ -104,15 +104,15 @@ char *tokens[] = {
104extern char *optarg, *suboptarg; 104extern char *optarg, *suboptarg;
105char *options, *value; 105char *options, *value;
106 106
107while ((ch = getopt(argc, argv, "ab:")) != \-1) { 107while ((ch = getopt(argc, argv, "ab:")) != -1) {
108 switch(ch) { 108 switch (ch) {
109 case 'a': 109 case 'a':
110 /* process ``a'' option */ 110 /* process ``a'' option */
111 break; 111 break;
112 case 'b': 112 case 'b':
113 options = optarg; 113 options = optarg;
114 while (*options) { 114 while (*options) {
115 switch(getsubopt(&options, tokens, &value)) { 115 switch (getsubopt(&options, tokens, &value)) {
116 case ONE: 116 case ONE:
117 /* process ``one'' sub option */ 117 /* process ``one'' sub option */
118 break; 118 break;
@@ -122,16 +122,18 @@ while ((ch = getopt(argc, argv, "ab:")) != \-1) {
122 error("no value for two"); 122 error("no value for two");
123 i = atoi(value); 123 i = atoi(value);
124 break; 124 break;
125 case \-1: 125 case -1:
126 if (suboptarg) 126 if (suboptarg)
127 error("illegal sub option %s", 127 error("illegal sub option %s",
128 suboptarg); 128 suboptarg);
129 else 129 else
130 error("missing sub option"); 130 error("missing sub option");
131 break; 131 break;
132 }
132 } 133 }
133 break; 134 break;
134 } 135 }
136}
135.Ed 137.Ed
136.Sh SEE ALSO 138.Sh SEE ALSO
137.Xr getopt 3 , 139.Xr getopt 3 ,