On Tue, Feb 21, 2017 at 11:24 PM, Julia Lawall wrote: > > > > On Tue, 21 Feb 2017, Gargi Sharma wrote: > > > Hi, > > > > Here's my coccinelle script to parentheses around the right hand side of an > > assignment. > > > > @@ expression e, e1, e2; @@ > > e = > > -( > > e1 + e2 > > -) > > > > @@ expression e, e1, e2; @@ > > e = > > -( > > e1 - e2 > > -) > > > > @@ expression e, e1; > > contant c; @@ > > e = > > -( > > e1 << c > > -) > > > > @@ expression e, e1; > > constant c; @@ > > e = > > -( > > e1 >> c > > -) > > It looks reasonable. I don't think you need to restrict the right side of > >> and << to constants, though. > > Also, the whole thing can actually be much shorter, because there is a > "binary operator" metavariable type. So you could say: > > @@ > binary operator bop = {+,-,>>,<<}; > expression e, e1, e2; > @@ Awesome! This makes the patch so much more concise. > > e = > - ( > e1 bop e2 > - ) > > Although, your version is probably more readable, because "bop" doesn't > really look like a binary operator. > > Did you try, eg > > e = > - (e1 + e2) > + e1 + e2 > > ? This is not a good solution, but it could be good to think about why. I tried this after reading this mail :). I think it's not a good solution because of the false positives that it will give. Also for the cases where there's no space around '+' will be replaced as well which is not the intended use case for the patch. And all the cases where we have shifted the operands to avoid the 80 character limit, will all be moved on the same line. gargi > > julia > > > thanks, > > gargi > > > > -- > > You received this message because you are subscribed to the Google Groups > > "outreachy-kernel" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to outreachy-kernel+unsubscribe@googlegroups.com. > > To post to this group, send email to outreachy-kernel@googlegroups.com. > > To view this discussion on the web visithttps://groups.google.com /d/msgid/outreachy-kernel/CAOCi2DHM%2BX0ksQZ2ZBXPk > > bJu5uv5kerHRpaJaFEG8C36CA72jA%40mail.gmail.com. > > For more options, visit https://groups.google.com/d/optout. > > > > > > -- > You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. > To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com. > To post to this group, send email to outreachy-kernel@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/ms gid/outreachy-kernel/alpine.DEB.2.20.1702211850270.3448%40hadrien. > For more options, visit https://groups.google.com/d/optout.