On Tue, 18 Dec 2018, Timur Tabi wrote:

> I added this line to my Python code:
>
>     print >>sys.stderr, 'Warning: missing \\n on line %s in %s' %
> (p1[0].line, p1[0].file)
>
> and this is what it prints:
>
> Warning: missing \n on line 813 in
> /tmp/cocci_small_output-11011-b5932b-grgf100.c
>
> So it looks like spatch is copying the file to the /tmp directory
> before processing it.  Is there any way to get the original file name,
> grgf100.c?

When you make a change in a file, Coccinelle subsequently works on a file
in /tmp for the changed part.  The line numbers are also not reliable.  It
is better to collect this information before making any changes.

In OCaml, to get the name of the current file you can also use
Coccilib.files(). This returns a list of the files being processed, eg if
you put multiple files on the command line.  I don't know if this is
offerent in python too.

julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to