On 06/08/2017 03:23 AM, Marc-André Lureau wrote: >> >> Your script differs from Markus', we should figure out if they can be >> merged into one. > > One notable difference is that I abuse expression, instead of type. I didn't > manage to teach spatch about the includes and custom type (--all-includes > didn't work). I just tried with expression and it was happy, I haven't > searched further. > >> >>> ( >>> - g_malloc0(sizeof(*e2)) >>> + g_malloc0(sizeof(*e2)) >> >> Huh? >> >>> | >>> - g_malloc(sizeof(*e2)) >>> + g_malloc(sizeof(*e2)) >> >> Huh? > > That's what I explained in the cover letter, I don't wont those to be > touched, but they would because I abuse expressions...
Ah. So you're writing a multi-pass filter: if it matches the first branch, then don't try later branches; otherwise if it matches the later branch, perform the substitution in the later branch. But that can be written: ( g_malloc0(sizeof(*e2)) | g_malloc(sizeof(*e2)) | - ... + ... ) where you don't have to use -/+ patch form for the lines that you are intentionally leaving unchanged because they are already in the right form and where you therefore don't want any subsequent branches of the pattern to be matched. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature