modifying C99 initializers?
Hi all,
I'm trying to do something like this:
@@
identifier list;
@@
struct my_struct list[] = {
<...
{
+ .field = 27,
},
...>
};
where "field" is a new struct member and I want it initialized everywhere.
The above doesn't parse, but is there another way of doing it?
The expected output would be
struct my_struct xyz[] = {
{
+ .field = 27,
.other_field = 7,
},
{
+ .field = 27,
.third_field = 8,
},
};Thanks,
johannes
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 30 lines · Johannes Berg
Hi all,
I'm trying to do something like this:
@@
identifier list;
@@
structmy_structlist[] = {
<...
{
+ .field = 27,
},
...>
};where "field" is a new struct member and I want it initialized everywhere.
The above doesn't parse, but is there another way of doing it?
The expected output would be
struct my_struct xyz[] = { {(quoted diff) +1
-0+ .field = 27,.other_field = 7, }, {(quoted diff) +1
-0+ .field = 27,
Quoted 3 lines
.third_field = 8, }, };
Try without the <... ...>.
julia
Quoted 10 lines
Thanks,
johannes
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 12 lines · Julia Lawall
Quoted 11 lines
@@
identifier list;
@@
structmy_structlist[] = {
<...
{
+ .field = 27,
},
...>
};
Quoted 1 line
Try without the <... ...>.
I did :-)
If I just remove the <... ...> then it only changes an array that has a single entry. If I add ... at the end, it only changes the first entry.
johannes
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 13 lines · Johannes Berg
Quoted 11 lines · Julia Lawall
Quoted 11 lines
@@
identifier list;
@@
structmy_structlist[] = {
<...
{
+ .field = 27,
},
...>
};
Quoted 6 lines
Quoted 1 line
Try without the <... ...>.
I did :-)
If I just remove the <... ...> then it only changes an array that has a single entry. If I add ... at the end, it only changes the first entry.
OK, how about ... before and after?
julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 15 lines · Julia Lawall
Quoted 12 lines · Johannes Berg
Quoted 11 lines · Julia Lawall
Quoted 11 lines
@@
identifier list;
@@
structmy_structlist[] = {
<...
{
+ .field = 27,
},
...>
};
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Try without the <... ...>.
I did :-)
If I just remove the <... ...> then it only changes an array that has a single entry. If I add ... at the end, it only changes the first entry.
OK, how about ... before and after?
Huh. I was going to say I tried this, but apparently I didn't since it actually works!
Thanks!
johannes
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 20 lines · Johannes Berg
Quoted 19 lines · Julia Lawall
Quoted 16 lines · Johannes Berg
Quoted 11 lines · Julia Lawall
Quoted 11 lines
@@
identifier list;
@@
structmy_structlist[] = {
<...
{
+ .field = 27,
},
...>
};Quoted 1 line
Try without the <... ...>.
I did :-)
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
If I just remove the <... ...> then it only changes an array that has a single entry. If I add ... at the end, it only changes the first entry.
OK, how about ... before and after?
Huh. I was going to say I tried this, but apparently I didn't since it actually works!
If it is .x = e, I think it would have worked without any kind of ... at all. But array elements are ordered, so the ... are needed. The pattern matches multiple times, one time for each array element.
julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci