coccilib.report.print_report Broken For Redirected STDOUT
Hello!
coccilib.report.print_report is not producing any output when STDOUT is redirected to a file or a pipe. I have attached a simple test case.
spatch cocciprint.cocci cocciprint.c
cocciprint.c:3:8-9: Printing Suceeded
spatch cocciprint.cocci cocciprint.c > /tmp/nothing wc -c /tmp/nothing
0 /tmp/nothing
thanks
bye
michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cocciprint.c
Type: text/x-csrc
Size: 42 bytes
Desc: not available
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20170211/5020f4c4/attachment.bin>
-------------- next part --------------
@r@
identifier i;
position p;
@@
int i at p;
@ script:python @
p << r.p;
@@coccilib.report.print_report(p[0], "Printing Suceeded")
Quoted 11 lines · Michael Stefaniuc
Hello!
coccilib.report.print_report is not producing any output when STDOUT is redirected to a file or a pipe. I have attached a simple test case.
spatch
cocciprint.coccicocciprint.c
cocciprint.c:3:8-9: Printing Suceededspatch
cocciprint.coccicocciprint.c>/tmp/nothingwc -c/tmp/nothing
0/tmp/nothing
Thanks for the report. Will have it looked into.
julia
Quoted 6 lines
thanks
bye
michael
Hello!
Michael:
Quoted 3 lines
Quoted 3 lines
spatch
cocciprint.coccicocciprint.c>/tmp/nothingwc -c/tmp/nothing
0/tmp/nothing
Standard output gets buffered when redirected to a file and not flushed as quickly as it is when there is no redirection: it is not specific to coccilib.report.print_report and the same observation can be obtained by just calling "print".
I just committed a simple fix on GitHub: standard outputs are now flushed at the end of the processing of code transformation.
Thanks for the report. Best regards.
Signature · 3 lines
Thierry. Julia Lawall (2017/02/11, 19:20 UTC)?:
Quoted 28 lines · Michael Stefaniuc
Quoted 6 lines
Hello!
coccilib.report.print_report is not producing any output when STDOUT is redirected to a file or a pipe. I have attached a simple test case.
Quoted 6 lines
spatch
cocciprint.coccicocciprint.c
cocciprint.c:3:8-9: Printing Suceededspatch
cocciprint.coccicocciprint.c>/tmp/nothingwc -c/tmp/nothing
0/tmp/nothingThanks for the report. Will have it looked into.
julia
Quoted 6 lines
thanks
bye
michael_______________________________________________
Cocci mailing list
Cocci at systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 7 lines · Thierry Martinez
Hello!
Michael:
Quoted 3 lines
Quoted 3 lines
spatch
cocciprint.coccicocciprint.c>/tmp/nothingwc -c/tmp/nothing
0/tmp/nothing
Quoted 7 lines
Standard output gets buffered when redirected to a file and not flushed as quickly as it is when there is no redirection: it is not specific to coccilib.report.print_report and the same observation can be obtained by just calling "print".
I just committed a simple fix on GitHub: standard outputs are now flushed at the end of the processing of code transformation.
Thanks Thierry, that fixes the issue.
bye
michael