Include guiddef.h in widltypes.h.
[wine/multimedia.git] / tools / winapi / winapi_cleanup
blob2918a656255b7084291606bea88114a744102742
1 #! /usr/bin/perl -w
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
20 use strict;
22 BEGIN {
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;
35 } else {
36 $output->disable_progress;
39 ########################################################################
40 # cleanup_file
42 sub cleanup_file {
43 local *IN = shift;
44 local *OUT = shift;
46 my $indent;
47 my @comments = ();
48 my $format_comments = sub {
49 local $_ = "";
50 if ($#comments == 0) {
51 my $comment = $comments[0];
53 $_ = "$indent/*$comment */";
54 } elsif ($#comments > 0) {
55 $_ = "$indent/*\n";
56 foreach my $comment (@comments) {
57 $_ .= "$indent *$comment\n";
59 $_ .= "$indent */";
61 $indent = "";
62 @comments = ();
64 return $_;
67 my $in_comment = 0;
68 my $modified = 0;
69 while (<IN>) {
70 chomp;
72 if ($options->trailing_whitespace) {
73 s/(.*?)\s+$/$1/ && do { $modified = 1; };
74 } else {
75 s/(.*?)\r$/$1/ && do { $modified = 1; };
78 if ($options->cpp_comments) {
79 if ($in_comment) {
80 if(/^.*?\*\//) {
81 $in_comment = 0;
83 } elsif (/^([^\"\/]*?(?:\"[^\"]*?\"[^\"]*?)*?)\/\*(.*?)$/) {
84 my $indent2 = $1;
85 my $comment = $2;
86 if($comment !~ /^.*?\*\//) {
87 $in_comment = 1;
89 } elsif (/^([^\"\/]*?(?:\"[^\"]*?\"[^\"]*?)*?)\/\/(.*?)\s*$/) {
90 my $indent2 = $1;
91 my $comment = $2;
93 if ($indent2 =~ /^\s*$/) {
94 if (!$indent || $indent eq $indent2) {
95 $indent = $indent2;
96 push @comments, $comment;
97 next;
98 } else {
99 $_ .= "$indent2/*$comment */";
101 } else {
102 my $comments = &$format_comments();
103 if ($comments) {
104 $_ = "$comments\n$indent2/*$comment */";
105 } else {
106 $_ = "$indent2/*$comment */";
109 $modified = 1;
111 } else {
112 my $comments = &$format_comments();
113 if ($comments) {
114 $_ = "$comments\n$_";
115 $modified = 1;
120 print OUT "$_\n";
123 my $comments = &$format_comments();
124 if ($comments) {
125 print OUT "$comments\n";
126 $modified = 1;
129 return $modified;
132 ########################################################################
133 # main
135 my @h_files = $options->h_files;
136 my @c_files = $options->c_files;
138 my $progress_output;
139 my $progress_current = 0;
140 my $progress_max = scalar(@h_files) + scalar(@c_files);
142 foreach my $file (@h_files) {
143 $progress_current++;
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) {
152 $progress_current++;
153 $output->progress("$file (file $progress_current of $progress_max)");
155 if (edit_file($file, \&cleanup_file, @_)) {
156 $output->write("$file: modified\n");