WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
21591
prepare-ChangeLog should know how to find functions in Perl files
https://bugs.webkit.org/show_bug.cgi?id=21591
Summary
prepare-ChangeLog should know how to find functions in Perl files
David Kilzer (:ddkilzer)
Reported
2008-10-14 11:37:37 PDT
Since most of the tools in WebKitTools are written in Perl, we should make prepare-ChangeLog work with Perl scripts.
Attachments
Make prepare-ChangeLog include modified Perl functions in its ChangeLog template
(5.65 KB, patch)
2011-07-05 15:07 PDT
,
Adam Roben (:aroben)
ddkilzer
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
David Kilzer (:ddkilzer)
Comment 1
2008-10-14 11:38:40 PDT
See
Bug 21567
for a similar change for JavaScript files. We'll need to check the first line of files to see if "#!/usr/bin/perl" or similar appears there since not all Perl scripts end with ".pl".
Adam Roben (:aroben)
Comment 2
2011-05-26 09:56:02 PDT
A very simple first cut would be to match against /^sub (\w\S+)/.
Adam Roben (:aroben)
Comment 3
2011-07-05 15:07:07 PDT
Created
attachment 99751
[details]
Make prepare-ChangeLog include modified Perl functions in its ChangeLog template
Adam Roben (:aroben)
Comment 4
2011-07-05 15:10:02 PDT
Comment on
attachment 99751
[details]
Make prepare-ChangeLog include modified Perl functions in its ChangeLog template View in context:
https://bugs.webkit.org/attachment.cgi?id=99751&action=review
> Tools/Scripts/prepare-ChangeLog:1213 > +# Read a file and get all the line ranges of the things that look like Perl functions. Only lines > +# which start with "sub " are recognized as starting a function, and only lines that are exactly "}" > +# are recognized as ending a function.
This isn't quite accurate. Rewritten as: # Read a file and get all the line ranges of the things that look like Perl functions. Functions # start on a line that starts with "sub ", and end on the first line starting with "}" thereafter.
David Kilzer (:ddkilzer)
Comment 5
2011-07-05 15:13:17 PDT
Comment on
attachment 99751
[details]
Make prepare-ChangeLog include modified Perl functions in its ChangeLog template View in context:
https://bugs.webkit.org/attachment.cgi?id=99751&action=review
r=me!
> Tools/Scripts/prepare-ChangeLog:1232 > + warn "nested functions found at top-level at $fileName:$.\n";
FYI, it is possible to nest subroutines in Perl. You can define a subroutine and assign it to a variable, too. I guess you can change $currentFunction to @currentFunction later.
Adam Roben (:aroben)
Comment 6
2011-07-05 15:13:51 PDT
Comment on
attachment 99751
[details]
Make prepare-ChangeLog include modified Perl functions in its ChangeLog template View in context:
https://bugs.webkit.org/attachment.cgi?id=99751&action=review
> Tools/Scripts/prepare-ChangeLog:1227 > + if (/^sub ([^(]+)/) {
I tweaked this to: /^sub\s+([^(\s]+)/ This better handles functions which have no prototype, and is a little more lenient about spaces after "sub".
Adam Roben (:aroben)
Comment 7
2011-07-05 15:15:22 PDT
Comment on
attachment 99751
[details]
Make prepare-ChangeLog include modified Perl functions in its ChangeLog template View in context:
https://bugs.webkit.org/attachment.cgi?id=99751&action=review
>> Tools/Scripts/prepare-ChangeLog:1232 >> + warn "nested functions found at top-level at $fileName:$.\n"; > > FYI, it is possible to nest subroutines in Perl. You can define a subroutine and assign it to a variable, too. > > I guess you can change $currentFunction to @currentFunction later.
Yes, I just decided to punt on nested subroutines in this patch. Note that we'll only complain if the nested function isn't indented, like this: sub outerFunction { sub innerFunction { } }
Adam Roben (:aroben)
Comment 8
2011-07-05 15:21:39 PDT
Committed
r90409
: <
http://trac.webkit.org/changeset/90409
>
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