1SPATCH(1) General Commands Manual SPATCH(1)
2
3
4
6 spatch - apply a semantic patch file to a set of C files
7
8
10 spatch -sp_file <SP> <files> [-o <outfile> ] [-iso_file <iso> ] [
11 options ]
12
14 spatch is a program matching and transformation tool for C. The pro‐
15 grammer describes the code to match and the transformation to perform
16 as a semantic patch, which looks like a standard patch, but can trans‐
17 form multiple files at any number of code sites.
18
19
20 Further information about spatch is available at http://coc‐
21 cinelle.lip6.fr/.
22
23
25 Here is a summary of the most commonly used options:
26
27
28 -sp_file <file>
29 the semantic patch file
30
31 -dir <dir>
32 process all files in directory recursively
33
34 -iso_file <file>
35 (default=/usr/share/coccinelle/standard.iso)
36
37 -macro_file <file>
38 (default=/usr/share/coccinelle/standard.h)
39
40 -debug print some information to help debug the matching process
41
42 -all_includes
43 causes all available include files to be used
44
45 -no_includes
46 causes not even local include files to be used
47
48 -I <dir>
49 the directory containing the include files
50
51 -include_headers
52 process header files independently
53
54 -use_glimpse
55 works with -dir, use information generated by glimpseindex
56
57 -o <file>
58 the output file. If none is specified, a patch is generated on
59 the standard output
60
61 -in_place
62 do the modification on the file directly
63
64 -out_place
65 store modifications in a .cocci_res file
66
67 -version
68 show the version of spatch
69
70 -date show the date on which spatch was compiled
71
72 -shorthelp
73 see short list of options
74
75 -longhelp
76 see all the available options in different categories
77
78 -help, --help
79 show summary of options.
80
81
82
83
85 ./spatch -sp_file foo.cocci foo.c
86
87 Apply the semantic patch foo.cocci to the C file foo.c. The semantic
88 patch is applied modulo a set of isomorphisms contained in standard.iso
89 (standard.iso is by default located in /usr/share/coccinelle/stan‐
90 dard.iso). A patch showing the effect of the application, if any, will
91 be generated on the standard output.
92
93 ./spatch -sp_file foo.cocci foo.c -o /tmp/newfoo.c
94
95 The same as the above, except that a modified version of foo.c is
96 stored in /tmp/newfoo.c.
97
98 It is also possible to apply spatch to all of the C files in a direc‐
99 tory:
100
101 ./spatch -cocci_file foo.cocci -dir foodir
102
103 If the semantic patch is not working as expected, the option -debug
104 shows selection of information about the application of a semantic
105 patch to a file or directory.
106
107
109 /usr/share/coccinelle/standard.iso
110 This file contains the default set of isomorphisms.
111 /usr/share/coccinelle/standard.h
112 This file contains the default set of macro hints.
113
114
116 COCCINELLE_HOME
117 The path to coccinelle share directory. Defaut is
118 /usr/share/coccinelle
119
120
122 Y. Padioleau, J.L. Lawall, R.R Hansen, G. Muller "Documenting and
123 Automating Collateral Evolutions in Linux Device Driver" EuroSys 2008,
124 Glasgow, Scotland (April 2008) pp. 247-260.
125
126
128 spatch was written by Julia Lawall <julia@diku.dk>, Yoann Padioleau
129 <yoann.padioleau@gmail.com>, Rene Rydhof Hansen <rrhansen@diku.dk> and
130 Henrik Stuart <henrik@hstuart.dk>.
131
132 This manual page was written by Yoann Padioleau <yoann.padi‐
133 oleau@gmail.com> and Julia Lawall <julia@diku.dk>.
134
135
137 Send a mail to <cocci@diku.dk>
138
139
141 Copyright 2010, University of Copenhagen DIKU and INRIA. Copyright
142 2005-2009, Ecole des Mines de Nantes, University of Copenhagen. spatch
143 is free software: you can redistribute it and/or modify it under the
144 terms of the GNU General Public License as published by the Free Soft‐
145 ware Foundation, according to version 2 of the License.
146
147
149 patch(1), diff(1)
150
151
152
153
154 January 28, 2010 SPATCH(1)