Hi,
I am wondering whether it would be possible for Coccinelle to
automatically remove unnecessary braces as detected by Linux's
checkpatch.pl
For example, here is the original code:
> void Vec3Lerp(vec3_t a, const vec3_t b, const vec3_t c, const float frac)
> {
> int i;
>
> if (frac <= 0.0) {
> for (i = 0; i < 3; i++) {
> a[i] = b[i];
> }
> } else if (frac >= 1.0) {
> for (i = 0; i < 3; i++) {
> a[i] = c[i];
> }
> } else {
> for (i = 0; i < 3; i++) {
> a[i] = b[i] + frac * (c[i] - b[i]);
> }
> }
> }
I would like to automatically translate such code into:
> void Vec3Lerp(vec3_t a, const vec3_t b, const vec3_t c, const float frac)
> {
> int i;
>
> if (frac <= 0.0)
> for (i = 0; i < 3; i++)
> a[i] = b[i];
> else if (frac >= 1.0)
> for (i = 0; i < 3; i++)
> a[i] = c[i];
> else
> for (i = 0; i < 3; i++)
> a[i] = b[i] + frac * (c[i] - b[i]);
> }
Would this be possible, also taking into account the fact that the
single-statement's can be nested? (As in this vector linear
interpolation example given above.)
Thank you.
--
Oliver McFadden.
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)