Bug 175571 - perl syntax highlighting wrong for hash key like $hash{s}
Summary: perl syntax highlighting wrong for hash key like $hash{s}
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: syntax (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-19 12:53 UTC by Toralf Förster
Modified: 2008-12-14 12:33 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Toralf Förster 2008-11-19 12:53:44 UTC
Version:           2.5.10 (using 3.5.10, Gentoo)
Compiler:          Target: i686-pc-linux-gnu
OS:                Linux (i686) release 2.6.26.8

For the following perl snippet:

#!/usr/bin/perl
#
print $h{s};
print $h{f};

exit (0);

the line "print $h{s};" change the syntax highlighting for all subsequent lines into sth. which looks wrong. Quoting {'s'} however is a workaround.
Comment 1 Anders Lund 2008-11-19 17:46:08 UTC
I can not confirm for kde 4.1.3, as it works perfect here.
I know that my test.pl file contains a lot of tests, like
$hash{element}; # with various amounts of space around the atoms of the statement, and that those all works. There is no example of a single letter unquoted key though.

Could you test if it is broken for keys with more letters, and if so, please attach a file to test against?
Comment 2 Toralf Förster 2008-11-20 09:36:27 UTC
It is only broken for the single character {s}, however {sfoo} or sth. else works. That's why I argue that is might be misinterpreted with the s/// operator ?
Comment 3 Anders Lund 2008-11-20 20:59:21 UTC
Yes, that is likely right, as the search for a hash key is running the full code analysis, and there is be a mistake: I can confirm that a key 's' leads to errors as described.

In your perl.xml, look for the lines 365 - 368, they should look like this:
        <RegExpr attribute="Operator" context="find_quoted" String="\bq(?=[qwx]?\s*[^\w\s])" />
        <RegExpr attribute="Operator" context="find_subst" String="\bs(?=\s*[^\w\s])" />
        <RegExpr attribute="Operator" context="tr" String="\b(?:tr|y)\s*(?=[^\w\s\]})])" />

The 2nd line, leading to context find_subst should contain a check for braces in the lookahead test at the end of  the pattern, I think it should look like the one below: (?=[^\w\s\]})]). This should mean that the s followed by letters, numbers or closing braces is not matched.

If you care to, could you try this?
Comment 4 Toralf Förster 2008-11-20 21:42:55 UTC
Right, that solved this issue :

n22 /usr/kde/3.5/share/apps/katepart/syntax # diff -u perl.xml.orig perl.xml
--- perl.xml.orig       2008-11-20 21:40:23.000000000 +0100
+++ perl.xml    2008-11-20 21:41:41.000000000 +0100
@@ -363,7 +363,7 @@
         <RegExpr attribute="Normal Text" context="#stay" String="\w+[=]" />

         <RegExpr attribute="Operator" context="find_quoted" String="\bq(?=[qwx]?\s*[^\w\s])" />
-        <RegExpr attribute="Operator" context="find_subst" String="\bs(?=\s*[^\w\s])" />
+        <RegExpr attribute="Operator" context="find_subst" String="\bs(?=[^\w\s\]})])" />
         <RegExpr attribute="Operator" context="tr" String="\b(?:tr|y)\s*(?=[^\w\s\]})])" />

         <RegExpr attribute="Operator" context="find_pattern" String="\b(?:m|qr)(?=\s*[^\w\s\]})])" />
Comment 5 Anders Lund 2008-12-14 12:33:10 UTC
SVN commit 896727 by alund:

Do not start a substitution pattern on closing braces.
BUG: 175571


 M  +2 -2      perl.xml  


WebSVN link: http://websvn.kde.org/?view=rev&revision=896727