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

- FreeBSD now supported.

- Much more work on the new C parser. - API files update.
parent 872784fc
......@@ -80,20 +80,22 @@ sub line {
my $progress = "";
if($directory && $directory ne ".") {
$progress .= "$directory: ";
}
if($tool) {
$progress .= "$tool: ";
}
$progress .= "$tool: ";
if($tool =~ /^cd|make$/) {
# Nothing
} elsif($tool =~ /^ld$/) {
foreach my $file (@{$read_files}) {
$output->lazy_progress("$progress: reading '$file'");
$output->lazy_progress("${progress}reading '$file'");
}
my $file = $$write_files[0];
$output->progress("$progress: writing '$file'");
} elsif($tool =~ /^rm$/) {
foreach my $file (@{$remove_files}) {
$output->lazy_progress("$progress: removing '$file'");
$output->lazy_progress("${progress}removing '$file'");
}
} else {
if($#$read_files >= 0) {
......@@ -118,24 +120,34 @@ sub line {
return 0;
}
my $make = $options->make;
if(/^Wine build complete\.$/) {
# Nothing
} elsif(/^(.*?) is newer than (.*?), please rerun (.*?)\!$/) {
$message = "$_";
} elsif(/^(.*?) is older than (.*?), please rerun (.*?)$/) {
$message = "$_";
} elsif(s/^make(?:\[(\d+)\])?:\s*//) {
} elsif(/^\`(.*?)\' is up to date.$/) {
$tool = "make";
make_output($1, $_);
} elsif(s/^$make(?:\[(\d+)\])?:\s*//) {
$tool = "make";
make_output($1, $_);
} elsif(!defined($tool)) {
error("line");
} elsif($tool eq "make") {
make_output($1, $_);
} elsif($tool eq "bison" && /^conflicts:\s+\d+\s+shift\/reduce$/) {
# Nothing
} elsif($tool eq "gcc" && /^(?:In file included |\s*)from (.+?):(\d+)[,:]$/) {
# Nothing
} elsif($tool =~ /^gcc|ld$/ && s/^(.+?\.s?o)(?:\(.*?\))?:\s*//) {
$tool = "ld";
ld_output($1, $_);
ld_output($1, $_)
} elsif($tool =~ /^gcc|ld$/ && s/^(.*?)ld:\s*//) {
$tool = "ld";
ld_output("", $_)
} elsif($tool =~ /^gcc|ld$/ && s/^collect2:\s*//) {
$tool = "ld";
ld_output("collect2", $_);
......@@ -149,6 +161,8 @@ sub line {
wrc_output($1, $_);
} elsif($tool eq "cd" && s/^\/bin\/sh:\s*cd:\s*//) {
parse_cd_output($_);
} elsif(/^\s*$/) {
# Nothing
} else {
error("line");
}
......@@ -172,7 +186,9 @@ sub make_output {
if(0) {
# Nothing
} elsif(/^\*\*\* \[(.*?)\] Error (\d+)$/) {
$message = "$_";
# Nothing
} elsif(/^\*\*\* Error code (\d+)$/) {
# Nothing
} elsif(/^\*\*\* Warning:\s+/) { #
if(/^File \`(.+?)\' has modification time in the future \((.+?) > \(.+?\)\)$/) {
# Nothing
......@@ -183,6 +199,8 @@ sub make_output {
# Nothing
} elsif(/^\[(.*?)\] Error (\d+) \(ignored\)$/) {
# Nothing
} elsif(/^don\'t know how to make (.*?)\. Stop$/) {
$message = "$_";
} elsif(/^(Entering|Leaving) directory \`(.*?)\'$/) {
if($1 eq "Entering") {
$directory = $2;
......@@ -209,6 +227,10 @@ sub make_output {
} else {
error("make_output");
}
} elsif(/^Stop in (.*?)\.$/) {
# Nothing
} elsif(/^\s*$/) {
# Nothing
} else {
error("make_output");
}
......@@ -399,13 +421,27 @@ sub gcc_command {
my $write_files;
if(/-o\s+(\S+)\s+(\S+)$/) {
$write_files = [$1];
$read_files = [$2];
my $write_file = $1;
my $read_file = $2;
$write_file =~ s%^\./%%;
$read_file =~ s%^\./%%;
$write_files = [$write_file];
$read_files = [$read_file];
} elsif(/-o\s+(\S+)/) {
$write_files = [$1];
my $write_file = $1;
$write_file =~ s%^\./%%;
$write_files = [$write_file];
$read_files = ["<???>"];
} elsif(/^-shared.*?-o\s+(\S+)/) {
$write_files = [$1];
my $write_file = $1;
$write_file =~ s%^\./%%;
$write_files = [$write_file];
$read_files = ["<???>"];
} else {
error("gcc_command");
......@@ -588,8 +624,16 @@ sub ld_output {
# Nothing
} elsif(/^In function \`(.*?)\':$/) {
$function = $1;
} elsif(0 && /^the use of \`(.+?)\' is dangerous, better use \`(.+?)\'$/) {
} elsif(/^more undefined references to \`(.*?)\' follow$/) {
# Nothing
} elsif(/^the use of \`(.+?)\' is dangerous, better use \`(.+?)\'$/) {
# Nothing
} elsif(/^undefined reference to \`(.*?)\'$/) {
# Nothing
} elsif(/^warning: (.*?)\(\) possibly used unsafely; consider using (.*?)\(\)$/) {
# Nothing
} elsif(/^warning: type and size of dynamic symbol \`(.*?)\' are not defined$/) {
$message = "$_";
} else {
$message = "$_";
}
......
......@@ -63,6 +63,7 @@ sub new {
$self->options_set("default");
my $arguments = \@{$self->{_ARGUMENTS}};
@$arguments = ();
my $end_of_options = 0;
while(defined($_ = shift @ARGV)) {
......@@ -121,6 +122,9 @@ sub new {
}
if(defined($parser)) {
if(!defined($value)) {
$value = shift @ARGV;
}
$$refvalue = &$parser($prefix,$value);
} else {
if(defined($value)) {
......
......@@ -137,10 +137,17 @@ sub progress {
my $progress = \${$self->{PROGRESS}};
my $last_time = \${$self->{LAST_TIME}};
$$progress = shift;
my $new_progress = shift;
if(defined($new_progress)) {
if(!defined($$progress) || $new_progress ne $$progress) {
$$progress = $new_progress;
$self->update_progress;
$$last_time = 0;
$self->update_progress;
$$last_time = 0;
}
} else {
return $$progress;
}
}
sub lazy_progress {
......@@ -164,8 +171,10 @@ sub prefix {
my $new_prefix = shift;
if(defined($new_prefix)) {
$$prefix = $new_prefix;
$$prefix_callback = undef;
if(!defined($$prefix) || $new_prefix ne $$prefix) {
$$prefix = $new_prefix;
$$prefix_callback = undef;
}
} else {
return $$prefix;
}
......
......@@ -53,9 +53,43 @@ foreach my $file (@c_files) {
$_ = <IN>;
close(IN);
}
my $max_line = 0;
{
local $_ = $_;
while(s/^.*?\n//) { $max_line++; }
if($_) { $max_line++; }
}
my $parser = new c_parser($file);
my $function;
my $line;
my $update_output = sub {
my $progress = "";
my $prefix = "";
$progress .= "$file (file $progress_current of $progress_max)";
$prefix .= "$file:";
if(defined($function)) {
my $name = $function->name;
my $begin_line = $function->begin_line;
my $begin_column = $function->begin_column;
$progress .= ": function $name";
$prefix .= "$begin_line.$begin_column: function $name: ";
}
if(defined($line)) {
$progress .= ": line $line of $max_line";
}
$output->progress($progress);
$output->prefix($prefix);
};
my $found_preprocessor = sub {
my $begin_line = shift;
my $begin_column = shift;
......@@ -80,6 +114,17 @@ foreach my $file (@c_files) {
$parser->set_found_comment_callback($found_comment);
my $found_line = sub {
$line = shift;
# local $_ = shift;
&$update_output;
# $output->progress("$file: line $line of ?");
};
$parser->set_found_line_callback($found_line);
my $found_declaration = sub {
my $begin_line = shift;
my $begin_column = shift;
......@@ -94,19 +139,17 @@ foreach my $file (@c_files) {
$parser->set_found_declaration_callback($found_declaration);
my $function;
my $found_function = sub {
$function = shift;
&$update_output;
my $name = $function->name;
my $begin_line = $function->begin_line;
my $begin_column = $function->begin_column;
$output->progress("$file (file $progress_current of $progress_max): $name");
$output->prefix("$file:$begin_line: function $name: ");
# $output->prefix_callback(sub { return $function->prefix; });
my $end_line = $function->end_line;
my $end_column = $function->end_column;
if($options->documentation) {
# fixup_documentation($function, $editor);
}
......@@ -119,6 +162,8 @@ foreach my $file (@c_files) {
if(!defined($statements)) {
$function = undef;
$output->prefix("$file: ");
} else {
# $output->write("$begin_line.$begin_column-$end_line.$end_column: function $name\n");
}
return 0;
......@@ -133,20 +178,38 @@ foreach my $file (@c_files) {
my $type = shift;
my $name = shift;
# $output->write("$begin_line.$begin_column: $linkage $type $name\n");
# $output->write("$begin_line.$begin_column: $linkage $type $name = /* ... */\n");
return 1;
};
$parser->set_found_variable_callback($found_variable);
my $line = 1;
my $column = 0;
if(!$parser->parse_c_file(\$_, \$line, \$column)) {
$output->write("can't parse file\n");
my $found_function_call = sub {
my $begin_line = shift;
my $begin_column = shift;
my $end_line = shift;
my $end_column = shift;
my $name = shift;
my $arguments = shift;
$output->write("$begin_line.$begin_column-$end_line.$end_column: $name(" . join(", ", @$arguments) . ")\n");
return 1;
};
$parser->set_found_function_call_callback($found_function_call);
{
my $line = 1;
my $column = 0;
if(!$parser->parse_c_file(\$_, \$line, \$column)) {
$output->write("can't parse file\n");
}
}
$output->prefix("");
$editor->flush;
}
......@@ -162,20 +162,26 @@ sub fixup_user_message_2_windowsx {
}
########################################################################
# _fixup_user_message
# _get_messages
sub _get_messages {
local $_ = shift;
if(/^WM_\w+$/) {
return ($_)
} elsif(/^(.*?)\s*\?\s*(WM_\w+)\s*:\s*(WM_\w+)$/) {
if(/^(?:BM|CB|EM|LB|STM|WM)_\w+(.*?)$/) {
if(!$1) {
return ($_);
} else {
return ();
}
} elsif(/^(.*?)\s*\?\s*((?:BM|CB|EM|LB|STM|WM)_\w+)\s*:\s*((?:BM|CB|EM|LB|STM|WM)_\w+)$/) {
return ($2, $3);
} elsif(/^\w+$/) {
return ();
} elsif(/^RegisterWindowMessage[AW]\s*\(.*?\)$/) {
return ();
} else {
$output->write("_fixup_user_message: '$_'\n");
exit 1;
$output->write("warning: _get_messages: '$_'\n");
return ();
}
}
......@@ -215,7 +221,9 @@ sub _fixup_user_message {
if(!defined($kind)) {
if($msg =~ /^WM_/) {
$output->write("messsage $msg not defined\n");
$output->write("messsage $msg not properly defined\n");
$modified = 0;
last;
}
} elsif($kind eq "ptr") {
if($$refparam =~ /^(\(${upper}PARAM\))?\s*($lower[pP]aram)$/) {
......@@ -263,15 +271,6 @@ sub fixup_statements {
return;
}
if(0 && $statements_line > 490) {
$output->write("$statements_line: \\\n");
my $line = $statements_line;
foreach my $statement (split(/\n/, $statements)) {
$output->write("$line: $statement\n");
$line++;
}
}
my $parser = new c_parser($file);
my $found_function_call = sub {
......@@ -302,7 +301,7 @@ sub fixup_statements {
if(defined($replace)) {
$editor->replace($begin_line, $begin_column, $end_line, $end_column, $replace);
}
} elsif(0 || $options->debug) {
} elsif($options->debug) {
$output->write("$begin_line.$begin_column-$end_line.$end_column: " .
"$name(" . join(", ", @$arguments) . ")\n");
}
......
......@@ -11,7 +11,7 @@ u_long
%ptr
INT16 *
LPWSADATA
LPWSADATA16
ULONG *
char *
struct sockaddr *
......
%long
DWORD
HRESULT
%ptr
......@@ -7,3 +8,11 @@ HRESULT
CLSID *
IID *
void **
%str
LPSTR
%wstr
LPWSTR
......@@ -18,8 +18,10 @@ RPC_AUTH_KEY_RETRIEVAL_FN
RPC_BINDING_HANDLE *
RPC_IF_CALLBACK_FN *
RPC_MGR_EPV *
RPC_STATUS *
UUID *
unsigned char **
unsigned short
void **
%str
......
......@@ -169,7 +169,9 @@ if($options->headers) {
} elsif($options->headers_duplicated) {
my $file = $previous_function->file;
my $function_line = $previous_function->function_line;
$output->write("duplicate declaration (first declaration at $file:$function_line)\n");
if($file =~ /\.h$/) {
$output->write("duplicate declaration (first declaration at $file:$function_line)\n");
}
}
}
$output->prefix("");
......
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