Merge branch 'maint-0.4.5' into maint-0.4.6
[tor.git] / scripts / coccinelle / test-operator-cleanup
blob28b4d4f588bfb1ae4be52fc73c7c504caa3aedec
1 #!/usr/bin/perl -w -p -i
3 # Copyright (c) 2001 Matej Pfajfar.
4 # Copyright (c) 2001-2004, Roger Dingledine.
5 # Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
6 # Copyright (c) 2007-2019, The Tor Project, Inc.
7 # See LICENSE for licensing information
9 # This script looks for instances of C comparison operators as macro arguments,
10 # and replaces them with our OP_* equivalents.
12 # Some macros that take operators are our tt_int_op() testing macro, and the
13 # standard timercmp() macro. Coccinelle can't handle their syntax, however,
14 # unless we give them their operators as a macro too.
16 next if m#^ */\*# or m#^ *\* #;
18 s/<([,)])/OP_LT$1/;
19 s/(?<=[\s,])>([,)])/OP_GT$1/;
20 #s/>([,)])/OP_GT$1/;
21 s/==([,)])/OP_EQ$1/;
22 s/>=([,)])/OP_GE$1/;
23 s/<=([,)])/OP_LE$1/;
24 s/!=([,)])/OP_NE$1/;