jgm / skylighting

A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions
190 stars 61 forks source link

Erlang test failure #63

Closed jgm closed 5 years ago

jgm commented 5 years ago

https://travis-ci.org/jgm/skylighting/jobs/490256029

 Erlang:                                              FAIL (64.10s)
      *** Failed! Exception: 'RegexException "Error in Text.Regex.PCRE.Wrap: ReturnCode (-8)"' (after 89 tests and 22 shrinks):
      "\"\\\"aaaaaaaaaaaaaaaaaaaa"

Use --quickcheck-replay=401761 to reproduce.

jgm commented 5 years ago

Reproducible on command line

 % skylighting -s erlang
"\"aaaaaaaaaaaaaaaaaaaaa
skylighting: RegexException "Error in Text.Regex.PCRE.Wrap: ReturnCode (-8)"

With trace:

DetectChar MATCHED Just (StringTok,"\"")
CONTEXT STACK ["stringquote","Normal Text"]
Trying rule Rule {rMatcher = RegExpr (RE {reString = "(?:(?:\\\\\")?[^\"]*)*\"", reCaseSensitive = True}), rAttribute = StringTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop]}
skylighting: RegexException "Error in Text.Regex.PCRE.Wrap: ReturnCode (-8)"
jgm commented 5 years ago

This diff seems to help:

diff --git a/skylighting-core/xml/erlang.xml b/skylighting-core/xml/erlang.xml
index 7bbcbc9..b631afd 100644
--- a/skylighting-core/xml/erlang.xml
+++ b/skylighting-core/xml/erlang.xml
@@ -213,7 +213,7 @@

       <!-- finish off the atom in quoted string (allow for escaped single quotes -->
       <context name="stringquote" attribute="String" lineEndContext="#pop">
-        <RegExpr attribute="String" context="#pop" String="(?:(?:\\&quot;)?[^&quot;]*)*&quot;" />
+        <RegExpr attribute="String" context="#pop" String="(?:\\&quot;|[^&quot;])*&quot;" />
       </context>

       <!-- finish off the comment (allows for alerts) -->

I'm not sure why the original wasn't working - some pcre issue?