2001-06-13 21:38:29 +02:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
# Copyright 2001 Patrik Stridvall
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
$0 =~ m%^(.*?/?tools)/winapi/winapi_fixup$%;
|
|
|
|
require "$1/winapi/setup.pm";
|
|
|
|
}
|
|
|
|
|
|
|
|
use config qw(
|
2001-06-21 00:53:21 +02:00
|
|
|
&file_type &files_filter
|
|
|
|
&file_skip &files_skip
|
|
|
|
&file_normalize
|
2001-06-19 05:34:39 +02:00
|
|
|
&get_spec_files
|
2001-06-13 21:38:29 +02:00
|
|
|
$current_dir $wine_dir $winapi_dir $winapi_check_dir
|
|
|
|
);
|
2001-07-24 01:20:56 +02:00
|
|
|
use output qw($output);
|
2001-06-13 21:38:29 +02:00
|
|
|
use modules;
|
|
|
|
use util;
|
|
|
|
use winapi;
|
|
|
|
use winapi_parser;
|
2001-07-24 01:20:56 +02:00
|
|
|
use winapi_fixup_options qw($options);
|
2001-06-13 21:38:29 +02:00
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
my $modules = 'modules'->new($options, $output, $wine_dir, $current_dir, \&file_type, "$winapi_check_dir/modules.dat");
|
2001-06-13 21:38:29 +02:00
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
my $win16api = 'winapi'->new($options, $output, "win16", "$winapi_check_dir/win16");
|
|
|
|
my $win32api = 'winapi'->new($options, $output, "win32", "$winapi_check_dir/win32");
|
2001-06-13 21:38:29 +02:00
|
|
|
my @winapis = ($win16api, $win32api);
|
|
|
|
|
|
|
|
if($wine_dir eq ".") {
|
2001-07-11 19:27:45 +02:00
|
|
|
'winapi'->read_all_spec_files($modules, $wine_dir, $current_dir, \&file_type, $win16api, $win32api);
|
2001-06-13 21:38:29 +02:00
|
|
|
} else {
|
|
|
|
my @spec_files = $modules->allowed_spec_files($wine_dir, $current_dir);
|
2001-07-11 19:27:45 +02:00
|
|
|
'winapi'->read_spec_files($modules, $wine_dir, $current_dir, \@spec_files, $win16api, $win32api);
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
my @c_files = $options->c_files;
|
2001-06-21 00:53:21 +02:00
|
|
|
@c_files = files_skip(@c_files);
|
|
|
|
@c_files = files_filter("winelib", @c_files);
|
2001-06-13 21:38:29 +02:00
|
|
|
|
|
|
|
my $progress_output;
|
|
|
|
my $progress_current = 0;
|
|
|
|
my $progress_max = scalar(@c_files);
|
|
|
|
|
|
|
|
foreach my $file (@c_files) {
|
2001-06-19 05:34:39 +02:00
|
|
|
my %insert_line;
|
2001-07-08 22:33:20 +02:00
|
|
|
my %substitute_line;
|
|
|
|
my %delete_line;
|
2001-06-19 05:34:39 +02:00
|
|
|
|
|
|
|
my %spec_file;
|
|
|
|
|
2001-06-13 21:38:29 +02:00
|
|
|
$progress_current++;
|
2001-07-11 19:27:45 +02:00
|
|
|
if($options->progress) {
|
|
|
|
$output->progress("$file: file $progress_current of $progress_max");
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
2001-06-21 00:53:21 +02:00
|
|
|
|
2001-07-24 01:20:56 +02:00
|
|
|
my %documentation_line_used;
|
|
|
|
|
2001-06-13 21:38:29 +02:00
|
|
|
my $found_function = sub {
|
2001-07-11 19:27:45 +02:00
|
|
|
my $function = shift;
|
|
|
|
|
|
|
|
my $documentation_line = $function->documentation_line;
|
|
|
|
my $documentation = $function->documentation;
|
|
|
|
my $function_line = $function->function_line;
|
|
|
|
my $linkage = $function->linkage;
|
|
|
|
my $return_type = $function->return_type;
|
|
|
|
my $calling_convention = $function->calling_convention;
|
|
|
|
my $internal_name = $function->internal_name;
|
|
|
|
my $statements = $function->statements;
|
2001-06-13 21:38:29 +02:00
|
|
|
|
2001-07-24 01:20:56 +02:00
|
|
|
if($linkage eq "static" ||
|
|
|
|
($linkage eq "extern" && !defined($statements)) ||
|
|
|
|
($linkage eq "" && !defined($statements)))
|
|
|
|
{
|
2001-07-02 03:21:48 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
my @external_names = $function->external_names;
|
2001-07-02 03:21:48 +02:00
|
|
|
if($#external_names < 0) {
|
2001-06-13 21:38:29 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-07-24 01:20:56 +02:00
|
|
|
if($documentation_line_used{$documentation_line}) {
|
|
|
|
$documentation = undef;
|
|
|
|
}
|
|
|
|
$documentation_line_used{$documentation_line}++;
|
|
|
|
|
|
|
|
$output->prefix_callback(sub { return $function->prefix; });
|
2001-06-19 05:34:39 +02:00
|
|
|
|
2001-07-13 00:22:05 +02:00
|
|
|
my @module_ordinal_entries = ();
|
|
|
|
foreach my $entry2 ($function->get_all_module_ordinal) {
|
|
|
|
(my $external_name2, my $module2, my $ordinal2) = @$entry2;
|
|
|
|
if(($external_name2 eq "@" ||
|
|
|
|
($win16api->is_module($module2) && !$win16api->is_function_stub_in_module($module2, $external_name2)) ||
|
|
|
|
($win32api->is_module($module2) && !$win32api->is_function_stub_in_module($module2, $external_name2))) &&
|
|
|
|
$modules->is_allowed_module_in_file($module2, "$current_dir/$file"))
|
|
|
|
{
|
|
|
|
push @module_ordinal_entries, $entry2;
|
|
|
|
}
|
|
|
|
}
|
2001-06-19 05:34:39 +02:00
|
|
|
|
2001-07-08 22:33:20 +02:00
|
|
|
my $spec_modified = 0;
|
2001-06-28 20:01:39 +02:00
|
|
|
|
2001-07-24 01:20:56 +02:00
|
|
|
if($options->stub && defined($documentation)) {
|
2001-07-11 19:27:45 +02:00
|
|
|
my $calling_convention16 = $function->calling_convention16;
|
|
|
|
my $calling_convention32 = $function->calling_convention32;
|
|
|
|
|
2001-07-08 22:33:20 +02:00
|
|
|
foreach my $winapi (@winapis) {
|
|
|
|
my @entries = ();
|
2001-07-14 02:48:41 +02:00
|
|
|
my $module = $winapi->function_internal_module($internal_name);
|
|
|
|
my $ordinal = $winapi->function_internal_ordinal($internal_name);
|
2001-07-08 22:33:20 +02:00
|
|
|
|
2001-07-14 02:48:41 +02:00
|
|
|
if($winapi->is_function_stub_in_module($module, $internal_name)) {
|
2001-07-08 22:33:20 +02:00
|
|
|
my $external_name = $internal_name;
|
|
|
|
if($winapi->name eq "win16") {
|
|
|
|
$external_name =~ s/(?:_)?16([AW]?)$//;
|
|
|
|
if(defined($1)) {
|
|
|
|
$external_name .= $1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
push @entries, [$external_name, $module, $ordinal];
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (split(/\n/, $documentation)) {
|
|
|
|
if(/^\s*\*\s*(\S+)\s*[\(\[]\s*(\w+)\s*\.\s*([^\s\)\]]*)\s*[\)\]].*?$/) {
|
|
|
|
my $external_name = $1;
|
|
|
|
my $module = lc($2);
|
|
|
|
my $ordinal = $3;
|
|
|
|
|
|
|
|
if($external_name ne "@" &&
|
|
|
|
$winapi->is_module($module) &&
|
2001-07-14 02:48:41 +02:00
|
|
|
$winapi->is_function_stub_in_module($module, $external_name) &&
|
2001-07-08 22:33:20 +02:00
|
|
|
$internal_name !~ /^\U$module\E_\Q$external_name\E$/)
|
|
|
|
{
|
|
|
|
push @entries, [$external_name, $module, $ordinal];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-07-02 03:21:48 +02:00
|
|
|
|
2001-07-08 22:33:20 +02:00
|
|
|
foreach my $entry (@entries) {
|
|
|
|
(my $external_name, my $module, my $ordinal) = @$entry;
|
2001-07-02 03:21:48 +02:00
|
|
|
|
2001-07-24 01:20:56 +02:00
|
|
|
my $refargument_types = $function->argument_types;
|
|
|
|
|
|
|
|
if(!defined($refargument_types)) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2001-07-08 22:33:20 +02:00
|
|
|
my $abort = 0;
|
|
|
|
my $n;
|
|
|
|
my @argument_kinds = map {
|
|
|
|
my $type = $_;
|
|
|
|
my $kind;
|
|
|
|
if($type ne "..." && !defined($kind = $winapi->translate_argument($type))) {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("no translation defined: " . $type . "\n");
|
2001-07-08 22:33:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# FIXME: Kludge
|
|
|
|
if(defined($kind) && $kind eq "longlong") {
|
|
|
|
$n += 2;
|
|
|
|
("long", "long");
|
|
|
|
} elsif(defined($kind)) {
|
|
|
|
$n++;
|
|
|
|
$kind;
|
|
|
|
} elsif($type eq "...") {
|
|
|
|
if($winapi->name eq "win16") {
|
|
|
|
$calling_convention16 = "pascal"; # FIXME: Is this correct?
|
|
|
|
} else {
|
|
|
|
$calling_convention32 = "varargs";
|
|
|
|
}
|
|
|
|
();
|
|
|
|
} else {
|
|
|
|
$abort = 1;
|
|
|
|
$n++;
|
|
|
|
"undef";
|
|
|
|
}
|
2001-07-24 01:20:56 +02:00
|
|
|
} @$refargument_types;
|
2001-07-08 22:33:20 +02:00
|
|
|
|
|
|
|
my $substitute = {};
|
|
|
|
$substitute->{search} = "^\\s*$ordinal\\s+stub\\s+$external_name\\s*(?:#.*?)?\$";
|
|
|
|
|
|
|
|
if($winapi->name eq "win16") {
|
|
|
|
$substitute->{replace} = "$ordinal $calling_convention16 $external_name(@argument_kinds) $internal_name";
|
|
|
|
} else {
|
|
|
|
$substitute->{replace} = "$ordinal $calling_convention32 $external_name(@argument_kinds) $internal_name";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!defined($spec_file{$module})) {
|
|
|
|
$spec_file{$module} = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!$abort) {
|
|
|
|
$spec_modified = 1;
|
|
|
|
push @{$spec_file{$module}}, $substitute;
|
|
|
|
}
|
|
|
|
}
|
2001-07-02 03:21:48 +02:00
|
|
|
}
|
2001-07-08 22:33:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
my %found_external_names;
|
|
|
|
foreach my $external_name (@external_names) {
|
|
|
|
$found_external_names{$external_name} = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
my $documentation_modified = 0;
|
|
|
|
|
|
|
|
if(!$spec_modified &&
|
2001-07-24 01:20:56 +02:00
|
|
|
(defined($documentation) && !$documentation_modified) &&
|
2001-07-11 19:27:45 +02:00
|
|
|
($options->documentation_name || $options->documentation_ordinal ||
|
2001-07-24 01:20:56 +02:00
|
|
|
$options->documentation_missing))
|
2001-07-08 22:33:20 +02:00
|
|
|
{
|
|
|
|
local $_;
|
2001-07-02 03:21:48 +02:00
|
|
|
|
|
|
|
my $line3;
|
|
|
|
my $search;
|
|
|
|
my $replace;
|
|
|
|
|
|
|
|
my $count = 0;
|
2001-07-11 19:27:45 +02:00
|
|
|
my $line2 = $documentation_line - 1;
|
2001-06-13 21:38:29 +02:00
|
|
|
foreach (split(/\n/, $documentation)) {
|
2001-07-02 03:21:48 +02:00
|
|
|
$line2++;
|
2001-07-08 22:33:20 +02:00
|
|
|
if(/^(\s*\*\s*(\S+)\s*)((?:\s*[\(\[]\s*\w+(?:\s*\.\s*[^\s\)\]]*\s*)?[\)\]])+)(.*?)$/) {
|
2001-06-21 00:53:21 +02:00
|
|
|
my $part1 = $1;
|
|
|
|
my $external_name = $2;
|
|
|
|
my $part3 = $3;
|
|
|
|
my $part4 = $4;
|
2001-06-19 05:34:39 +02:00
|
|
|
|
2001-06-21 00:53:21 +02:00
|
|
|
$part4 =~ s/\s*$//;
|
|
|
|
|
|
|
|
my @entries = ();
|
2001-07-02 03:21:48 +02:00
|
|
|
while($part3 =~ s/^\s*([\(\[]\s*(\w+)(?:\s*\.\s*([^\s\)\]]*)\s*)?[\)\]])//) {
|
|
|
|
push @entries, [$1, $2, $3];
|
|
|
|
}
|
|
|
|
|
|
|
|
my $found = 0;
|
|
|
|
foreach my $external_name2 (@external_names) {
|
|
|
|
if($external_name eq $external_name2) {
|
2001-07-08 22:33:20 +02:00
|
|
|
foreach my $entry (@entries) {
|
|
|
|
(undef, my $module, undef) = @$entry;
|
|
|
|
$found_external_names{$external_name2}{$module} = 1;
|
|
|
|
}
|
2001-07-02 03:21:48 +02:00
|
|
|
$found = 1;
|
|
|
|
last;
|
|
|
|
}
|
2001-06-19 05:34:39 +02:00
|
|
|
}
|
2001-06-21 00:53:21 +02:00
|
|
|
|
|
|
|
my $replaced = 0;
|
2001-07-02 03:21:48 +02:00
|
|
|
my $replace2 = "";
|
2001-06-21 00:53:21 +02:00
|
|
|
foreach my $entry (@entries) {
|
2001-07-02 03:21:48 +02:00
|
|
|
my $part12 = $part1;
|
|
|
|
(my $part32, my $module, my $ordinal) = @$entry;
|
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
foreach my $entry2 (@module_ordinal_entries) {
|
2001-06-28 20:01:39 +02:00
|
|
|
(my $external_name2, my $module2, my $ordinal2) = @$entry2;
|
2001-07-02 03:21:48 +02:00
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
if($options->documentation_name && lc($module) eq $module2 &&
|
2001-07-02 03:21:48 +02:00
|
|
|
$external_name ne $external_name2)
|
|
|
|
{
|
|
|
|
if(!$found && $part12 =~ s/\b\Q$external_name\E\b/$external_name2/) {
|
|
|
|
$external_name = $external_name2;
|
|
|
|
$replaced++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
if($options->documentation_ordinal &&
|
2001-07-02 03:21:48 +02:00
|
|
|
$external_name eq $external_name2 &&
|
|
|
|
lc($module) eq $module2 &&
|
|
|
|
($#entries > 0 || !defined($ordinal) || ($ordinal ne $ordinal2)))
|
2001-06-21 00:53:21 +02:00
|
|
|
{
|
|
|
|
if(defined($ordinal)) {
|
2001-07-02 03:21:48 +02:00
|
|
|
if($part32 =~ s/\Q$module\E\s*.\s*\Q$ordinal\E/\U$module2\E.$ordinal2/ || $#entries > 0) {
|
2001-06-21 00:53:21 +02:00
|
|
|
$replaced++;
|
|
|
|
}
|
|
|
|
} else {
|
2001-07-02 03:21:48 +02:00
|
|
|
if($part32 =~ s/\Q$module\E/\U$module2\E.$ordinal2/ || $#entries > 0) {
|
2001-06-21 00:53:21 +02:00
|
|
|
$replaced++;
|
|
|
|
}
|
|
|
|
}
|
2001-06-19 05:34:39 +02:00
|
|
|
}
|
2001-07-02 03:21:48 +02:00
|
|
|
|
2001-06-21 00:53:21 +02:00
|
|
|
}
|
2001-07-02 03:21:48 +02:00
|
|
|
if($replace2) { $replace2 .= "\n"; }
|
|
|
|
$replace2 .= "$part12$part32$part4";
|
2001-06-21 00:53:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if($replaced > 0) {
|
2001-07-02 03:21:48 +02:00
|
|
|
$line3 = $line2;
|
|
|
|
$search = "^\Q$_\E\$";
|
|
|
|
$replace = $replace2;
|
2001-06-21 00:53:21 +02:00
|
|
|
}
|
2001-07-02 03:21:48 +02:00
|
|
|
$count++;
|
2001-07-08 22:33:20 +02:00
|
|
|
} elsif(/^(\s*\*\s*)([^\s\(]+)(?:\(\))?\s*$/) {
|
2001-06-21 00:53:21 +02:00
|
|
|
my $part1 = $1;
|
|
|
|
my $external_name = $2;
|
2001-07-08 22:33:20 +02:00
|
|
|
|
|
|
|
if($internal_name =~ /^(?:\S+_)?\Q$external_name\E(?:16)?$/) {
|
2001-07-11 19:27:45 +02:00
|
|
|
foreach my $entry (@module_ordinal_entries) {
|
2001-06-28 20:01:39 +02:00
|
|
|
(my $external_name2, my $module, my $ordinal) = @$entry;
|
2001-06-21 00:53:21 +02:00
|
|
|
|
2001-07-02 03:21:48 +02:00
|
|
|
$line3 = $line2;
|
|
|
|
$search = "^\Q$_\E\$";
|
|
|
|
$replace = "$part1$external_name2 (\U$module\E.$ordinal)";
|
2001-06-19 05:34:39 +02:00
|
|
|
}
|
2001-07-08 22:33:20 +02:00
|
|
|
$count++;
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-21 00:53:21 +02:00
|
|
|
|
2001-07-02 03:21:48 +02:00
|
|
|
if(defined($line3) && defined($search) && defined($replace)) {
|
|
|
|
if($count > 1 || $#external_names >= 1) {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("multiple entries (fixup not supported)\n");
|
|
|
|
# $output->write("s/$search/$replace/\n");
|
|
|
|
# $output->write("@external_names\n");
|
2001-07-02 03:21:48 +02:00
|
|
|
} else {
|
2001-07-08 22:33:20 +02:00
|
|
|
$documentation_modified = 1;
|
2001-07-24 01:20:56 +02:00
|
|
|
|
2001-07-02 03:21:48 +02:00
|
|
|
$substitute_line{$line3}{search} = $search;
|
|
|
|
$substitute_line{$line3}{replace} = $replace;
|
2001-07-08 22:33:20 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!$spec_modified && !$documentation_modified &&
|
2001-07-24 01:20:56 +02:00
|
|
|
$options->documentation_missing && defined($documentation))
|
2001-07-08 22:33:20 +02:00
|
|
|
{
|
|
|
|
my $part1;
|
|
|
|
my $part2;
|
|
|
|
my $part3;
|
|
|
|
my $part4;
|
|
|
|
my $line3 = 0;
|
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
my $line2 = $documentation_line - 1;
|
2001-07-08 22:33:20 +02:00
|
|
|
foreach (split(/\n/, $documentation)) {
|
|
|
|
$line2++;
|
|
|
|
if(/^(\s*\*\s*)(\S+\s*)([\(\[])\s*\w+\s*\.\s*[^\s\)\]]*\s*([\)\]]).*?$/) {
|
|
|
|
$part1 = $1;
|
|
|
|
$part2 = $2;
|
|
|
|
$part3 = $3;
|
|
|
|
$part4 = $4;
|
|
|
|
|
|
|
|
$part2 =~ s/\S/ /g;
|
|
|
|
|
|
|
|
$line3 = $line2 + 1;
|
2001-06-28 20:01:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
foreach my $entry2 (@module_ordinal_entries) {
|
2001-07-08 22:33:20 +02:00
|
|
|
(my $external_name2, my $module2, my $ordinal2) = @$entry2;
|
|
|
|
|
|
|
|
my $found = 0;
|
2001-07-02 03:21:48 +02:00
|
|
|
foreach my $external_name (keys(%found_external_names)) {
|
2001-07-08 22:33:20 +02:00
|
|
|
foreach my $module3 (keys(%{$found_external_names{$external_name}})) {
|
|
|
|
if($external_name eq $external_name2 && uc($module2) eq $module3) {
|
|
|
|
$found = 1;
|
|
|
|
}
|
2001-06-21 00:53:21 +02:00
|
|
|
}
|
2001-07-08 22:33:20 +02:00
|
|
|
}
|
|
|
|
# FIXME: Not 100% correct
|
|
|
|
if(!$found &&
|
2001-07-14 02:48:41 +02:00
|
|
|
!$win16api->is_function_stub_in_module($module2, $internal_name) &&
|
|
|
|
!$win32api->is_function_stub_in_module($module2, $internal_name))
|
2001-07-08 22:33:20 +02:00
|
|
|
{
|
|
|
|
if($line3 > 0) {
|
2001-07-24 01:20:56 +02:00
|
|
|
$documentation_modified = 1;
|
|
|
|
|
2001-07-08 22:33:20 +02:00
|
|
|
$part2 = $external_name2 . " " x (length($part2) - length($external_name2));
|
|
|
|
$insert_line{$line3} = "$part1$part2$part3\U$module2\E.$ordinal2$part4\n";
|
|
|
|
} else {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("$external_name2 (\U$module2\E.$ordinal2) missing (fixup not supported)\n");
|
2001-07-08 22:33:20 +02:00
|
|
|
}
|
|
|
|
}
|
2001-06-28 20:01:39 +02:00
|
|
|
}
|
2001-06-21 00:53:21 +02:00
|
|
|
}
|
|
|
|
|
2001-07-08 22:33:20 +02:00
|
|
|
if(!$documentation_modified &&
|
2001-07-24 01:20:56 +02:00
|
|
|
defined($documentation) &&
|
2001-07-11 19:27:45 +02:00
|
|
|
$options->documentation_wrong)
|
2001-07-08 22:33:20 +02:00
|
|
|
{
|
2001-07-11 19:27:45 +02:00
|
|
|
my $line2 = $documentation_line - 1;
|
2001-07-08 22:33:20 +02:00
|
|
|
foreach (split(/\n/, $documentation)) {
|
|
|
|
$line2++;
|
|
|
|
if(/^\s*\*\s*(\S+)\s*[\(\[]\s*(\w+)\s*\.\s*([^\s\)\]]*)\s*[\)\]].*?$/) {
|
|
|
|
my $external_name = $1;
|
|
|
|
my $module = $2;
|
|
|
|
my $ordinal = $3;
|
|
|
|
|
|
|
|
my $found = 0;
|
2001-07-11 19:27:45 +02:00
|
|
|
foreach my $entry2 (@module_ordinal_entries) {
|
2001-07-08 22:33:20 +02:00
|
|
|
(my $external_name2, my $module2, my $ordinal2) = @$entry2;
|
2001-07-13 00:22:05 +02:00
|
|
|
|
2001-07-08 22:33:20 +02:00
|
|
|
if($external_name eq $external_name2 &&
|
|
|
|
lc($module) eq $module2 &&
|
|
|
|
$ordinal eq $ordinal2)
|
|
|
|
{
|
|
|
|
$found = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!$found) {
|
|
|
|
if(1) {
|
2001-07-24 01:20:56 +02:00
|
|
|
$documentation_modified = 1;
|
|
|
|
|
2001-07-08 22:33:20 +02:00
|
|
|
$delete_line{$line2} = "^\Q$_\E\$";
|
|
|
|
} else {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("$external_name (\U$module\E.$ordinal) wrong (fixup not supported)\n");
|
2001-07-08 22:33:20 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-24 01:20:56 +02:00
|
|
|
if(!$spec_modified && !$documentation_modified && !defined($documentation))
|
2001-07-08 22:33:20 +02:00
|
|
|
{
|
2001-07-24 01:20:56 +02:00
|
|
|
my $insert = "";
|
2001-06-13 21:38:29 +02:00
|
|
|
foreach my $winapi (@winapis) {
|
2001-07-24 01:20:56 +02:00
|
|
|
my $external_name = $winapi->function_external_name($internal_name);
|
|
|
|
my $module = $winapi->function_internal_module($internal_name);
|
|
|
|
my $ordinal = $winapi->function_internal_ordinal($internal_name);
|
2001-06-13 21:38:29 +02:00
|
|
|
|
2001-07-24 01:20:56 +02:00
|
|
|
if(defined($external_name) && defined($module) && defined($ordinal)) {
|
|
|
|
$insert .= " *\t\t$external_name (\U$module\E.$ordinal)\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($insert) {
|
2001-07-11 19:27:45 +02:00
|
|
|
$insert_line{$function_line} =
|
2001-06-13 21:38:29 +02:00
|
|
|
"/" . "*" x 71 . "\n" .
|
2001-07-24 01:20:56 +02:00
|
|
|
"$insert" .
|
2001-06-13 21:38:29 +02:00
|
|
|
" */\n";
|
|
|
|
}
|
|
|
|
}
|
2001-06-19 05:34:39 +02:00
|
|
|
|
|
|
|
$output->prefix("");
|
2001-06-13 21:38:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
my $found_preprocessor = sub {
|
|
|
|
my $directive = shift;
|
|
|
|
my $argument = shift;
|
|
|
|
};
|
|
|
|
|
2001-07-24 01:20:56 +02:00
|
|
|
&winapi_parser::parse_c_file($options, $file, $found_function, $found_preprocessor);
|
2001-06-13 21:38:29 +02:00
|
|
|
|
|
|
|
my $editor = sub {
|
|
|
|
local *IN = shift;
|
|
|
|
local *OUT = shift;
|
|
|
|
|
|
|
|
my $modified = 0;
|
|
|
|
while(<IN>) {
|
|
|
|
chomp;
|
|
|
|
|
2001-07-08 22:33:20 +02:00
|
|
|
my $line;
|
|
|
|
|
|
|
|
$line = $insert_line{$.};
|
2001-06-13 21:38:29 +02:00
|
|
|
if(defined($line)) {
|
2001-07-11 19:27:45 +02:00
|
|
|
if($options->modify) {
|
2001-06-13 21:38:29 +02:00
|
|
|
$_ = "$line$_";
|
|
|
|
$modified = 1;
|
|
|
|
} else {
|
2001-07-08 22:33:20 +02:00
|
|
|
my $line2 = $line; chomp($line2);
|
|
|
|
my @line2 = split(/\n/, $line2);
|
|
|
|
if($#line2 > 0) {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("$file: $.: insert: \\\n");
|
2001-07-08 22:33:20 +02:00
|
|
|
foreach my $line2 (@line2) {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("'$line2'\n");
|
2001-07-08 22:33:20 +02:00
|
|
|
}
|
|
|
|
} else {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("$file: $.: insert: '$line2'\n");
|
2001-07-08 22:33:20 +02:00
|
|
|
}
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-02 03:21:48 +02:00
|
|
|
my $search = $substitute_line{$.}{search};
|
|
|
|
my $replace = $substitute_line{$.}{replace};
|
2001-06-13 21:38:29 +02:00
|
|
|
|
|
|
|
if(defined($search) && defined($replace)) {
|
2001-06-21 00:53:21 +02:00
|
|
|
my $modified2 = 0;
|
2001-07-02 03:21:48 +02:00
|
|
|
if(s/$search/$replace/) {
|
2001-07-11 19:27:45 +02:00
|
|
|
if($options->modify) {
|
2001-06-13 21:38:29 +02:00
|
|
|
$modified = 1;
|
2001-06-21 00:53:21 +02:00
|
|
|
}
|
2001-07-02 03:21:48 +02:00
|
|
|
$modified2 = 1;
|
2001-06-21 00:53:21 +02:00
|
|
|
}
|
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
if(!$options->modify || !$modified2) {
|
2001-06-21 00:53:21 +02:00
|
|
|
my $search2;
|
|
|
|
my $replace2;
|
2001-07-02 03:21:48 +02:00
|
|
|
if(!$modified2) {
|
2001-06-21 00:53:21 +02:00
|
|
|
$search2 = "unmatched search";
|
|
|
|
$replace2 = "unmatched replace";
|
|
|
|
} else {
|
|
|
|
$search2 = "search";
|
|
|
|
$replace2 = "replace";
|
|
|
|
}
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("$file: $.: $search2 : '$search'\n");
|
2001-06-21 00:53:21 +02:00
|
|
|
|
|
|
|
my @replace2 = split(/\n/, $replace);
|
|
|
|
if($#replace2 > 0) {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("$file: $.: $replace2: \\\n");
|
2001-06-21 00:53:21 +02:00
|
|
|
foreach my $replace2 (@replace2) {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("'$replace2'\n");
|
2001-06-21 00:53:21 +02:00
|
|
|
}
|
|
|
|
} else {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("$file: $.: $replace2: '$replace'\n");
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-07-08 22:33:20 +02:00
|
|
|
|
|
|
|
$line = $delete_line{$.};
|
|
|
|
if(defined($line)) {
|
|
|
|
if(/$line/) {
|
2001-07-11 19:27:45 +02:00
|
|
|
if($options->modify) {
|
2001-07-08 22:33:20 +02:00
|
|
|
$modified = 1;
|
|
|
|
next;
|
|
|
|
} else {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("$file: $.: delete: '$line'\n");
|
2001-07-08 22:33:20 +02:00
|
|
|
}
|
|
|
|
} else {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("$file: $.: unmatched delete: '$line'\n");
|
2001-07-08 22:33:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-13 21:38:29 +02:00
|
|
|
print OUT "$_\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
return $modified;
|
|
|
|
};
|
|
|
|
|
2001-07-08 22:33:20 +02:00
|
|
|
my $n = 0;
|
|
|
|
while(defined(each %insert_line)) { $n++; }
|
|
|
|
while(defined(each %substitute_line)) { $n++; }
|
|
|
|
while(defined(each %delete_line)) { $n++; }
|
2001-06-19 05:34:39 +02:00
|
|
|
if($n > 0) {
|
|
|
|
edit_file($file, $editor);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $module (sort(keys(%spec_file))) {
|
|
|
|
my $file;
|
|
|
|
foreach my $winapi (@winapis) {
|
|
|
|
$file = ($winapi->module_file($module) || $file);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(defined($file)) {
|
|
|
|
$file = file_normalize($file);
|
|
|
|
}
|
|
|
|
|
|
|
|
my @substitutes = @{$spec_file{$module}};
|
|
|
|
|
|
|
|
my $editor = sub {
|
|
|
|
local *IN = shift;
|
|
|
|
local *OUT = shift;
|
|
|
|
|
|
|
|
my $modified = 0;
|
|
|
|
while(<IN>) {
|
|
|
|
chomp;
|
|
|
|
|
2001-06-21 00:53:21 +02:00
|
|
|
my @substitutes2 = ();
|
2001-06-19 05:34:39 +02:00
|
|
|
foreach my $substitute (@substitutes) {
|
|
|
|
my $search = $substitute->{search};
|
|
|
|
my $replace = $substitute->{replace};
|
|
|
|
|
|
|
|
if(s/$search/$replace/) {
|
2001-07-11 19:27:45 +02:00
|
|
|
if($options->modify) {
|
2001-06-19 05:34:39 +02:00
|
|
|
$modified = 1;
|
2001-07-02 03:21:48 +02:00
|
|
|
} else {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("$file: search : '$search'\n");
|
|
|
|
$output->write("$file: replace: '$replace'\n");
|
2001-06-19 05:34:39 +02:00
|
|
|
}
|
2001-06-21 00:53:21 +02:00
|
|
|
next;
|
|
|
|
} else {
|
|
|
|
push @substitutes2, $substitute;
|
2001-06-19 05:34:39 +02:00
|
|
|
}
|
|
|
|
}
|
2001-06-21 00:53:21 +02:00
|
|
|
@substitutes = @substitutes2;
|
2001-06-19 05:34:39 +02:00
|
|
|
|
|
|
|
print OUT "$_\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
return $modified;
|
|
|
|
};
|
|
|
|
|
|
|
|
if(defined($file)) {
|
|
|
|
edit_file($file, $editor);
|
|
|
|
} else {
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("$module: doesn't have any spec file\n");
|
2001-06-19 05:34:39 +02:00
|
|
|
}
|
2001-06-21 00:53:21 +02:00
|
|
|
|
|
|
|
if($#substitutes >= 0) {
|
|
|
|
foreach my $substitute (@substitutes) {
|
|
|
|
my $search = $substitute->{search};
|
|
|
|
my $replace = $substitute->{replace};
|
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->write("$file: unmatched search : '$search'\n");
|
|
|
|
$output->write("$file: unmatched replace: '$replace'\n");
|
2001-06-21 00:53:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-19 05:34:39 +02:00
|
|
|
}
|
2001-06-13 21:38:29 +02:00
|
|
|
}
|
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
$output->hide_progress;
|