On Thu, 28 Jul 2016, SF Markus Elfring wrote:
> > Did you try it?
>
> Yes.
>
> elfring@Sonne:~/Projekte/Linux/next-patched> spatch.opt -sp-file
> ~/Projekte/Coccinelle/janitor/show_lengths_for_if_statements2.cocci
> drivers/staging/ks7010/ks7010_sdio.c
> init_defs_builtins: /usr/local/lib64/coccinelle/standard.h
> minus: parse error:
> File
> "/home/elfring/Projekte/Coccinelle/janitor/show_lengths_for_if_statements2.cocci",
> line 6, column 4, charpos = 89
> around = 'is',
> whole content = is
>
>
> > I think you would need braces around is and es.
>
> Another SmPL approach:
>
> @lengths@
> statement list [if_count] isl;
> statement list [else_count] esl;
> @@
> if (...)
> { isl }
> else
> { esl }
>
> @script:python display@
> if_n << lengths.if_count;
> else_n << lengths.else_count;
> @@
> print("{0}|{1}".format(if_n, else_n))
>
>
> elfring@Sonne:~/Projekte/Linux/next-patched> spatch.opt -sp-file
> ~/Projekte/Coccinelle/janitor/show_lengths_for_if_statements3.cocci
> drivers/staging/ks7010/ks7010_sdio.c
> init_defs_builtins: /usr/local/lib64/coccinelle/standard.h
> Cannot resolve PyUnicodeUCS2_AsEncodedString.
>
>
> How should this surprise be fixed?
Make clean, or maybe make distclean.
>
>
> > Otherwise, the result would always be 1, because there can only be one
> > statement in each branch of an if.
>
> Can the number of "steps" that were stored by a metavariable of the
> type "statement" also be determined anyhow?
No idea what you mean by steps. A statement metavariable only matches a
single statement.
julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci