Modified: trunk/Tools/ChangeLog (90408 => 90409)
--- trunk/Tools/ChangeLog 2011-07-05 22:20:43 UTC (rev 90408)
+++ trunk/Tools/ChangeLog 2011-07-05 22:20:53 UTC (rev 90409)
@@ -1,5 +1,28 @@
2011-07-05 Adam Roben <[email protected]>
+ Make prepare-ChangeLog include modified Perl functions in its ChangeLog template
+
+ This is a very simple first cut. Functions must start with a line that starts with "sub "
+ and end with a line that starts with a closing brace. No leading whitespace is allowed.
+ Package names aren't parsed at all.
+
+ Fixes <http://webkit.org/b/21591> prepare-ChangeLog should know how to find functions in
+ Perl files
+
+ Reviewed by David Kilzer.
+
+ * Scripts/prepare-ChangeLog: Removed redundant code that ignored certain files when
+ searching for function line ranges. This is already done inside the get_function_line_ranges
+ function.
+ (get_function_line_ranges): Cleaned up coding style a little bit. Call
+ get_function_line_ranges_for_perl for files with .pl and .pm extensions. For files with an
+ unknown extension or no extension, read the shebang line to try to determine the script
+ interpreter. Call get_function_line_ranges_for_perl if the interpreter seems to be Perl.
+ (get_function_line_ranges_for_perl): Added. Does extremely basic parsing of the file to find
+ lines starting with "sub " or "}".
+
+2011-07-05 Adam Roben <[email protected]>
+
Clean up run-api-tests output on Windows
We were mixing run-api-tests output with gtest output, and the result was a mess.
Modified: trunk/Tools/Scripts/prepare-ChangeLog (90408 => 90409)
--- trunk/Tools/Scripts/prepare-ChangeLog 2011-07-05 22:20:43 UTC (rev 90408)
+++ trunk/Tools/Scripts/prepare-ChangeLog 2011-07-05 22:20:53 UTC (rev 90409)
@@ -89,6 +89,7 @@
sub get_function_line_ranges_for_c($$);
sub get_function_line_ranges_for_java($$);
sub get_function_line_ranges_for_javascript($$);
+sub get_function_line_ranges_for_perl($$);
sub get_selector_line_ranges_for_css($$);
sub method_decl_to_selector($);
sub processPaths(\@);
@@ -207,9 +208,6 @@
if (%changed_line_ranges) {
print STDERR " Extracting affected function names from source files.\n";
foreach my $file (keys %changed_line_ranges) {
- # Only look for function names in certain source files.
- next unless $file =~ /\.(c|cpp|m|mm|h|java|js)/;
-
# Find all the functions in the file.
open SOURCE, $file or next;
my @function_ranges = get_function_line_ranges(\*SOURCE, $file);
@@ -494,15 +492,24 @@
{
my ($file_handle, $file_name) = @_;
- if ($file_name =~ /\.(c|cpp|m|mm|h)$/) {
- return get_function_line_ranges_for_c ($file_handle, $file_name);
- } elsif ($file_name =~ /\.java$/) {
- return get_function_line_ranges_for_java ($file_handle, $file_name);
- } elsif ($file_name =~ /\.js$/) {
- return get_function_line_ranges_for_javascript ($file_handle, $file_name);
- } elsif ($file_name =~ /\.css$/) {
- return get_selector_line_ranges_for_css ($file_handle, $file_name);
- }
+ # Try to determine the source language based on the file extension.
+
+ return get_function_line_ranges_for_c($file_handle, $file_name) if $file_name =~ /\.(c|cpp|m|mm|h)$/;
+ return get_function_line_ranges_for_java($file_handle, $file_name) if $file_name =~ /\.java$/;
+ return get_function_line_ranges_for_javascript($file_handle, $file_name) if $file_name =~ /\.js$/;
+ return get_selector_line_ranges_for_css($file_handle, $file_name) if $file_name =~ /\.css$/;
+ return get_function_line_ranges_for_perl($file_handle, $file_name) if $file_name =~ /\.p[lm]$/;
+
+ # Try to determine the source language based on the script interpreter.
+
+ my $first_line = <$file_handle>;
+ seek($file_handle, 0, 0);
+
+ return () unless $first_line =~ /^#!(\S+)/;
+ my $interpreter = $1;
+
+ return get_function_line_ranges_for_perl($file_handle, $file_name) if $interpreter =~ /perl$/;
+
return ();
}
@@ -1201,6 +1208,44 @@
return @ranges;
}
+# 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.
+#
+# Result is a list of triples: [ start_line, end_line, function ].
+
+sub get_function_line_ranges_for_perl($$)
+{
+ my ($fileHandle, $fileName) = @_;
+
+ my @ranges;
+
+ my $currentFunction = "";
+ my $start = 0;
+
+ while (<$fileHandle>) {
+ if (/^sub\s+([^(\s]+)/) {
+ # Skip over forward declarations, which don't contain a brace and end with a semicolon.
+ next if !/{/ && /;$/;
+
+ if ($currentFunction) {
+ warn "nested functions found at top-level at $fileName:$.\n";
+ next;
+ }
+ $currentFunction = $1;
+ $start = $.;
+ }
+ if (index($_, "}") == 0) {
+ next unless $start;
+ push(@ranges, [$start, $., $currentFunction]);
+ $currentFunction = "";
+ $start = 0;
+ next;
+ }
+ }
+
+ return @ranges;
+}
+
# Read a file and get all the line ranges of the things that look like CSS selectors. A selector is
# anything before an opening brace on a line. A selector starts at the line containing the opening
# brace and ends at the closing brace.