summaryrefslogtreecommitdiff
path: root/test/testargs.c
diff options
context:
space:
mode:
authorgstein <gstein@13f79535-47bb-0310-9956-ffa450edef68>2000-11-25 22:34:04 +0000
committergstein <gstein@13f79535-47bb-0310-9956-ffa450edef68>2000-11-25 22:34:04 +0000
commit73d622ff06d1300b210b87b32686916569212a26 (patch)
tree36708ddee8762ca341ecfec14e0f5496efcf68ff /test/testargs.c
parent5ed029317a11b27499cfd47d9f13164d484f9777 (diff)
downloadlibapr-73d622ff06d1300b210b87b32686916569212a26.tar.gz
add a "default:" case, just to be sure.
print out any additional arguments. factor out the maybe_arg() functionality. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@60793 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testargs.c')
-rw-r--r--test/testargs.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/test/testargs.c b/test/testargs.c
index 0596131c4..3a2bafbec 100644
--- a/test/testargs.c
+++ b/test/testargs.c
@@ -63,6 +63,16 @@
#include <unistd.h>
#endif
+static void maybe_arg(const char *arg)
+{
+ if (arg) {
+ printf(" with %s\n", arg);
+ }
+ else {
+ printf("\n");
+ }
+}
+
int main(int argc, char * const argv[])
{
apr_pool_t *context;
@@ -80,7 +90,7 @@ int main(int argc, char * const argv[])
exit(1);
}
while (apr_getopt(opt, "abc:d::", &data, &optarg) == APR_SUCCESS) {
- switch(data) {
+ switch (data) {
case 'a':
case 'b':
printf("option %c\n", data);
@@ -90,14 +100,17 @@ int main(int argc, char * const argv[])
break;
case 'd':
printf("option %c", data);
- if (optarg) {
- printf(" with %s\n", optarg);
- }
- else {
- printf("\n");
- }
+ maybe_arg(optarg);
+ break;
+ default:
+ printf("unknown option: %c", data);
+ maybe_arg(optarg);
break;
}
}
+
+ while (opt->ind < opt->argc)
+ printf("extra arg: %s\n", opt->argv[opt->ind++]);
+
return 1;
}