commctrl.h cleanup

Alexandre Julliard julliard at
Thu Sep 4 18:08:42 CDT 2003

"Dimitrie O. Paun" <dimi at> writes:

> I have a lot more changes (cleanup of winnt.h), do you want me to drop
> them all? Fixing _all_ headers is a big task, I don't understand why
> we can't do it in distinct chunks....

Because such large scale changes are a real pain for everybody who has
local changes; we can't really avoid changing every file, but we can
avoid changing every file 10 times. Besides, we'll need a script to
fix winbase.h, so we might as well use it for the others too.

Anyway, just to show it can be done here's the beginning of such a
script; you can do 'fix-includes windef.h winbase.h <files>' and it
will make sure all the files listed include windef.h before winbase.h
without making unnecessary changes. It's not perfect yet, but it sure
beats doing everything by hand...

Alexandre Julliard
julliard at
-------------- next part --------------
# usage: fix-includes file_to_add.h before_file.h <files>

$toadd = shift @ARGV;
$before = shift @ARGV;

# build the dependency list
system("./tools/makedep -fdeps -Iinclude -Idlls/ddraw `find . -name \\*.h`");
open DEPS, "deps" or die "cannot open deps";
while (<DEPS>)
    while (/\\$/) { chop; $_ .= <DEPS>; }
    my ($obj, at deps) = split;
    for (my $i = 0; $i <= $#deps; $i++) { $deps[$i] =~ s/.*\///; }
    my $header = $deps[0];
    foreach my $f (@deps) { $includes{$header}{$f} = 1; }
close DEPS;
unlink "deps";

foreach $file (@ARGV)
    open IN, "$file" or die "cannot open $file";
    @lines = ();
    $added = 0;

    while (<IN>)
        if (/^\s*\#\s*include\s+([<"])(.*)[>"]/)
            my $quote = $1;
            my $incl = $2;

            if ($includes{$incl}{$toadd})
                # the header includes the one we want
                last unless $added;  # not added yet, nothing to do
                next if ($incl eq $toadd);  # don't add it twice
            elsif ($includes{$incl}{$before})
                push @lines, ($quote eq "<") ? "#include <$toadd>\n" : "#include \"$toadd\"\n" unless $added;
                $added = 1;
        push @lines, $_ . "\n";
    close IN;

    if ($added)
        open OUT, ">$" or die "cannot create $";
        print OUT @lines;
        close OUT;
        print "changed $file\n";
        system "chmod --reference=$file $";
        system "diff -u $file $";
        rename "$", "$file";

More information about the wine-devel mailing list