Commit cec294e4 authored by Patrik Stridvall's avatar Patrik Stridvall Committed by Alexandre Julliard

A few bug fixes.

parent 89a0c02b
...@@ -110,16 +110,16 @@ sub file_normalize { ...@@ -110,16 +110,16 @@ sub file_normalize {
} }
sub file_directory { sub file_directory {
my $file = shift; local $_ = shift;
$file =~ s%^./%%;
my $dir = $file; s%/?[^/]*$%%;
$dir =~ s%/?[^/]*$%%; if(!$_) {
if(!$dir) { $_ = ".";
$dir = ".";
} }
return $dir; s%^(?:\./)?(.*?)(?:/\.)?%$1%;
return $_;
} }
sub _get_files { sub _get_files {
......
...@@ -30,10 +30,30 @@ my $function; ...@@ -30,10 +30,30 @@ my $function;
######################################################################## ########################################################################
sub error { sub error {
my $where = shift;
if(!defined($where)) {
$where = "";
}
my $context;
if($tool) {
$context = "$tool";
if($where) {
$context .= "<$where>";
}
} else {
if($where) {
$context = "<$where>";
} else {
$context = "<>";
}
}
if(defined($tool)) { if(defined($tool)) {
$output->write("make_filter: $tool: can't parse output: '$current'\n"); $output->write("make_filter: $context: can't parse output: '$current'\n");
} else { } else {
$output->write("make_filter: <>: can't parse output: '$current'\n"); $output->write("make_filter: $context: can't parse output: '$current'\n");
} }
exit 1; exit 1;
} }
...@@ -57,20 +77,25 @@ sub line { ...@@ -57,20 +77,25 @@ sub line {
$function = ""; $function = "";
my $progress = "";
if($directory && $directory ne ".") {
$progress .= "$directory: ";
}
$progress .= "$tool: ";
if($tool =~ /^cd|make$/) { if($tool =~ /^cd|make$/) {
# Nothing # Nothing
} elsif($tool =~ /^ld$/) { } elsif($tool =~ /^ld$/) {
foreach my $file (@{$read_files}) { foreach my $file (@{$read_files}) {
$output->lazy_progress("$directory: ld: reading '$file'"); $output->lazy_progress("$progress: reading '$file'");
} }
my $file = $$write_files[0]; my $file = $$write_files[0];
$output->progress("$directory: ld: writing '$file'"); $output->progress("$progress: writing '$file'");
} elsif($tool =~ /^rm$/) { } elsif($tool =~ /^rm$/) {
foreach my $file (@{$remove_files}) { foreach my $file (@{$remove_files}) {
$output->lazy_progress("$directory: rm: removing '$file'"); $output->lazy_progress("$progress: removing '$file'");
} }
} else { } else {
my $progress = "$directory: $tool: ";
if($#$read_files >= 0) { if($#$read_files >= 0) {
$progress .= "read[" . join(" ", @{$read_files}) . "]"; $progress .= "read[" . join(" ", @{$read_files}) . "]";
} }
...@@ -89,6 +114,7 @@ sub line { ...@@ -89,6 +114,7 @@ sub line {
$output->progress($progress); $output->progress($progress);
} }
return 0; return 0;
} }
...@@ -102,7 +128,7 @@ sub line { ...@@ -102,7 +128,7 @@ sub line {
$tool = "make"; $tool = "make";
make_output($1, $_); make_output($1, $_);
} elsif(!defined($tool)) { } elsif(!defined($tool)) {
error(); error("line");
} elsif($tool eq "bison" && /^conflicts:\s+\d+\s+shift\/reduce$/) { } elsif($tool eq "bison" && /^conflicts:\s+\d+\s+shift\/reduce$/) {
# Nothing # Nothing
} elsif($tool eq "gcc" && /^In file included from (.+?):(\d+):$/) { } elsif($tool eq "gcc" && /^In file included from (.+?):(\d+):$/) {
...@@ -120,7 +146,7 @@ sub line { ...@@ -120,7 +146,7 @@ sub line {
} elsif($tool eq "cd" && s/^\/bin\/sh:\s*cd:\s*//) { } elsif($tool eq "cd" && s/^\/bin\/sh:\s*cd:\s*//) {
parse_cd_output($_); parse_cd_output($_);
} else { } else {
error(); error("line");
} }
$file =~ s/^\.\///; $file =~ s/^\.\///;
...@@ -147,7 +173,7 @@ sub make_output { ...@@ -147,7 +173,7 @@ sub make_output {
if(/^File \`(.+?)\' has modification time in the future \((.+?) > \(.+?\)\)$/) { if(/^File \`(.+?)\' has modification time in the future \((.+?) > \(.+?\)\)$/) {
# Nothing # Nothing
} else { } else {
error(); error("make_output");
} }
} elsif(/^\`(.*?)\' is up to date.$/) { } elsif(/^\`(.*?)\' is up to date.$/) {
# Nothing # Nothing
...@@ -177,10 +203,10 @@ sub make_output { ...@@ -177,10 +203,10 @@ sub make_output {
if(/^Clock skew detected. Your build may be incomplete.$/) { if(/^Clock skew detected. Your build may be incomplete.$/) {
# Nothing # Nothing
} else { } else {
error(); error("make_output");
} }
} else { } else {
error(); error("make_output");
} }
} }
...@@ -204,61 +230,61 @@ sub command { ...@@ -204,61 +230,61 @@ sub command {
# Nothing # Nothing
} }
if(s/^ar\s*//) { if(s/^ar\s+//) {
$tool = "ar"; $tool = "ar";
($read_files, $write_files) = ar_command($_); ($read_files, $write_files) = ar_command($_);
} elsif(s/^as\s*//) { } elsif(s/^as\s+//) {
$tool = "as"; $tool = "as";
($read_files, $write_files) = as_command($_); ($read_files, $write_files) = as_command($_);
} elsif(s/^bison\s*//) { } elsif(s/^bison\s+//) {
$tool = "bison"; $tool = "bison";
($read_files, $write_files) = bison_command($_); ($read_files, $write_files) = bison_command($_);
} elsif(s/^cd\s*//) { } elsif(s/^cd\s+//) {
$tool = "cd"; $tool = "cd";
($read_files, $write_files) = cd_command($_); ($read_files, $write_files) = cd_command($_);
} elsif(s/^flex\s*//) { } elsif(s/^flex\s+//) {
$tool = "flex"; $tool = "flex";
($read_files, $write_files) = flex_command($_); ($read_files, $write_files) = flex_command($_);
} elsif(s/^for\s*//) { } elsif(s/^for\s+//) {
$tool = "for"; $tool = "for";
($read_files, $write_files) = for_command($_); ($read_files, $write_files) = for_command($_);
} elsif(s/^\/usr\/bin\/install\s*//) { } elsif(s/^\/usr\/bin\/install\s+//) {
$tool = "install"; $tool = "install";
($read_files, $write_files) = install_command($_); ($read_files, $write_files) = install_command($_);
} elsif(s/^ld\s*//) { } elsif(s/^ld\s+//) {
$tool = "ld"; $tool = "ld";
($read_files, $write_files) = ld_command($_); ($read_files, $write_files) = ld_command($_);
} elsif(s/^\/sbin\/ldconfig\s*//) { } elsif(s/^\/sbin\/ldconfig\s+//) {
$tool = "ldconfig"; $tool = "ldconfig";
($read_files, $write_files) = ldconfig_command(); ($read_files, $write_files) = ldconfig_command();
} elsif(s/^gcc\s*//) { } elsif(s/^gcc\s+//) {
$tool = "gcc"; $tool = "gcc";
($read_files, $write_files) = gcc_command($_); ($read_files, $write_files) = gcc_command($_);
} elsif(s/^(?:(?:\.\.\/)+|\.\/)tools\/makedep\s*//) { } elsif(s/^(?:(?:\.\.\/)+|\.\/)tools\/makedep\s+//) {
$tool = "makedep"; $tool = "makedep";
($read_files, $write_files) = makedep_command($_); ($read_files, $write_files) = makedep_command($_);
} elsif(s/^mkdir\s*//) { } elsif(s/^mkdir\s+//) {
$tool = "mkdir"; $tool = "mkdir";
($read_files, $write_files) = mkdir_command($_); ($read_files, $write_files) = mkdir_command($_);
} elsif(s/^ranlib\s*//) { } elsif(s/^ranlib\s+//) {
$tool = "ranlib"; $tool = "ranlib";
($read_files, $write_files) = ranlib_command($_); ($read_files, $write_files) = ranlib_command($_);
} elsif(s/^rm\s*//) { } elsif(s/^rm\s+//) {
$tool = "rm"; $tool = "rm";
($read_files, $write_files, $remove_files) = rm_command($_); ($read_files, $write_files, $remove_files) = rm_command($_);
} elsif(s/^sed\s*//) { } elsif(s/^sed\s+//) {
$tool = "sed"; $tool = "sed";
($read_files, $write_files) = sed_command($_); ($read_files, $write_files) = sed_command($_);
} elsif(s/^strip\s*//) { } elsif(s/^strip\s+//) {
$tool = "sed"; $tool = "sed";
($read_files, $write_files) = strip_command($_); ($read_files, $write_files) = strip_command($_);
} elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/winebuild\/winebuild\s*//) { } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/winebuild\/winebuild\s+//) {
$tool = "winebuild"; $tool = "winebuild";
($read_files, $write_files) = winebuild_command($_); ($read_files, $write_files) = winebuild_command($_);
} elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/wmc\/wmc\s*//) { } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/wmc\/wmc\s+//) {
$tool = "wmc"; $tool = "wmc";
($read_files, $write_files) = wmc_command($_); ($read_files, $write_files) = wmc_command($_);
} elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/wrc\/wrc\s*//) { } elsif(s/^LD_LIBRARY_PATH="(?:(?:\.\.\/)*unicode)?:\$LD_LIBRARY_PATH"\s+(?:\.\.\/)*tools\/wrc\/wrc\s+//) {
$tool = "wrc"; $tool = "wrc";
($read_files, $write_files) = wrc_command($_); ($read_files, $write_files) = wrc_command($_);
} }
...@@ -282,7 +308,7 @@ sub ar_command { ...@@ -282,7 +308,7 @@ sub ar_command {
$read_files =~ s/^\s*//; $read_files =~ s/^\s*//;
$read_files = [split(/\s+/, $read_files)]; $read_files = [split(/\s+/, $read_files)];
} else { } else {
error(); error("ar_command");
} }
return ($read_files, $write_files); return ($read_files, $write_files);
...@@ -302,7 +328,7 @@ sub as_command { ...@@ -302,7 +328,7 @@ sub as_command {
$write_files = [$1]; $write_files = [$1];
$read_files = [$2]; $read_files = [$2];
} else { } else {
error(); error("as_command");
} }
return ($read_files, $write_files); return ($read_files, $write_files);
...@@ -378,7 +404,7 @@ sub gcc_command { ...@@ -378,7 +404,7 @@ sub gcc_command {
$write_files = [$1]; $write_files = [$1];
$read_files = ["<???>"]; $read_files = ["<???>"];
} else { } else {
error(); error("gcc_command");
} }
return ($read_files, $write_files); return ($read_files, $write_files);
...@@ -400,7 +426,19 @@ sub gcc_output { ...@@ -400,7 +426,19 @@ sub gcc_output {
if(0) { if(0) {
# Nothing # Nothing
} elsif(/^((?:signed |unsigned )?(?:int|long)) format, (different type|\S+) arg \(arg (\d+)\)$/) { } elsif(/^((?:signed |unsigned )?(?:int|long)) format, (different type|\S+) arg \(arg (\d+)\)$/) {
$supress = 0; my $type = $2;
if($type =~ /^
HACCEL|HANDLE|HBITMAP|HBRUSH|HCALL|HCURSOR|HDC|HDRVR|HDESK|
HGDIOBJ|HKL|HGLOBAL|HINSTANCE|HKEY|
HMENU|HMIDISTRM|HMIDIIN|HMIDIOUT|HMIXER|HMIXEROBJ|HMMIO|HMODULE|
HLINE|HPHONE|HPHONEAPP|
HRASCONN|HRGN|HRSRC|HWAVEIN|HWAVEOUT|HWINSTA|HWND|WSAEVENT|
handle_t|pointer$/x)
{
$supress = 1;
} else {
$supress = 0;
}
} elsif(/^\(near initialization for \`(.*?)\'\)$/) { } elsif(/^\(near initialization for \`(.*?)\'\)$/) {
$supress = 0; $supress = 0;
} elsif(/^\`(.*?)\' defined but not used$/) { } elsif(/^\`(.*?)\' defined but not used$/) {
...@@ -442,7 +480,13 @@ sub gcc_output { ...@@ -442,7 +480,13 @@ sub gcc_output {
} elsif(/^ordered comparison of pointer with integer zero$/) { } elsif(/^ordered comparison of pointer with integer zero$/) {
$supress = 0; $supress = 0;
} elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') from incompatible pointer type$/) { } elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') from incompatible pointer type$/) {
$supress = 0; my $arg = $1;
my $name = $2;
if(defined($name) && $name =~ /^GDI_AllocObject$/) {
$supress = 1;
} else {
$supress = 0;
}
} elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') makes integer from pointer without a cast$/) { } elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') makes integer from pointer without a cast$/) {
$supress = 0; $supress = 0;
} elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') makes pointer from integer without a cast$/) { } elsif(/^passing arg (\d+) of (?:pointer to function|\`(\S+)\') makes pointer from integer without a cast$/) {
...@@ -458,14 +502,14 @@ sub gcc_output { ...@@ -458,14 +502,14 @@ sub gcc_output {
} elsif(!$options->pedantic) { } elsif(!$options->pedantic) {
$supress = 0; $supress = 0;
} else { } else {
error(); error("gcc_output");
} }
if(!$supress) { if(!$supress) {
if($function) { if($function) {
$message = "function $function: $_"; $message = "function $function: warning: $_";
} else { } else {
$message = "$_"; $message = "warning: $_";
} }
} else { } else {
$message = ""; $message = "";
...@@ -487,14 +531,14 @@ sub gcc_output { ...@@ -487,14 +531,14 @@ sub gcc_output {
} elsif(!$options->pedantic) { } elsif(!$options->pedantic) {
$message = "$_"; $message = "$_";
} else { } else {
error(); error("gcc_output");
} }
} elsif(/^In function \`(.*?)\':$/) { } elsif(/^In function \`(.*?)\':$/) {
$function = $1; $function = $1;
} elsif(/^At top level:$/) { } elsif(/^At top level:$/) {
$function = ""; $function = "";
} else { } else {
error(); error("gcc_output");
} }
} }
...@@ -522,7 +566,7 @@ sub ld_command { ...@@ -522,7 +566,7 @@ sub ld_command {
$write_files = [$2]; $write_files = [$2];
$read_files = [split(/\s+/, $1)]; $read_files = [split(/\s+/, $1)];
} else { } else {
error(); error("ld_command");
} }
return ($read_files, $write_files); return ($read_files, $write_files);
...@@ -657,7 +701,7 @@ sub wmc_command { ...@@ -657,7 +701,7 @@ sub wmc_command {
$write_files = [$rc_file]; $write_files = [$rc_file];
$read_files = [$mc_file]; $read_files = [$mc_file];
} else { } else {
error(); error("wmc_command");
} }
return ($read_files, $write_files); return ($read_files, $write_files);
...@@ -691,7 +735,7 @@ sub wrc_command { ...@@ -691,7 +735,7 @@ sub wrc_command {
$write_files = [$o_file]; $write_files = [$o_file];
$read_files = [$rc_file]; $read_files = [$rc_file];
} else { } else {
error(); error("wrc_command");
} }
return ($read_files, $write_files); return ($read_files, $write_files);
......
...@@ -41,7 +41,6 @@ package _options; ...@@ -41,7 +41,6 @@ package _options;
use strict; use strict;
use config qw($current_dir $wine_dir);
use output qw($output); use output qw($output);
sub new { sub new {
...@@ -182,6 +181,7 @@ sub parse_files { ...@@ -182,6 +181,7 @@ sub parse_files {
my $self = shift; my $self = shift;
my $arguments = \@{$self->{_ARGUMENTS}}; my $arguments = \@{$self->{_ARGUMENTS}};
my $directories = \@{$self->{_DIRECTORIES}};
my $c_files = \@{$self->{_C_FILES}}; my $c_files = \@{$self->{_C_FILES}};
my $h_files = \@{$self->{_H_FILES}}; my $h_files = \@{$self->{_H_FILES}};
...@@ -245,6 +245,16 @@ sub parse_files { ...@@ -245,6 +245,16 @@ sub parse_files {
} }
} split(/\n/, `$h_command`)); } split(/\n/, `$h_command`));
} }
my %dirs;
foreach my $file (@$c_files, @$h_files) {
my $dir = $file;
$dir =~ s%/?[^/]+$%%;
if(!$dir) { $dir = "."; }
$dirs{$dir}++
}
@$directories = sort(keys(%dirs));
} }
sub options_set { sub options_set {
...@@ -392,4 +402,16 @@ sub h_files { ...@@ -392,4 +402,16 @@ sub h_files {
return @$h_files; return @$h_files;
} }
sub directories {
my $self = shift;
my $directories = \@{$self->{_DIRECTORIES}};
if(!defined(@$directories)) {
$self->parse_files;
}
return @$directories;
}
1; 1;
...@@ -391,6 +391,8 @@ dlls/winedos ...@@ -391,6 +391,8 @@ dlls/winedos
% dlls/wineps/wineps.spec % dlls/wineps/wineps.spec
dlls/wineps
% dlls/wineps/wineps16.spec % dlls/wineps/wineps16.spec
dlls/wineps dlls/wineps
......
...@@ -14,7 +14,7 @@ use vars qw($modules); ...@@ -14,7 +14,7 @@ use vars qw($modules);
use config qw( use config qw(
&file_type &files_skip &file_type &files_skip
&file_directory &file_directory
&get_c_files &get_c_files &get_spec_files
$current_dir $wine_dir $current_dir $wine_dir
$winapi_check_dir $winapi_check_dir
); );
...@@ -23,36 +23,58 @@ use output qw($output); ...@@ -23,36 +23,58 @@ use output qw($output);
$modules = 'modules'->new; $modules = 'modules'->new;
sub get_spec_file_type {
my $file = shift;
my $module;
my $type;
open(IN, "< $file") || die "$file: $!\n";
local $/ = "\n";
while(<IN>) {
s/^\s*(.*?)\s*$/$1/;
s/^(.*?)\s*#.*$/$1/;
/^$/ && next;
if(/^name\s*(\S*)/) { $module = $1; }
if(/^type\s*(\w+)/) { $type = $1; }
if(defined($module) && defined($type)) { last; }
}
close(IN);
if(!defined($module)) {
$module = $file;
$module =~ s%^.*?([^/]+)\.spec|%$1%;
}
if(!defined($type)) {
$type = "";
}
return ($type, $module);
}
sub new { sub new {
my $proto = shift; my $proto = shift;
my $class = ref($proto) || $proto; my $class = ref($proto) || $proto;
my $self = {}; my $self = {};
bless ($self, $class); bless ($self, $class);
my $spec_files16 = \@{$self->{SPEC_FILES16}};
my $spec_files32 = \@{$self->{SPEC_FILES32}};
my $dir2spec_file = \%{$self->{DIR2SPEC_FILE}}; my $dir2spec_file = \%{$self->{DIR2SPEC_FILE}};
my $spec_file2dir = \%{$self->{SPEC_FILE2DIR}}; my $spec_file2dir = \%{$self->{SPEC_FILE2DIR}};
my $spec_file2module = \%{$self->{SPEC_FILE2MODULE}}; my $spec_file2module = \%{$self->{SPEC_FILE2MODULE}};
my $module2spec_file = \%{$self->{MODULE2SPEC_FILE}};
my $module_file = "$winapi_check_dir/modules.dat"; my $module_file = "$winapi_check_dir/modules.dat";
my @all_spec_files = map {
s/^.\/(.*)$/$1/;
if(file_type($_) eq "winelib") {
$_;
} else {
();
}
} split(/\n/, `find $wine_dir -name \\*.spec`);
my %all_spec_files;
foreach my $file (@all_spec_files) {
$all_spec_files{$file}++ ;
}
if($options->progress) { if($options->progress) {
$output->progress("modules.dat"); $output->progress("modules.dat");
} }
my %spec_file_found;
my $allowed_dir; my $allowed_dir;
my $spec_file; my $spec_file;
...@@ -65,17 +87,13 @@ sub new { ...@@ -65,17 +87,13 @@ sub new {
if(/^%\s+(.*?)$/) { if(/^%\s+(.*?)$/) {
$spec_file = $1; $spec_file = $1;
if(!-f "$wine_dir/$spec_file") { if(!-f "$wine_dir/$spec_file") {
$output->write("modules.dat: $spec_file: file ($spec_file) doesn't exist or is no file\n"); $output->write("modules.dat: $spec_file: file ($spec_file) doesn't exist or is no file\n");
} }
if($wine_dir eq ".") { $spec_file_found{$spec_file}++;
$all_spec_files{$spec_file}--; $$spec_file2dir{$spec_file} = {};
} else {
$all_spec_files{"$wine_dir/$spec_file"}--;
}
$$dir2spec_file{""}{$spec_file}++; # FIXME: Kludge
next; next;
} else { } else {
$allowed_dir = $1; $allowed_dir = $1;
...@@ -89,8 +107,40 @@ sub new { ...@@ -89,8 +107,40 @@ sub new {
} }
close(IN); close(IN);
foreach my $spec_file (sort(keys(%all_spec_files))) { my @spec_files;
if($all_spec_files{$spec_file} > 0) { if($wine_dir eq ".") {
@spec_files = get_spec_files("winelib");
} else {
my %spec_files = ();
foreach my $dir ($options->directories) {
$dir = "$current_dir/$dir";
$dir =~ s%/\.$%%;
foreach my $spec_file (sort(keys(%{$$dir2spec_file{$dir}}))) {
$spec_files{$spec_file}++;
}
}
@spec_files = sort(keys(%spec_files));
}
@$spec_files16 = ();
@$spec_files32 = ();
foreach my $spec_file (@spec_files) {
(my $type, my $module) = get_spec_file_type("$wine_dir/$spec_file");
$$spec_file2module{$spec_file} = $module;
$$module2spec_file{$module} = $spec_file;
if($type eq "win16") {
push @$spec_files16, $spec_file;
} elsif($type eq "win32") {
push @$spec_files32, $spec_file;
} else {
$output->write("$spec_file: unknown type '$type'\n");
}
}
foreach my $spec_file (@spec_files) {
if(!$spec_file_found{$spec_file}) {
$output->write("modules.dat: $spec_file: exists but is not specified\n"); $output->write("modules.dat: $spec_file: exists but is not specified\n");
} }
} }
...@@ -146,19 +196,14 @@ sub complete_modules { ...@@ -146,19 +196,14 @@ sub complete_modules {
return @complete_modules; return @complete_modules;
} }
sub spec_file_module { sub is_allowed_module {
my $self = shift; my $self = shift;
my $spec_file2module = \%{$self->{SPEC_FILE2MODULE}};
my $module2spec_file = \%{$self->{MODULE2SPEC_FILE}}; my $module2spec_file = \%{$self->{MODULE2SPEC_FILE}};
my $spec_file = shift;
$spec_file =~ s/^\.\///;
my $module = shift; my $module = shift;
$$spec_file2module{$spec_file} = $module; return defined($$module2spec_file{$module});
$$module2spec_file{$module} = $spec_file;
} }
sub is_allowed_module_in_file { sub is_allowed_module_in_file {
...@@ -205,7 +250,9 @@ sub allowed_modules_in_file { ...@@ -205,7 +250,9 @@ sub allowed_modules_in_file {
$allowed_modules{$module}++; $allowed_modules{$module}++;
} }
return join(" & ", sort(keys(%allowed_modules))); my $module = join(" & ", sort(keys(%allowed_modules)));
return $module;
} }
sub allowed_dirs_for_module { sub allowed_dirs_for_module {
...@@ -221,32 +268,20 @@ sub allowed_dirs_for_module { ...@@ -221,32 +268,20 @@ sub allowed_dirs_for_module {
return sort(keys(%{$$spec_file2dir{$spec_file}})); return sort(keys(%{$$spec_file2dir{$spec_file}}));
} }
sub allowed_spec_files { sub allowed_spec_files16 {
my $self = shift; my $self = shift;
my $dir2spec_file = \%{$self->{DIR2SPEC_FILE}}; my $spec_files16 = \@{$self->{SPEC_FILES16}};
my @dirs = map { return @$spec_files16;
s/^\.\/(.*)$/$1/; }
if(/^\.$/) {
$current_dir;
} else {
if($current_dir ne ".") {
"$current_dir/$_";
} else {
$_;
}
}
} split(/\n/, `find . -type d ! -name CVS`);
my %allowed_spec_files = (); sub allowed_spec_files32 {
foreach my $dir (sort(@dirs)) { my $self = shift;
foreach my $spec_file (sort(keys(%{$$dir2spec_file{$dir}}))) {
$allowed_spec_files{$spec_file}++; my $spec_files32 = \@{$self->{SPEC_FILES32}};
}
}
return sort(keys(%allowed_spec_files)); return @$spec_files32;
} }
sub found_module_in_dir { sub found_module_in_dir {
...@@ -257,6 +292,9 @@ sub found_module_in_dir { ...@@ -257,6 +292,9 @@ sub found_module_in_dir {
my $used_module_dirs = \%{$self->{USED_MODULE_DIRS}}; my $used_module_dirs = \%{$self->{USED_MODULE_DIRS}};
$dir = "$current_dir/$dir";
$dir =~ s%/\.$%%;
$$used_module_dirs{$module}{$dir}++; $$used_module_dirs{$module}{$dir}++;
} }
...@@ -264,15 +302,16 @@ sub global_report { ...@@ -264,15 +302,16 @@ sub global_report {
my $self = shift; my $self = shift;
my $dir2spec_file = \%{$self->{DIR2SPEC_FILE}}; my $dir2spec_file = \%{$self->{DIR2SPEC_FILE}};
my $spec_file2module = \%{$self->{SPEC_FILE2MODULE}}; my $module2spec_file = \%{$self->{MODULE2SPEC_FILE}};
my $used_module_dirs = \%{$self->{USED_MODULE_DIRS}}; my $used_module_dirs = \%{$self->{USED_MODULE_DIRS}};
my @messages; my @messages;
foreach my $dir (sort(keys(%$dir2spec_file))) { foreach my $dir ($options->directories) {
if($dir eq "") { next; } $dir = "$current_dir/$dir";
foreach my $spec_file (sort(keys(%{$$dir2spec_file{$dir}}))) { $dir =~ s%/\.$%%;
my $module = $$spec_file2module{$spec_file}; foreach my $module ($self->all_modules) {
if(!$$used_module_dirs{$module}{$dir}) { if(!$$used_module_dirs{$module}{$dir}) {
my $spec_file = $$module2spec_file{$module};
push @messages, "modules.dat: $spec_file: directory ($dir) is not used\n"; push @messages, "modules.dat: $spec_file: directory ($dir) is not used\n";
} }
} }
......
...@@ -2,10 +2,13 @@ ...@@ -2,10 +2,13 @@
BOOL BOOL
CHAR CHAR
COLORREF
DWORD DWORD
INT INT
HANDLE HANDLE
HDC HDC
HBITMAP
HGDIOBJ
HRGN HRGN
HWND HWND
LONG LONG
...@@ -20,16 +23,28 @@ int ...@@ -20,16 +23,28 @@ int
%ptr %ptr
BITMAPINFO *
BYTE * BYTE *
DC *
DEVMODEA *
DWORD *
CREATESTRUCTA * CREATESTRUCTA *
LPBYTE LPBYTE
LPCVOID
LPDIDEVICEOBJECTDATA LPDIDEVICEOBJECTDATA
LPDWORD LPDWORD
LPINT
LPMOUSE_EVENT_PROC LPMOUSE_EVENT_PROC
LPSIZE
LPTEXTMETRICW
LPVOID LPVOID
INT *
POINT *
RECT *
WINDOWPOS * WINDOWPOS *
struct tagCURSORICONINFO * struct tagCURSORICONINFO *
struct tagWND * struct tagWND *
void *
%str %str
...@@ -38,6 +53,7 @@ LPSTR ...@@ -38,6 +53,7 @@ LPSTR
%wstr %wstr
LPCWSTR
LPWSTR LPWSTR
%void %void
......
%long
BOOL
COLORREF
DWORD
HDC
HGDIOBJ
HWND
INT
LPARAM
UINT
WORD
%ptr
BITMAPINFO *
DC *
DEVICEFONTENUMPROC
DEVMODEA *
DOCINFOA *
DWORD *
INT *
LPDEVMODEA
LPINT
LPLOGFONTW
LPSIZE
POINT *
RECT *
TEXTMETRICW *
void *
%ptr # --forbidden
SEGPTR
%str
LPCSTR
LPSTR
%wstr
LPCWSTR
%void
VOID
...@@ -2,14 +2,18 @@ ...@@ -2,14 +2,18 @@
BOOL BOOL
CHAR CHAR
COLORREF
DWORD DWORD
HANDLE HANDLE
HBITMAP
HDC HDC
HGDIOBJ
HICON HICON
HRGN HRGN
HWND HWND
INT INT
LONG LONG
LPARAM
UINT UINT
WPARAM WPARAM
WORD WORD
...@@ -22,20 +26,39 @@ int ...@@ -22,20 +26,39 @@ int
%ptr %ptr
BITMAPINFO *
BYTE * BYTE *
DC *
CURSORICONINFO * CURSORICONINFO *
CREATESTRUCTA * CREATESTRUCTA *
DEVICEFONTENUMPROC
DEVMODEA *
DWORD *
HANDLE * HANDLE *
INT *
LPBYTE LPBYTE
LPCVOID
LPDIDEVICEOBJECTDATA LPDIDEVICEOBJECTDATA
LPDWORD LPDWORD
LPINT
LPLOGFONTW
LPMOUSE_EVENT_PROC LPMOUSE_EVENT_PROC
LPPOINT LPPOINT
LPRECT LPRECT
LPSIZE
LPVOID LPVOID
LPVOID *
PIXELFORMATDESCRIPTOR *
POINT *
RECT * RECT *
TEXTMETRICW *
WINDOWPOS * WINDOWPOS *
WND * WND *
void *
%ptr # --forbidden
SEGPTR
%str %str
......
...@@ -13,28 +13,31 @@ use vars qw($win16api $win32api @winapis); ...@@ -13,28 +13,31 @@ use vars qw($win16api $win32api @winapis);
use config qw( use config qw(
&file_type &file_type
&get_api_files &get_spec_files &get_api_files
$current_dir $wine_dir $current_dir $wine_dir
); );
use modules qw($modules); use modules qw($modules);
use options qw($options); use options qw($options);
use output qw($output); use output qw($output);
$win16api = 'winapi'->new("win16"); my @spec_files16 = $modules->allowed_spec_files16;
$win32api = 'winapi'->new("win32"); $win16api = 'winapi'->new("win16", \@spec_files16);
@winapis = ($win16api, $win32api);
my @spec_files = get_spec_files("winelib"); my @spec_files32 = $modules->allowed_spec_files32;
foreach my $file (@spec_files) { $win32api = 'winapi'->new("win32", \@spec_files32);
(my $type, my $module) = 'winapi'->get_spec_file_type("$wine_dir/$file");
$modules->spec_file_module($file, $module); @winapis = ($win16api, $win32api);
}
if($wine_dir eq ".") { for my $internal_name ($win32api->all_internal_functions) {
'winapi'->read_spec_files(\@spec_files); my $module16 = $win16api->function_internal_module($internal_name);
} else { my $module32 = $win16api->function_internal_module($internal_name);
@spec_files = $modules->allowed_spec_files; if(defined($module16) &&
'winapi'->read_spec_files(\@spec_files); !$win16api->is_function_stub_in_module($module16, $internal_name) &&
!$win32api->is_function_stub_in_module($module32, $internal_name))
{
$win16api->found_shared_internal_function($internal_name);
$win32api->found_shared_internal_function($internal_name);
}
} }
sub new { sub new {
...@@ -44,19 +47,34 @@ sub new { ...@@ -44,19 +47,34 @@ sub new {
bless ($self, $class); bless ($self, $class);
my $name = \${$self->{NAME}}; my $name = \${$self->{NAME}};
my $function_forward = \%{$self->{FUNCTION_FORWARD}};
my $function_internal_name = \%{$self->{FUNCTION_INTERNAL_NAME}};
my $function_module = \%{$self->{FUNCTION_MODULE}};
$$name = shift; $$name = shift;
my $refspec_files = shift;
foreach my $file (@$refspec_files) {
$self->parse_spec_file("$wine_dir/$file");
}
foreach my $file (get_api_files($$name)) { foreach my $file (get_api_files($$name)) {
my $module = $file; my $module = $file;
$module =~ s/.*?\/([^\/]*?)\.api$/$1/;
if($options->progress) { if($modules->is_allowed_module($module)) {
$output->lazy_progress("$file"); $self->parse_api_file($file,$module);
} }
$module =~ s/.*?\/([^\/]*?)\.api$/$1/;
$self->parse_api_file($file,$module);
} }
foreach my $forward_name (sort(keys(%$function_forward))) {
$$function_forward{$forward_name} =~ /^(\S*):(\S*)\.(\S*)$/;
(my $from_module, my $to_module, my $external_name) = ($1, $2, $3);
my $internal_name = $$function_internal_name{$external_name};
if(defined($internal_name)) {
$$function_module{$internal_name} .= " & $from_module";
}
}
return $self; return $self;
} }
...@@ -88,7 +106,7 @@ sub parse_api_file { ...@@ -88,7 +106,7 @@ sub parse_api_file {
my $forbidden = 0; my $forbidden = 0;
if($options->progress) { if($options->progress) {
$output->progress("$file"); $output->lazy_progress("$file");
} }
open(IN, "< $wine_dir/$file") || die "$wine_dir/$file: $!\n"; open(IN, "< $wine_dir/$file") || die "$wine_dir/$file: $!\n";
...@@ -173,75 +191,6 @@ sub parse_api_file { ...@@ -173,75 +191,6 @@ sub parse_api_file {
close(IN); close(IN);
} }
sub get_spec_file_type {
my $proto = shift;
my $class = ref($proto) || $proto;
my $file = shift;
my $module;
my $type;
open(IN, "< $file") || die "$file: $!\n";
local $/ = "\n";
while(<IN>) {
s/^\s*(.*?)\s*$/$1/;
s/^(.*?)\s*#.*$/$1/;
/^$/ && next;
if(/^name\s*(\S*)/) { $module = $1; }
if(/^type\s*(\w+)/) { $type = $1; }
if(defined($module) && defined($type)) { last; }
}
close(IN);
return ($type, $module);
}
sub read_spec_files {
my $proto = shift;
my $class = ref($proto) || $proto;
my $files = shift;
foreach my $file (@$files) {
(my $type, my $module) = 'winapi'->get_spec_file_type("$wine_dir/$file");
if($type eq "win16") {
$win16api->parse_spec_file("$wine_dir/$file");
} elsif($type eq "win32") {
$win32api->parse_spec_file("$wine_dir/$file");
}
}
foreach my $self ($win16api, $win32api) {
my $function_forward = \%{$self->{FUNCTION_FORWARD}};
my $function_internal_name = \%{$self->{FUNCTION_INTERNAL_NAME}};
my $function_module = \%{$self->{FUNCTION_MODULE}};
foreach my $forward_name (sort(keys(%$function_forward))) {
$$function_forward{$forward_name} =~ /^(\S*):(\S*)\.(\S*)$/;
(my $from_module, my $to_module, my $external_name) = ($1, $2, $3);
my $internal_name = $$function_internal_name{$external_name};
if(defined($internal_name)) {
$$function_module{$internal_name} .= " & $from_module";
}
}
}
for my $internal_name ($win32api->all_internal_functions) {
my $module16 = $win16api->function_internal_module($internal_name);
my $module32 = $win16api->function_internal_module($internal_name);
if(defined($module16) &&
!$win16api->is_function_stub_in_module($module16, $internal_name) &&
!$win32api->is_function_stub_in_module($module32, $internal_name))
{
$win16api->found_shared_internal_function($internal_name);
$win32api->found_shared_internal_function($internal_name);
}
}
}
sub parse_spec_file { sub parse_spec_file {
my $self = shift; my $self = shift;
......
...@@ -98,6 +98,26 @@ my @h_files = $options->h_files; ...@@ -98,6 +98,26 @@ my @h_files = $options->h_files;
@h_files = files_skip(@h_files); @h_files = files_skip(@h_files);
@h_files = files_filter("winelib", @h_files); @h_files = files_filter("winelib", @h_files);
my $all_modules = 0;
my %complete_module;
if($options->global) {
my @complete_modules = $modules->complete_modules(\@c_files);
foreach my $module (@complete_modules) {
$complete_module{$module}++;
}
my $all_modules = 1;
foreach my $module ($modules->all_modules) {
if(!$complete_module{$module}) {
$all_modules = 0;
if($wine_dir eq ".") {
$output->write("*.c: module $module is not complete\n");
}
}
}
}
my $progress_current = 0; my $progress_current = 0;
my $progress_max = scalar(@c_files); my $progress_max = scalar(@c_files);
...@@ -289,7 +309,7 @@ foreach my $file (@c_files) { ...@@ -289,7 +309,7 @@ foreach my $file (@c_files) {
(defined($module16) || defined($module32)) && (defined($module16) || defined($module32)) &&
$linkage eq "" && defined($statements)) $linkage eq "" && defined($statements))
{ {
# &winapi_documentation::check_documentation($function); &winapi_documentation::check_documentation($function);
} }
if(1) { if(1) {
...@@ -523,7 +543,7 @@ foreach my $file (@c_files) { ...@@ -523,7 +543,7 @@ foreach my $file (@c_files) {
} }
} }
}; };
&winapi_parser::parse_c_file($file, $create_function, $found_function, $create_type, $found_type, $found_preprocessor); &winapi_parser::parse_c_file($file, $create_function, $found_function, $create_type, $found_type, $found_preprocessor);
if($options->config_unnessary) { if($options->config_unnessary) {
...@@ -536,12 +556,7 @@ foreach my $file (@c_files) { ...@@ -536,12 +556,7 @@ foreach my $file (@c_files) {
} }
if($options->global) { if($options->global) {
my @complete_modules = $modules->complete_modules(\@c_files); my @complete_modules = sort(keys(%complete_module));
my %complete_module;
foreach my $module (@complete_modules) {
$complete_module{$module}++;
}
if($options->declared) { if($options->declared) {
foreach my $module (@complete_modules) { foreach my $module (@complete_modules) {
...@@ -575,12 +590,6 @@ if($options->global) { ...@@ -575,12 +590,6 @@ if($options->global) {
} }
} }
my $all_modules = 1;
foreach my $module ($modules->all_modules) {
if(!$complete_module{$module}) {
$all_modules = 0;
}
}
if($all_modules) { if($all_modules) {
&winapi_documentation::report_documentation; &winapi_documentation::report_documentation;
......
...@@ -323,7 +323,7 @@ sub _check_statements { ...@@ -323,7 +323,7 @@ sub _check_statements {
} }
} }
} }
} else { } elsif($options->cross_call) {
$$functions{$internal_name}->function_called($called_name); $$functions{$internal_name}->function_called($called_name);
if(!defined($$functions{$called_name})) { if(!defined($$functions{$called_name})) {
$$functions{$called_name} = 'winapi_function'->new; $$functions{$called_name} = 'winapi_function'->new;
......
...@@ -293,10 +293,6 @@ sub parse_c_file { ...@@ -293,10 +293,6 @@ sub parse_c_file {
} }
} }
if(!defined($statements)) {
$statements = "";
}
if($line !~ /^\s*$/) { if($line !~ /^\s*$/) {
$statements .= "$line\n"; $statements .= "$line\n";
} }
...@@ -408,9 +404,9 @@ sub parse_c_file { ...@@ -408,9 +404,9 @@ sub parse_c_file {
$function_line, $linkage, $return_type, $calling_convention, $name, $function_line, $linkage, $return_type, $calling_convention, $name,
\@argument_types,\@argument_names,\@argument_documentations); \@argument_types,\@argument_names,\@argument_documentations);
if($level == 0) { if($level == 0) {
&$function_end($statements); &$function_end(undef);
$statements = undef;
} }
$statements = "";
} elsif(/__ASM_GLOBAL_FUNC\(\s*(.*?)\s*,/s) { } elsif(/__ASM_GLOBAL_FUNC\(\s*(.*?)\s*,/s) {
my @lines = split(/\n/, $&); my @lines = split(/\n/, $&);
my $function_line = $. - scalar(@lines) + 1; my $function_line = $. - scalar(@lines) + 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment