Modified: trunk/Tools/ChangeLog (106314 => 106315)
--- trunk/Tools/ChangeLog 2012-01-31 02:22:37 UTC (rev 106314)
+++ trunk/Tools/ChangeLog 2012-01-31 02:40:24 UTC (rev 106315)
@@ -1,3 +1,42 @@
+2012-01-30 Kentaro Hara <[email protected]>
+
+ REGRESSION(r105797): prepare-ChangeLog for a .cpp file can
+ output an empty method name (i.e. "()")
+ https://bugs.webkit.org/show_bug.cgi?id=77336
+
+ Reviewed by Darin Adler.
+
+ r105797 tried to detect a change outside methods, but it causes a bug that
+ prepare-ChangeLog can output an empty method name, like this:
+
+ * foo/bar/baz.cpp:
+ (method1):
+ ():
+ (method2):
+
+ This is because the cpp parser in prepare-ChangeLog cannot distinguish
+ '{' as the beginning of a method with '{' as the beginning of an array definition
+ at the top level.
+
+ int a[] = { 1, 2, 3 }; // This '{' is the beginning of an array definition.
+
+ void func() { // This '{' is the beginning of a method.
+ ...;
+ }
+
+ This patch fixes prepare-ChangeLog so that it skips an array definition at the top level.
+
+ * Scripts/prepare-ChangeLog:
+ (get_function_line_ranges_for_cpp): Modified as described above.
+ (generateFunctionLists): As a hack, modified so that prepare-ChangeLog does not output
+ an empty method name. Ideally this should not happen but may happen, since the
+ parsers are not perfect.
+ * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp: Added test cases.
+ (NameSpace7):
+ (NameSpace8):
+ (Class109):
+ * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt:
+
2012-01-30 Ojan Vafai <[email protected]>
run-webkit-tests calls out to webkit-build-directory twice
Modified: trunk/Tools/Scripts/prepare-ChangeLog (106314 => 106315)
--- trunk/Tools/Scripts/prepare-ChangeLog 2012-01-31 02:22:37 UTC (rev 106314)
+++ trunk/Tools/Scripts/prepare-ChangeLog 2012-01-31 02:40:24 UTC (rev 106315)
@@ -270,6 +270,14 @@
FUNCTION: foreach my $function_range_ref (@function_ranges) {
my @function_range = @$function_range_ref;
+ # FIXME: This is a hack. If the function name is empty, skip it.
+ # The cpp, python, _javascript_, perl, css and java parsers
+ # are not perfectly implemented and sometimes function names cannot be retrieved
+ # correctly. As you can see in get_function_line_ranges_XXXX(), those parsers
+ # are not intended to implement real parsers but intended to just retrieve function names
+ # for most practical syntaxes.
+ next unless $function_range[2];
+
# Advance to successive change ranges.
for (;; @change_range = @{shift @change_ranges}) {
last FUNCTION unless @change_range;
@@ -618,10 +626,12 @@
my $in_method_declaration = 0;
my $in_parentheses = 0;
my $in_braces = 0;
+ my $in_toplevel_array_brace = 0;
my $brace_start = 0;
my $brace_end = 0;
my $namespace_start = -1;
my $skip_til_brace_or_semicolon = 0;
+ my $equal_observed = 0;
my $word = "";
my $interface_name = "";
@@ -749,7 +759,23 @@
# Find function, interface and method names.
- while (m&((?:[[:word:]]+::)*operator(?:[ \t]*\(\)|[^()]*)|[[:word:]:~]+|[(){}:;])|\@(?:implementation|interface|protocol)\s+(\w+)[^{]*&g) {
+ while (m&((?:[[:word:]]+::)*operator(?:[ \t]*\(\)|[^()]*)|[[:word:]:~]+|[(){}:;=])|\@(?:implementation|interface|protocol)\s+(\w+)[^{]*&g) {
+ # Skip an array definition at the top level.
+ # e.g. static int arr[] = { 1, 2, 3 };
+ if ($1) {
+ if ($1 eq "=" and !$in_parentheses and !$in_braces) {
+ $equal_observed = 1;
+ } elsif ($1 eq "{" and $equal_observed) {
+ # This '{' is the beginning of an array definition, not the beginning of a method.
+ $in_toplevel_array_brace = 1;
+ $in_braces++;
+ $equal_observed = 0;
+ next;
+ } elsif ($1 !~ /[ \t]/) {
+ $equal_observed = 0;
+ }
+ }
+
# interface name
if ($2) {
$interface_name = $2;
@@ -833,6 +859,12 @@
# End of an outer level set of braces.
# This could be a function body.
if (!$in_braces and $name) {
+ # This is the end of an array definition at the top level, not the end of a method.
+ if ($in_toplevel_array_brace) {
+ $in_toplevel_array_brace = 0;
+ next;
+ }
+
push @ranges, [ $start, $., $name ];
if (@namespaces) {
$name = $namespaces[-1];
Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt (106314 => 106315)
--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt 2012-01-31 02:22:37 UTC (rev 106314)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests-expected.txt 2012-01-31 02:40:24 UTC (rev 106315)
@@ -326,6 +326,31 @@
'321',
'321',
'Class108'
+ ],
+ [
+ '340',
+ '354',
+ 'NameSpace7'
+ ],
+ [
+ '356',
+ '369',
+ 'NameSpace8'
+ ],
+ [
+ '371',
+ '371',
+ 'NameSpace7'
+ ],
+ [
+ '373',
+ '386',
+ 'Class109'
+ ],
+ [
+ '388',
+ '388',
+ 'NameSpace7'
]
]
}
Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp (106314 => 106315)
--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp 2012-01-31 02:22:37 UTC (rev 106314)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/cpp_unittests.cpp 2012-01-31 02:40:24 UTC (rev 106315)
@@ -320,3 +320,70 @@
}
int h;
};
+
+int a[] = { };
+int a[] = {
+};
+int a[] = { 1, 2, 3 };
+int a[] = {
+ 1,
+ 2,
+ 3
+};
+int a[3] = { 1, 2, 3 };
+int a[][3] = { {1, 2, 3}, {4, 5, 6} };
+int a[2][3] = { {1, 2, 3}, {4, 5, 6} };
+extern int a[];
+char a[4] = "test";
+
+namespace NameSpace7 {
+int a[] = { };
+int a[] = {
+};
+int a[] = { 1, 2, 3 };
+int a[] = {
+ 1,
+ 2,
+ 3
+};
+int a[3] = { 1, 2, 3 };
+int a[][3] = { {1, 2, 3}, {4, 5, 6} };
+int a[2][3] = { {1, 2, 3}, {4, 5, 6} };
+extern int a[];
+char a[4] = "test";
+
+namespace NameSpace8 {
+int a[] = { };
+int a[] = {
+};
+int a[] = { 1, 2, 3 };
+int a[] = {
+ 1,
+ 2,
+ 3
+};
+int a[3] = { 1, 2, 3 };
+int a[][3] = { {1, 2, 3}, {4, 5, 6} };
+int a[2][3] = { {1, 2, 3}, {4, 5, 6} };
+extern int a[];
+char a[4] = "test";
+};
+
+class Class109 {
+ int a[] = { };
+ int a[] = {
+ };
+ int a[] = { 1, 2, 3 };
+ int a[] = {
+ 1,
+ 2,
+ 3
+ };
+ int a[3] = { 1, 2, 3 };
+ int a[][3] = { {1, 2, 3}, {4, 5, 6} };
+ int a[2][3] = { {1, 2, 3}, {4, 5, 6} };
+ extern int a[];
+ char a[4] = "test";
+};
+
+};