spatch (1) Linux Manual Page
spatch – apply a semantic patch file to a set of C files
Synopsis
spatch -sp_file <SP> <files> [-o <outfile> ] [-iso_file <iso> ] [ options ]Description
spatch is a program matching and transformation tool for C. The programmer describes the code to match and the transformation to perform as a semantic patch, which looks like a standard patch, but can transform multiple files at any number of code sites.Further information about spatch is available at http://www.emn.fr/x-info/coccinelle.
Options
Here is a summary of the most commonly used options:- -sp_file <file>
- the semantic patch file
- -dir <dir>
- process all files in directory recursively
- -iso_file <file>
- (default=/usr/local/share/coccinelle/standard.iso)
- -macro_file <file>
- (default=/usr/local/share/coccinelle/standard.h)
- -debug
- print some information to help debug the matching process
- -all_includes
- causes all available include files to be used
- -no_includes
- causes not even local include files to be used
- -I <dir>
- the directory containing the include files
- -include_headers
- process header files independently
- -use_glimpse
- works with -dir, use information generated by glimpseindex
- -o <file>
- the output file. If none is specified, a patch is generated on the standard output
- -inplace
- do the modification on the file directly
- -outplace
- store modifications in a .cocci_res file
- -version
- show the version of spatch
- -date
- show the date on which spatch was compiled
- -shorthelp
- see short list of options
- -longhelp
- see all the available options in different categories
- -help, –help
- show summary of options.
Examples
Apply the semantic patch foo.cocci to the C file foo.c. The semantic patch is applied modulo a set of isomorphisms contained in standard.iso (standard.iso is by default located in /usr/local/share/coccinelle/standard.iso). A patch showing the effect of the application, if any, will be generated on the standard output.
The same as the above, except that a modified version of foo.c is stored in /tmp/newfoo.c.
It is also possible to apply spatch to all of the C files in a directory:
If the semantic patch is not working as expected, the option -debug shows selection of information about the application of a semantic patch to a file or directory.
Files
/usr/local/share/coccinelle/standard.iso- This file contains the default set of isomorphisms.
/usr/local/share/coccinelle/standard.h
- This file contains the default set of macro hints.
Environment
- COCCINELLE_HOME
- The path to coccinelle share directory. Defaut is /usr/local/share/coccinelle
References
Y. Padioleau, J.L. Lawall, R.R Hansen, G. Muller "Documenting and Automating Collateral Evolutions in Linux Device Driver" EuroSys 2008, Glasgow, Scotland (April 2008) pp. 247-260.Author
spatch was written by Julia Lawall <julia [at] diku.dk>, Yoann Padioleau <yoann.padioleau [at] gmail.com>, Rene Rydhof Hansen <rrhansen [at] diku.dk> and Henrik Stuart <henrik [at] hstuart.dk>.This manual page was written by Yoann Padioleau <yoann.padioleau [at] gmail.com> and Julia Lawall <julia [at] diku.dk>.
