test-operator-cleanup 785 B

123456789101112131415161718192021222324
  1. #!/usr/bin/perl -w -p -i
  2. #
  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
  8. # This script looks for instances of C comparison operators as macro arguments,
  9. # and replaces them with our OP_* equivalents.
  10. #
  11. # Some macros that take operators are our tt_int_op() testing macro, and the
  12. # standard timercmp() macro. Coccinelle can't handle their syntax, however,
  13. # unless we give them their operators as a macro too.
  14. next if m#^ */\*# or m#^ *\* #;
  15. s/<([,)])/OP_LT$1/;
  16. s/(?<=[\s,])>([,)])/OP_GT$1/;
  17. #s/>([,)])/OP_GT$1/;
  18. s/==([,)])/OP_EQ$1/;
  19. s/>=([,)])/OP_GE$1/;
  20. s/<=([,)])/OP_LE$1/;
  21. s/!=([,)])/OP_NE$1/;