WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
12284
Clean up the header guards
https://bugs.webkit.org/show_bug.cgi?id=12284
Summary
Clean up the header guards
Eric Seidel (no email)
Reported
2007-01-15 08:06:46 PST
Everyone enjoys a good full-recompile every now and then. It's like fiber. Good for the system, and all that.
Attachments
do it
(53.95 KB, patch)
2007-01-15 08:07 PST
,
Eric Seidel (no email)
no flags
Details
Formatted Diff
Diff
better patch
(54.55 KB, patch)
2007-01-15 08:21 PST
,
Eric Seidel (no email)
rwlbuis
: review+
Details
Formatted Diff
Diff
go whole-hog
(200.56 KB, patch)
2007-01-15 09:07 PST
,
Eric Seidel (no email)
rwlbuis
: review-
Details
Formatted Diff
Diff
updated patch
(187.05 KB, patch)
2007-01-15 14:26 PST
,
Eric Seidel (no email)
no flags
Details
Formatted Diff
Diff
a script to do this in the future
(573 bytes, text/x-ruby-script)
2007-01-15 14:27 PST
,
Eric Seidel (no email)
no flags
Details
real, working script.
(1.89 KB, patch)
2007-01-15 14:54 PST
,
Eric Seidel (no email)
no flags
Details
Formatted Diff
Diff
automatic changes from script
(236.17 KB, patch)
2007-01-15 15:10 PST
,
Eric Seidel (no email)
mrowe
: review+
Details
Formatted Diff
Diff
even better script (with changelog!)
(2.27 KB, patch)
2007-01-15 15:11 PST
,
Eric Seidel (no email)
no flags
Details
Formatted Diff
Diff
now pimped out with spinners and neons, oh boy. (and a --prefix option for darin)
(2.59 KB, patch)
2007-01-15 15:43 PST
,
Eric Seidel (no email)
mrowe
: review+
Details
Formatted Diff
Diff
Show Obsolete
(7)
View All
Add attachment
proposed patch, testcase, etc.
Eric Seidel (no email)
Comment 1
2007-01-15 08:07:29 PST
Created
attachment 12456
[details]
do it
Eric Seidel (no email)
Comment 2
2007-01-15 08:21:08 PST
Created
attachment 12458
[details]
better patch
Rob Buis
Comment 3
2007-01-15 08:24:45 PST
Comment on
attachment 12458
[details]
better patch Only issue is _h vs. _H, but apart from that looks fine.
Eric Seidel (no email)
Comment 4
2007-01-15 09:07:54 PST
Created
attachment 12459
[details]
go whole-hog What started as a small waste of time, turned into a big waste of time, ugh. I compiled with andersca, weinig, and rwlbuis's request to change _H to _h. I even updated the style guidelines to help with future consistency. There are still a few strange guards in the editing files, but most all of the headers now have consistently named header guards.
Darin Adler
Comment 5
2007-01-15 11:13:02 PST
I'd like to see a script that fixes all the header guards that we could run from time to time. That could eliminate any future waste of time on this.
Rob Buis
Comment 6
2007-01-15 11:48:21 PST
Comment on
attachment 12459
[details]
go whole-hog IMHO the line between #ifndef and #define should go, as well as the empty line after that (bad regexp?). Apart from that you probably want HTMLPARSER_h not too be all uppercase. Finally it would be neat if #endif could comment the include header too (#endif // Foo_h)
Eric Seidel (no email)
Comment 7
2007-01-15 13:43:38 PST
I wrote one eons ago. But at 4 am I didn't know where to find it. I've since found it... or at least one partial version, attached to:
http://bugs.webkit.org/show_bug.cgi?id=10490
Eric Seidel (no email)
Comment 8
2007-01-15 14:26:51 PST
Created
attachment 12467
[details]
updated patch
Eric Seidel (no email)
Comment 9
2007-01-15 14:27:55 PST
Created
attachment 12468
[details]
a script to do this in the future
Eric Seidel (no email)
Comment 10
2007-01-15 14:54:10 PST
Created
attachment 12469
[details]
real, working script.
Eric Seidel (no email)
Comment 11
2007-01-15 15:10:32 PST
Created
attachment 12471
[details]
automatic changes from script I just chucked the manual changes and beefed up the script. An updated script coming in the next patch.
Eric Seidel (no email)
Comment 12
2007-01-15 15:11:26 PST
Created
attachment 12472
[details]
even better script (with changelog!)
Eric Seidel (no email)
Comment 13
2007-01-15 15:43:18 PST
Created
attachment 12473
[details]
now pimped out with spinners and neons, oh boy. (and a --prefix option for darin)
Eric Seidel (no email)
Comment 14
2007-01-15 15:52:09 PST
I'll explain some of the ruby-isms in this script: +options = {} +OptionParser.new do |opts| I'm not sure why ruby invented yet another OptionParser. But yeah, it's pretty cool. More powerful (and in some ways easier to use) than getoptlong once you get used to it. Like so many things in ruby, it uses a block (the do, end block) and passes an object to that block (in the |args, go, here|). the .new method calls "yield" to call that block with arguments. +IgnoredFilenamePatterns = [ + # ignore headers which are known not to have guard + /WebCorePrefix/, + /ForwardingHeaders/, + %r|bindings/objc|, + /vcproj/, # anything inside a vcproj is in the windows wasteland + + # we don't own any of these headers + %r|icu/unicode|, + %r|platform/graphics/cairo|, + %r|platform/image-decoders|, + + /config.h/ # changing this one sounds scary +].freeze I'm making an array of regexps there. Then "freezing" it as a constant. The freeze part is not absolutely required, but recommended. +IgnoreFileNamesPattern = Regexp.union(*IgnoredFilenamePatterns).freeze *array means "expand this array as though it were passed as arguments" Regexp.union makes one big compiled regexp out of the array of regexps + match_results = contents.match(/#ifndef (\S+)\n#define \1/s) This is a "MatchData" object, the objectified version of $0, $1, etc. (although those work in Ruby too) + new_guard = options[:prefix] + '_' + new_guard if options[:prefix] :foo is a "symbol" in ruby, an atomic string, basically. string.to_sym and symbol.to_s can be used to convert back and forth. + contents.gsub!(current_guard, new_guard) All methods with ! at the end of their name modify the caller. (all methods with ? return a bool) + puts "Ignoring #{filename}, failed to find existing header guards." #{} is the ruby way of variable substitution in strings.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug