Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
e0e921b9
Commit
e0e921b9
authored
Oct 07, 2010
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
opt: remove gratuitous { } in initializers.
A little less typing for users.
parent
1fe7f55b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
19 deletions
+17
-19
ccan/opt/opt.h
ccan/opt/opt.h
+9
-9
ccan/opt/test/utils.c
ccan/opt/test/utils.c
+8
-10
No files found.
ccan/opt/opt.h
View file @
e0e921b9
...
...
@@ -48,7 +48,7 @@ struct opt_table {
* OPT_WITH_ARG()
*/
#define OPT_WITHOUT_ARG(names, cb, arg, desc) \
(names), OPT_CB_NOARG((cb), (arg)), (desc)
{ (names), OPT_CB_NOARG((cb), (arg)), (desc) }
/**
* OPT_WITH_ARG() - macro for initializing long and short option (with arg)
...
...
@@ -83,7 +83,7 @@ struct opt_table {
* OPT_WITHOUT_ARG()
*/
#define OPT_WITH_ARG(name, cb, show, arg, desc) \
(name), OPT_CB_ARG((cb), (show), (arg)), (desc)
{ (name), OPT_CB_ARG((cb), (show), (arg)), (desc) }
/**
* OPT_SUBTABLE() - macro for including another table inside a table.
...
...
@@ -111,13 +111,13 @@ struct opt_table {
* Example:
* static int verbose = 0;
* static struct opt_table opts[] = {
*
{
OPT_WITHOUT_ARG("--verbose", opt_inc_intval, &verbose,
*
"Verbose mode (can be specified more than once)") }
,
*
{
OPT_WITHOUT_ARG("-v", opt_inc_intval, &verbose,
*
"Verbose mode (can be specified more than once)") }
,
*
{
OPT_WITHOUT_ARG("--usage", opt_usage_and_exit,
*
"args...\nA silly test program.",
*
"Print this message.") }
,
* OPT_WITHOUT_ARG("--verbose", opt_inc_intval, &verbose,
*
"Verbose mode (can be specified more than once)")
,
* OPT_WITHOUT_ARG("-v", opt_inc_intval, &verbose,
*
"Verbose mode (can be specified more than once)")
,
* OPT_WITHOUT_ARG("--usage", opt_usage_and_exit,
* "args...\nA silly test program.",
*
"Print this message.")
,
* OPT_ENDTABLE
* };
*
...
...
ccan/opt/test/utils.c
View file @
e0e921b9
...
...
@@ -70,33 +70,31 @@ bool parse_args(int *argc, char ***argv, ...)
struct
opt_table
short_table
[]
=
{
/* Short opts, different args. */
{
OPT_WITHOUT_ARG
(
"-a"
,
test_noarg
,
"a"
,
"Description of a"
)
}
,
{
OPT_WITH_ARG
(
"-b"
,
test_arg
,
show_arg
,
"b"
,
"Description of b"
)
}
,
OPT_WITHOUT_ARG
(
"-a"
,
test_noarg
,
"a"
,
"Description of a"
)
,
OPT_WITH_ARG
(
"-b"
,
test_arg
,
show_arg
,
"b"
,
"Description of b"
)
,
OPT_ENDTABLE
};
struct
opt_table
long_table
[]
=
{
/* Long opts, different args. */
{
OPT_WITHOUT_ARG
(
"--ddd"
,
test_noarg
,
"ddd"
,
"Description of ddd"
)
}
,
{
OPT_WITH_ARG
(
"--eee <filename>"
,
test_arg
,
show_arg
,
"eee"
,
""
)
}
,
OPT_WITHOUT_ARG
(
"--ddd"
,
test_noarg
,
"ddd"
,
"Description of ddd"
)
,
OPT_WITH_ARG
(
"--eee <filename>"
,
test_arg
,
show_arg
,
"eee"
,
""
)
,
OPT_ENDTABLE
};
struct
opt_table
long_and_short_table
[]
=
{
/* Short and long, different args. */
{
OPT_WITHOUT_ARG
(
"--ggg/-g"
,
test_noarg
,
"ggg"
,
"Description of ggg"
)
},
{
OPT_WITH_ARG
(
"-h/--hhh"
,
test_arg
,
NULL
,
"hhh"
,
"Description of hhh"
)
},
OPT_WITHOUT_ARG
(
"--ggg/-g"
,
test_noarg
,
"ggg"
,
"Description of ggg"
),
OPT_WITH_ARG
(
"-h/--hhh"
,
test_arg
,
NULL
,
"hhh"
,
"Description of hhh"
),
OPT_ENDTABLE
};
/* Sub-table test. */
struct
opt_table
subtables
[]
=
{
/* Two short, and two long long, no description */
{
OPT_WITH_ARG
(
"--jjj/-j/--lll/-l"
,
test_arg
,
show_arg
,
"jjj"
,
""
)
}
,
OPT_WITH_ARG
(
"--jjj/-j/--lll/-l"
,
test_arg
,
show_arg
,
"jjj"
,
""
)
,
/* Hidden option */
{
OPT_WITH_ARG
(
"--mmm/-m"
,
test_arg
,
show_arg
,
"mmm"
,
opt_hidden
)
}
,
OPT_WITH_ARG
(
"--mmm/-m"
,
test_arg
,
show_arg
,
"mmm"
,
opt_hidden
)
,
OPT_SUBTABLE
(
short_table
,
NULL
),
OPT_SUBTABLE
(
long_table
,
"long table options"
),
OPT_SUBTABLE
(
long_and_short_table
,
NULL
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment