aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorkatherine <shmibs@airen-no-jikken.icu>2019-05-27 18:45:21 -0700
committerkatherine <shmibs@airen-no-jikken.icu>2019-05-27 18:45:21 -0700
commit879d526d7ee7ee7a876f284dac76075e7a7267ae (patch)
treea62bbaf2d70d4772faf34e6d4b7a37cf0f7d1711 /doc
parent9e8912b6d5672333e254e7f3aacff3bf99816dff (diff)
downloadsimple-opt-879d526d7ee7ee7a876f284dac76075e7a7267ae.tar.gz
move stores vals to named union
for c99 compatibility
Diffstat (limited to 'doc')
-rw-r--r--doc/example.c14
-rw-r--r--doc/interface.md20
2 files changed, 17 insertions, 17 deletions
diff --git a/doc/example.c b/doc/example.c
index 324473e..71ce24b 100644
--- a/doc/example.c
+++ b/doc/example.c
@@ -63,32 +63,32 @@ int main(int argc, char **argv)
if (options[i].arg_is_stored) {
switch (options[i].type) {
case SIMPLE_OPT_BOOL:
- printf(", val: %s", options[i].val_bool ? "true" : "false");
+ printf(", val: %s", options[i].val.v_bool ? "true" : "false");
break;
case SIMPLE_OPT_INT:
- printf(", val: %ld", options[i].val_int);
+ printf(", val: %ld", options[i].val.v_int);
break;
case SIMPLE_OPT_UNSIGNED:
- printf(", val: %lu", options[i].val_unsigned);
+ printf(", val: %lu", options[i].val.v_unsigned);
break;
case SIMPLE_OPT_DOUBLE:
- printf(", val: %lf", options[i].val_double);
+ printf(", val: %lf", options[i].val.v_double);
break;
case SIMPLE_OPT_CHAR:
- printf(", val: %c", options[i].val_char);
+ printf(", val: %c", options[i].val.v_char);
break;
case SIMPLE_OPT_STRING:
- printf(", val: %s", options[i].val_string);
+ printf(", val: %s", options[i].val.v_string);
break;
case SIMPLE_OPT_STRING_SET:
printf(", val: %s",
- options[i].string_set[options[i].val_string_set_idx]);
+ options[i].string_set[options[i].val.v_string_set_idx]);
break;
default:
diff --git a/doc/interface.md b/doc/interface.md
index f8d5886..978ecb3 100644
--- a/doc/interface.md
+++ b/doc/interface.md
@@ -52,21 +52,21 @@ the fields which are set by `simple_opt_parse` are:
bool arg_is_stored;
union {
- bool val_bool;
- long val_int;
- unsigned long val_unsigned;
- double val_double;
- char val_char;
- char val_string[SIMPLE_OPT_OPT_ARG_MAX_WIDTH];
- int val_string_set_idx;
- };
+ bool v_bool;
+ long v_int;
+ unsigned long v_unsigned;
+ double v_double;
+ char v_char;
+ char v_string[SIMPLE_OPT_OPT_ARG_MAX_WIDTH];
+ int v_string_set_idx;
+ } val;
```
`was_seen` indicates if this option was encountered during parsing,
-`arg_is_stored` if an argument was passed to the option, and the `val_<type>`
+`arg_is_stored` if an argument was passed to the option, and the `val.v_<type>`
fields contain the value passed (with the correct field to set being determined
by the `type` field shown above) for all but `SIMPLE_OPT_STRING_SET`, for which
-`val_string_set_idx` is set, an index into the `string_set` field's array,
+`val.v_string_set_idx` is set, an index into the `string_set` field's array,
indicating which possibility was matched.
options of the following types: