Bug 323525 - Symbol viewer's perl parser can incorrectly identify lines as the start of a comment
Summary: Symbol viewer's perl parser can incorrectly identify lines as the start of a ...
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Unclassified
Component: general (show other bugs)
Version: Git
Platform: Compiled Sources Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-15 04:36 UTC by John Schroeder
Modified: 2013-08-15 07:23 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.11.1


Attachments
Sample test case (1.59 KB, application/octet-stream)
2013-08-15 04:37 UTC, John Schroeder
Details
Proposed patch (961 bytes, patch)
2013-08-15 04:39 UTC, John Schroeder
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Schroeder 2013-08-15 04:36:01 UTC
The current implementation of symbol viewer's perl parser can incorrectly identify lines lines that match '^\s=' as the beginning of a comment.

Reproducible: Always

Steps to Reproduce:
1. Open create a perl file that has code like:
my $foo
= 'bar';
2. Observe that symbol viewer's perl parser interprets the line "= 'bar';" as the start of a comment.
Actual Results:  
This should not be interpreted as a comment.  It is a multi-line statement with an assignment operator beginning the second line.

Perl's documentation at:
http://perldoc.perl.org/perlpodspec.html

Specifies that a comment begins with a line that "matches <m/\A=[a-zA-Z]/>".  In other words, the line must begin with a '=' character followed immediately by an alpha character.

Expected Results:  
Symbol viewer's perl parser should only identify lines as the beginning of a comment if they match perl's documented pattern that identifies the start of a comment.
Comment 1 John Schroeder 2013-08-15 04:37:27 UTC
Created attachment 81714 [details]
Sample test case
Comment 2 John Schroeder 2013-08-15 04:38:04 UTC
I have attached a sample test case that highlights the pitfalls of the current implementation.
Comment 3 John Schroeder 2013-08-15 04:39:34 UTC
Created attachment 81715 [details]
Proposed patch
Comment 4 John Schroeder 2013-08-15 04:41:42 UTC
And finally, I've attached a patch that addresses these shortcomings by not trimming the line being analyzed until after comment detection has been attempted and by modifying the regular expression used to identify the beginning of a comment.
Comment 5 Dominik Haumann 2013-08-15 07:21:00 UTC
Git commit 94719b9790671b27a80698ee55439f9a59db4b38 by Dominik Haumann.
Committed on 15/08/2013 at 07:20.
Pushed by dhaumann into branch 'master'.

symbol viewer: fix perl parsing comments

problem was:
my $foo
  = 'bar';

Thanks to John Schroeder for the patch!

FIXED-IN: 4.11.1

M  +4    -3    addons/kate/symbolviewer/perl_parser.cpp

http://commits.kde.org/kate/94719b9790671b27a80698ee55439f9a59db4b38
Comment 6 Dominik Haumann 2013-08-15 07:21:28 UTC
Git commit dc74d823340c75a4d06b9b3da2c40dff04852af9 by Dominik Haumann.
Committed on 15/08/2013 at 07:20.
Pushed by dhaumann into branch 'KDE/4.11'.

symbol viewer: fix perl parsing comments

problem was:
my $foo
  = 'bar';

Thanks to John Schroeder for the patch!

FIXED-IN: 4.11.1

M  +4    -3    addons/kate/symbolviewer/perl_parser.cpp

http://commits.kde.org/kate/dc74d823340c75a4d06b9b3da2c40dff04852af9
Comment 7 Dominik Haumann 2013-08-15 07:23:46 UTC
John, if you want, you can also ask for commit access http://sysadmin.kde.org/tickets/ so that you can commit yourself :-)