Title: [104401] trunk/Tools
Revision
104401
Author
[email protected]
Date
2012-01-08 08:21:17 -0800 (Sun, 08 Jan 2012)

Log Message

The Perl parser of prepare-ChangeLog can parse here-documents
https://bugs.webkit.org/show_bug.cgi?id=73208

Reviewed by David Kilzer.

Currently prepare-ChangeLog cannot recognize here-documents in Perl,
which results in wrong subroutine names in ChangeLogs.
With this patch, prepare-ChangeLog can judge whether the line of "}"
is the end of a subroutine or a line inside a here-document.

Test: Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests.pl

* Scripts/prepare-ChangeLog:
(get_function_line_ranges_for_perl):
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests-expected.txt:
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests.pl:
Added test cases for here-documents.
(func7):
(func8):
(func9):
(func10):
(func11):
(func12):
(func13):
(func14):
(func15):
(func16):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (104400 => 104401)


--- trunk/Tools/ChangeLog	2012-01-08 16:15:51 UTC (rev 104400)
+++ trunk/Tools/ChangeLog	2012-01-08 16:21:17 UTC (rev 104401)
@@ -1,3 +1,33 @@
+2012-01-04  Kentaro Hara  <[email protected]>
+
+        The Perl parser of prepare-ChangeLog can parse here-documents
+        https://bugs.webkit.org/show_bug.cgi?id=73208
+
+        Reviewed by David Kilzer.
+
+        Currently prepare-ChangeLog cannot recognize here-documents in Perl,
+        which results in wrong subroutine names in ChangeLogs.
+        With this patch, prepare-ChangeLog can judge whether the line of "}"
+        is the end of a subroutine or a line inside a here-document.
+
+        Test: Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests.pl
+
+        * Scripts/prepare-ChangeLog:
+        (get_function_line_ranges_for_perl):
+        * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests-expected.txt:
+        * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests.pl:
+        Added test cases for here-documents.
+        (func7):
+        (func8):
+        (func9):
+        (func10):
+        (func11):
+        (func12):
+        (func13):
+        (func14):
+        (func15):
+        (func16):
+
 2012-01-08  Kentaro Hara  <[email protected]>
 
         Add unittests for the _javascript_ parser of prepare-ChangeLog

Modified: trunk/Tools/Scripts/prepare-ChangeLog (104400 => 104401)


--- trunk/Tools/Scripts/prepare-ChangeLog	2012-01-08 16:15:51 UTC (rev 104400)
+++ trunk/Tools/Scripts/prepare-ChangeLog	2012-01-08 16:21:17 UTC (rev 104401)
@@ -1286,26 +1286,39 @@
 
     my $currentFunction = "";
     my $start = 0;
+    my $hereDocumentIdentifier = "";
 
     while (<$fileHandle>) {
-        if (/^sub\s+([^(\s]+)/) {
-            # Skip over forward declarations, which don't contain a brace and end with a semicolon.
-            next if !/{/ && /;$/;
+        chomp;
+        if (!$hereDocumentIdentifier) {
+            if (/^sub\s+([\w_][\w\d_]*)/) {
+                # Skip over forward declarations, which don't contain a brace and end with a semicolon.
+                next if /;\s*$/;
 
-            if ($currentFunction) {
-                warn "nested functions found at top-level at $fileName:$.\n";
-                next;
+                if ($currentFunction) {
+                    warn "nested functions found at top-level at $fileName:$.\n";
+                    next;
+                }
+                $currentFunction = $1;
+                $start = $.;
             }
-            $currentFunction = $1;
-            $start = $.;
+            if (/<<\s*[\"\']?([\w_][\w_\d]*)/) {
+                # Enter here-document.
+                $hereDocumentIdentifier = $1;
+            }
+            if (index($_, "}") == 0) {
+                unless ($start) {
+                    warn "nested functions found at top-level at $fileName:$.\n";
+                    next;
+                }
+                push(@ranges, [$start, $., $currentFunction]);
+                $currentFunction = "";
+                $start = 0;
+            }
+        } elsif ($_ eq $hereDocumentIdentifier) {
+            # Escape from here-document.
+            $hereDocumentIdentifier = "";
         }
-        if (index($_, "}") == 0) {
-            next unless $start;
-            push(@ranges, [$start, $., $currentFunction]);
-            $currentFunction = "";
-            $start = 0;
-            next;
-        }
     }
 
     return @ranges;

Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests-expected.txt (104400 => 104401)


--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests-expected.txt	2012-01-08 16:15:51 UTC (rev 104400)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests-expected.txt	2012-01-08 16:21:17 UTC (rev 104401)
@@ -28,5 +28,55 @@
     '44',
     '46',
     'func6'
+  ],
+  [
+    '48',
+    '53',
+    'func7'
+  ],
+  [
+    '55',
+    '60',
+    'func8'
+  ],
+  [
+    '62',
+    '67',
+    'func9'
+  ],
+  [
+    '69',
+    '76',
+    'func10'
+  ],
+  [
+    '78',
+    '88',
+    'func11'
+  ],
+  [
+    '90',
+    '100',
+    'func12'
+  ],
+  [
+    '102',
+    '111',
+    'func13'
+  ],
+  [
+    '113',
+    '118',
+    'func14'
+  ],
+  [
+    '120',
+    '125',
+    'func15'
+  ],
+  [
+    '127',
+    '128',
+    'func16'
   ]
 ]

Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests.pl (104400 => 104401)


--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests.pl	2012-01-08 16:15:51 UTC (rev 104400)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests.pl	2012-01-08 16:21:17 UTC (rev 104401)
@@ -44,3 +44,90 @@
 sub func6(\@\@\$\$\$\$)
 {
 }
+
+sub func7
+{
+    $str =<< EOF;
+
+EOF
+}
+
+sub func8
+{
+    $str =<< "EOF";
+
+EOF
+}
+
+sub func9
+{
+    $str =<< 'EOF';
+
+EOF
+}
+
+sub func10
+{
+    $str =<< EOF;
+sub funcInHereDocument1
+{
+}
+EOF
+}
+
+sub func11
+{
+    $str =<< EOF;
+sub funcInHereDocument2
+{
+}
+sub funcInHereDocument3
+{
+}
+EOF
+}
+
+sub func12
+{
+    $str =<< EOF;
+{
+{
+{
+}
+}
+}
+EOF
+}
+
+sub func13
+{
+    $str =<< EOF;
+
+$str << DUMMY_EOF
+
+DUMMY_EOF
+
+EOF
+}
+
+sub func14
+{
+    push(@array, << EOF);
+
+EOF
+}
+
+sub func15
+{
+    print << EOF;
+
+EOF
+}
+
+sub func16 {
+}
+
+sub prototypeDeclaration1;
+sub prototypeDeclaration2();
+sub prototypeDeclaration3(\@$$);
+
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to