3 # Copyright 2002 Patrik Stridvall
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 $0 =~ m
%^(.*?
/?tools)/winapi
/winapi_cleanup
$%;
24 require "$1/winapi/setup.pm";
27 use config
qw($current_dir $wine_dir);
28 use output qw($output);
29 use winapi_cleanup_options qw($options);
31 use util qw(edit_file);
33 if($options->progress) {
34 $output->enable_progress;
36 $output->disable_progress;
39 ########################################################################
48 my $format_comments = sub {
50 if ($#comments == 0) {
51 my $comment = $comments[0];
53 $_ = "$indent/*$comment */";
54 } elsif ($#comments > 0) {
56 foreach my $comment (@comments) {
57 $_ .= "$indent *$comment\n";
72 if ($options->trailing_whitespace) {
73 s/(.*?)\s+$/$1/ && do { $modified = 1; };
75 s/(.*?)\r$/$1/ && do { $modified = 1; };
78 if ($options->cpp_comments) {
83 } elsif (/^([^\"\/]*?
(?
:\"[^\"]*?
\"[^\"]*?
)*?
)\
/\*(.*?)$/) {
86 if($comment !~ /^.*?\*\//) {
89 } elsif (/^([^\"\/]*?
(?
:\"[^\"]*?
\"[^\"]*?
)*?
)\
/\/(.*?
)\s
*$/) {
93 if ($indent2 =~ /^\s*$/) {
94 if (!$indent || $indent eq $indent2) {
96 push @comments, $comment;
99 $_ .= "$indent2/*$comment */";
102 my $comments = &$format_comments();
104 $_ = "$comments\n$indent2/*$comment */";
106 $_ = "$indent2/*$comment */";
112 my $comments = &$format_comments();
114 $_ = "$comments\n$_";
123 my $comments = &$format_comments();
125 print OUT
"$comments\n";
132 ########################################################################
135 my @h_files = $options->h_files;
136 my @c_files = $options->c_files;
139 my $progress_current = 0;
140 my $progress_max = scalar(@h_files) + scalar(@c_files);
142 foreach my $file (@h_files) {
144 $output->progress("$file (file $progress_current of $progress_max)");
146 if (edit_file
($file, \
&cleanup_file
, @_)) {
147 $output->write("$file: modified\n");
151 foreach my $file (@c_files) {
153 $output->progress("$file (file $progress_current of $progress_max)");
155 if (edit_file
($file, \
&cleanup_file
, @_)) {
156 $output->write("$file: modified\n");