permit multiline comments and strings in macros
[bpt/coccinelle.git] / demos / proc_info.cocci
1 @ rule1 @
2 identifier buffer, start, offset, length, inout, hostno;
3 identifier hostptr;
4 identifier proc_info_func;
5 @@
6 proc_info_func (
7 + struct Scsi_Host *hostptr,
8 char *buffer, char **start, off_t offset, int length,
9 - int hostno,
10 int inout) {
11 ...
12 - struct Scsi_Host *hostptr;
13 ...
14 - hostptr = scsi_host_hn_get(hostno);
15 ...
16 ?- if (!hostptr) { ... return ...; }
17 ...
18 ?- scsi_host_put(hostptr);
19 ...
20 }
21
22 //alt:
23 //- proc_info_func(char *buffer, char **start, off_t offset, int length,
24 //- int hostno, int inout)
25 //+ proc_info_func(struct Scsi_Host *hostptr, char *buffer, char **start,
26 //+ off_t offset, int length, int inout)
27 //{
28
29
30
31 @@
32 identifier rule1.proc_info_func;
33 identifier rule1.hostno;
34 @@
35 proc_info_func(...) {
36 <...
37 - hostno
38 + hostptr->host_no
39 ...>
40 }
41
42 @@
43 identifier func;
44 expression buffer, start, offset, length, inout, hostno;
45 identifier hostptr;
46 identifier rule1.proc_info_func;
47 @@
48
49 func(..., struct Scsi_Host *hostptr, ...) {
50 <...
51 proc_info_func(
52 + hostptr,
53 buffer, start, offset, length,
54 - hostno,
55 inout)
56 ...>
57 }