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
8e4b51ad
Commit
8e4b51ad
authored
Nov 11, 2014
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cdump: handle , at end of enums.
Signed-off-by:
Rusty Russell
<
rusty@rustcorp.com.au
>
parent
158691ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
ccan/cdump/cdump.c
ccan/cdump/cdump.c
+4
-0
ccan/cdump/test/run-enum-comma.c
ccan/cdump/test/run-enum-comma.c
+34
-0
No files found.
ccan/cdump/cdump.c
View file @
8e4b51ad
...
...
@@ -428,6 +428,10 @@ static bool tok_take_enum(struct parse_state *ps)
do
{
struct
cdump_enum_val
*
v
;
/* GCC extension: comma and end of enum */
if
(
tok_is
(
&
ps
->
toks
,
"}"
))
break
;
tal_resize
(
&
e
->
u
.
enum_vals
,
n
+
1
);
v
=
&
e
->
u
.
enum_vals
[
n
++
];
...
...
ccan/cdump/test/run-enum-comma.c
0 → 100644
View file @
8e4b51ad
#include <ccan/cdump/cdump.h>
/* Include the C files directly. */
#include <ccan/cdump/cdump.c>
#include <ccan/tap/tap.h>
int
main
(
void
)
{
struct
cdump_definitions
*
defs
;
const
struct
cdump_type
*
t
;
char
*
problems
;
/* This is how many tests you plan to run */
plan_tests
(
12
);
defs
=
cdump_extract
(
NULL
,
"enum foo { BAR, BAZ, };"
,
&
problems
);
ok1
(
defs
);
ok1
(
!
problems
);
ok1
(
strmap_empty
(
&
defs
->
structs
));
ok1
(
strmap_empty
(
&
defs
->
unions
));
t
=
strmap_get
(
&
defs
->
enums
,
"foo"
);
ok1
(
t
);
ok1
(
t
->
kind
==
CDUMP_ENUM
);
ok1
(
streq
(
t
->
name
,
"foo"
));
ok1
(
tal_count
(
t
->
u
.
enum_vals
)
==
2
);
ok1
(
streq
(
t
->
u
.
enum_vals
[
0
].
name
,
"BAR"
));
ok1
(
!
t
->
u
.
enum_vals
[
0
].
value
);
ok1
(
streq
(
t
->
u
.
enum_vals
[
1
].
name
,
"BAZ"
));
ok1
(
!
t
->
u
.
enum_vals
[
1
].
value
);
tal_free
(
defs
);
/* This exits depending on whether all tests passed */
return
exit_status
();
}
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