X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=build-aux%2Fuseless-if-before-free;h=b8f5a2635e89cf4246bedcbd3e0e4709947b6325;hb=c3631123354a030261b19e206205bbfb973af38b;hp=793c9753e05f1f0ab7841582cef49287e8788f5c;hpb=b3602e85d8c625e8ffc08855b67c0ae11169a5f3;p=gnulib.git diff --git a/build-aux/useless-if-before-free b/build-aux/useless-if-before-free index 793c9753e..b8f5a2635 100755 --- a/build-aux/useless-if-before-free +++ b/build-aux/useless-if-before-free @@ -2,17 +2,15 @@ eval '(exit $?0)' && eval 'exec perl -wST "$0" ${1+"$@"}' & eval 'exec perl -wST "$0" $argv:q' if 0; # Detect instances of "if (p) free (p);". -# Likewise for "if (p != NULL) free (p);". And with braces. -# Also detect "if (NULL != p) free (p);". -# And with 0 in place of NULL. +# Likewise "if (p != 0)", "if (0 != p)", or with NULL; and with braces. -my $VERSION = '2009-04-16 15:57'; # UTC +my $VERSION = '2011-04-20 13:43'; # UTC # The definition above must lie within the first 8 lines in order # for the Emacs time-stamp write hook (at end) to update it. # If you change this file with Emacs, please let the write hook # do its job. Otherwise, update this string manually. -# Copyright (C) 2008, 2009 Free Software Foundation, Inc. +# Copyright (C) 2008-2011 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -63,7 +61,7 @@ detect free-like functions named FOO and BAR. OPTIONS: - --list print only the name of each matching FILE (\0-terminated) + --list print only the name of each matching FILE (\\0-terminated) --name=N add name N to the list of \`free\'-like functions to detect; may be repeated @@ -134,7 +132,7 @@ sub is_NULL ($) while ($line =~ /\b(if\s*\(\s*([^)]+?)(?:\s*!=\s*([^)]+?))?\s*\) # 1 2 3 - (?: \s*$regexp\s*\((?:\s*\([^)]+\))?\s*([^)]+)\)| + (?: \s*$regexp\s*\((?:\s*\([^)]+\))?\s*([^)]+)\)\s*;| \s*\{\s*$regexp\s*\((?:\s*\([^)]+\))?\s*([^)]+)\)\s*;\s*\}))/sxg) { my $all = $1; @@ -181,7 +179,7 @@ free=xfree git grep -l -z "$free *(" \ | xargs -0 useless-if-before-free -l --name="$free" \ | xargs -0 perl -0x3b -pi -e \ - 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL))?\s*\)\s+('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\))/$2/s' + 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL))?\s*\)\s+('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\)\s*;)/$2/s' # Use the following to remove redundant uses of kfree inside braces. # Note that -0777 puts perl in slurp-whole-file mode;