It's a tool for manipulating C source code. Sure, you can search & replace using your favourite editor, sed or awk, but Coccinelle really understands C.
For example, if x is an integer, replace if (!x) with if (x == 0)
These script are works-in-progress. Use with caution. They may, or may not, get used in the NeoMutt project.
| Coccinelle Script | Test C | Description |
|---|---|---|
| dprint | source | Replace Mutt's dprint() with NeoMutt's mutt_debug() |
| if-assignment | source | Split up if statements containing an assignment |
| not-pointer | source | Only allow if (x) for bools and pointers |
| not-swap | source | Swap if (!x) clauses |
| null-check | source | Replace if (x == NULL) with if (x) |
| prototypes | source | Highlight missing argument names in function prototypes |
| rename-function | Rename a function, reordering the arguments | |
| scoped-for-variable | source | Reduce the scope of a for loop variable |
| set-pointer-null | Set all pointers to NULL when declared | |
| strcmp | Test strcmp-like functions against 0 | |
| tidy-return | Simplify return statements |
Unless otherwise stated, these scripts and samples are copyrighted by Richard Russon (flatcap) and released under the GPLv2.
- Home: http://coccinelle.lip6.fr/
- Scripts: http://coccinellery.org/
- Source: https://github.com/coccinelle/coccinelle
- Grep-like tool: https://github.com/regit/coccigrep