I suspect that the problem is in delimiter join.
Yes. - Your are right with this view finally.
It seems that I made another nasty software development mistake. I expected a
bit too much from the capabilities of the mentioned method "join".
http://teethgrinder.co.uk/perm.php?a=Python-join-comma-seperated-list
http://stackoverflow.com/questions/497765/python-string-joinlist-on-object-array-rather-than-string-array
http://programming.itags.org/python/42764/
If I add one more data type conversion before passing the constructed value to
it, the following SmPL example works as expected.
elfring@Sonne:~/Projekte/Coccinelle/lokal/demos/return_values> SRC=example1b.c
&& cat $SRC && LINE='-----' && echo $LINE && PAT=select_non_void_functions.cocci
&& cat $PAT && echo $LINE && spatch -sp_file $PAT $SRC
int my_safe_log(char const * text);
int my_status(void);
void my_log(char const * text) {/* Write something ... */}
int my_safe_log(char const * text) { if (!text) return 1; my_log(text); return
0; }
char const * const my_message(void) { return "Surprise!"; }
int my_status(void) { return 1; }
int my_addition(char a, char b);
int my_addition(char a, char b) { return a + b; }
int main(void) { return my_status(); }
-----
@initialize:python@
result = []
delimiter = '|'
@function_declaration@
type t;
identifier f;
position p;
@@
t@p f(...);
@is_void@
identifier function_declaration.f;
@@
void f(...);
@script:python collection depends on !is_void@
typ << function_declaration.t;
fun << function_declaration.f;
places << function_declaration.p;
@@
for place in places:
fields = []
fields.append(fun.ident)
fields.append(typ)
fields.append(place.file)
fields.append(place.line)
fields.append(str(int(place.column) + 1))
result.append(delimiter.join(fields))
@finalize:python@
if result:
result.insert(0, delimiter.join(("function", '"return type"', '"source
file"', "line", "column")))
print("\r\n".join(result))
else:
print("No result for this analysis!")
-----
init_defs_builtins: /usr/share/coccinelle/standard.h
HANDLING: example1b.c
function|"return type"|"source file"|line|column
my_safe_log|int|example1b.c|1|1
my_status|int|example1b.c|2|3
my_addition|int|example1b.c|7|5
I would like to apologise for inappropriate trouble I may have caused in our
discussion recently.
Thanks for your patience and great support.
Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)