On Sat, 20 Dec 2014, Eliseo Martínez wrote:
> Great. That worked. Just one more thing, please.
> Some of the replacements done by the rule before leave literals of the form
> “(uintmax_t)34”.
> I would like to use an unsigned constant in those cases. This is, something
> like “34u”.
> So I add the following rule:
>
> ```
> @@ expression e1, e3; constant c2; @@
> 30
> 31 - put_bytes(e1, (uintmax_t)c2, e3)
> 32 + put_bytes(e1, c2, e3)
> ```
>
> That does the work, except adding the “u”. How could I do that?
> Is it possible adding something literally in the output?
> Is it possible to somehow say in line 32 “render c2 but with u suffix”?
It is possible, but somewhat awkward. Here is a simpler example that you
can adapt to your case:
@r@
typedef uintmax_t;
constant c;
@@
(uintmax_t)c
@script:python s@
c << r.c;
cu;
@@
coccinelle.cu = "%su" % (c)
@@
constant r.c;
identifier s.cu;
@@
- (uintmax_t)c
+ cu
julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci