Re: [PATCH 01/10] cleanup: Remove the duplicate header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 17/04/13 10:50, Eric Blake wrote:
On 04/16/2013 07:41 AM, Osier Yang wrote:
Detected by a simple Shell script:

for i in $(find -type f -name "*.[ch]" | grep -v gnulib); do
You can limit things to version-controlled files a bit faster with:

for i in $(git ls-files -- '*.[ch]'); do

Nice.


     awk 'BEGIN {
         FS=" "
         fail=0
     }
     /^# *include.*\.h[">]$/{
This pattern misses files that include a header with a comment saying
why, such as this one:

src/util/virxml.c:#include <math.h>               /* for isnan() */


         arr[$NF]++
This doesn't catch duplication between "" and <> in the same file, since
it includes the delimiter as part of the key name.  Slightly more
powerful is:

/# *include/{
     match($0, /["<][^">]*[">]/)
     arr[substr($0, RSTART+1, RLENGTH-2)]++
}

Nice too. But it detects:

2 "virsh-edit.c" are included
Duplicate header(s) in virsh-domain.c

I changed it a bit to avoid it:

/# *include.*\.h/{
    match($0, /["<][^">]*[">]/)
    arr[substr($0, RSTART+1, RLENGTH-2)]++
}

Osier

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]