> Sorry for bugging you again, but I tried to create a rule for cases that
> don't name the struct. E.g.
>   typedef struct {
>       int bar;
>   } foo;
> 
> My problem seems to be, that a struct identifier is an identifier, while
> the newly created type is a type. Hence, my naive approach:
> @@
> type t;
> @@
> -typedef struct {
> +struct t {
>       ...
> }
> - t
> ;
> 
> does not work. And thus far, I couldn't find a way to get around this. I
> suspect there is some subtle trick to make it do what I want but I'm
> just not seeing it.

It's a hack, but you can pass through python or ocaml.

@r@
type t;
@@
typedef struct {
        ...
} t ;

@script:python s@
t << r.t;
i;
@@

coccinelle.i = t

@@
tpye r.t;
identifier s.i;
@@

...

Now in the last rule, you have all the information you need.  You might even
remove eg any trailing _t from t along the way.

julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to