Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package ghc-skylighting-core for 
openSUSE:Factory checked in at 2021-03-24 16:12:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-skylighting-core (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-skylighting-core.new.2401 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-skylighting-core"

Wed Mar 24 16:12:03 2021 rev:21 rq:880428 version:0.10.4.1

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/ghc-skylighting-core/ghc-skylighting-core.changes    
    2021-03-10 08:58:13.242948773 +0100
+++ 
/work/SRC/openSUSE:Factory/.ghc-skylighting-core.new.2401/ghc-skylighting-core.changes
      2021-03-24 16:12:04.343883618 +0100
@@ -1,0 +2,12 @@
+Sun Mar 14 22:46:44 UTC 2021 - [email protected]
+
+- Update skylighting-core to version 0.10.4.1.
+  ## 0.10.4.1
+
+    * Fixed logic for checking line-end-context (#119).
+
+    * Use NonEmpty for the context stack.
+
+    * Remove unneeded build-depends.
+
+-------------------------------------------------------------------

Old:
----
  skylighting-core-0.10.4.tar.gz

New:
----
  skylighting-core-0.10.4.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-skylighting-core.spec ++++++
--- /var/tmp/diff_new_pack.nkRanB/_old  2021-03-24 16:12:04.983884289 +0100
+++ /var/tmp/diff_new_pack.nkRanB/_new  2021-03-24 16:12:04.987884293 +0100
@@ -19,7 +19,7 @@
 %global pkg_name skylighting-core
 %bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        0.10.4
+Version:        0.10.4.1
 Release:        0
 Summary:        Syntax highlighting library
 License:        BSD-3-Clause
@@ -48,10 +48,8 @@
 ExcludeArch:    %{ix86}
 %if %{with tests}
 BuildRequires:  ghc-Diff-devel
-BuildRequires:  ghc-HUnit-devel
 BuildRequires:  ghc-QuickCheck-devel
 BuildRequires:  ghc-pretty-show-devel
-BuildRequires:  ghc-random-devel
 BuildRequires:  ghc-tasty-devel
 BuildRequires:  ghc-tasty-golden-devel
 BuildRequires:  ghc-tasty-hunit-devel

++++++ skylighting-core-0.10.4.tar.gz -> skylighting-core-0.10.4.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/skylighting-core-0.10.4/changelog.md 
new/skylighting-core-0.10.4.1/changelog.md
--- old/skylighting-core-0.10.4/changelog.md    2021-02-27 21:56:42.000000000 
+0100
+++ new/skylighting-core-0.10.4.1/changelog.md  2021-03-14 23:37:55.000000000 
+0100
@@ -1,5 +1,13 @@
 # Revision history for skylighting and skylighting-core
 
+## 0.10.4.1
+
+  * Fixed logic for checking line-end-context (#119).
+
+  * Use NonEmpty for the context stack.
+
+  * Remove unneeded build-depends.
+
 ## 0.10.4
 
   * Move from hxt to xml-conduit for XML parsing.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/skylighting-core-0.10.4/skylighting-core.cabal 
new/skylighting-core-0.10.4.1/skylighting-core.cabal
--- old/skylighting-core-0.10.4/skylighting-core.cabal  2021-02-27 
21:56:56.000000000 +0100
+++ new/skylighting-core-0.10.4.1/skylighting-core.cabal        2021-03-14 
23:38:07.000000000 +0100
@@ -1,5 +1,5 @@
 name:                skylighting-core
-version:             0.10.4
+version:             0.10.4.1
 synopsis:            syntax highlighting library
 description:         Skylighting is a syntax highlighting library.
                      It derives its tokenizers from XML syntax
@@ -139,6 +139,8 @@
   ghc-options:         -Wall
   if impl(ghc >= 8.4)
     ghc-options:       -fhide-source-paths
+  if impl(ghc >= 8.10)
+    ghc-options:      -Wunused-packages
 
 Flag executable
   Description:   Build skylighting-extract tool
@@ -149,17 +151,14 @@
   main-is:        test-skylighting.hs
   hs-source-dirs: test
   build-depends:  base >= 4.8 && < 5.0,
-                  HUnit,
                   tasty,
                   tasty-golden,
                   tasty-hunit,
                   tasty-quickcheck,
                   QuickCheck,
                   containers,
-                  random,
                   Diff,
                   text,
-                  utf8-string,
                   pretty-show,
                   aeson >= 1.0,
                   bytestring,
@@ -168,6 +167,8 @@
                   skylighting-core
   default-language: Haskell2010
   ghc-options:    -Wall
+  if impl(ghc >= 8.10)
+    ghc-options:      -Wunused-packages
 
 benchmark benchmark-skylighting
   Type:            exitcode-stdio-1.0
@@ -183,6 +184,8 @@
   Ghc-Options:   -rtsopts -Wall -fno-warn-unused-do-bind
   if impl(ghc >= 8.4)
     ghc-options:       -fhide-source-paths
+  if impl(ghc >= 8.10)
+    ghc-options:      -Wunused-packages
   Default-Language: Haskell2010
 
 executable skylighting-extract
@@ -202,5 +205,7 @@
   default-language:    Haskell2010
   other-extensions:    CPP
   ghc-options:         -Wall
+  if impl(ghc >= 8.10)
+    ghc-options:      -Wunused-packages
   if impl(ghc >= 8.4)
     ghc-options:       -fhide-source-paths
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/skylighting-core-0.10.4/src/Skylighting/Tokenizer.hs 
new/skylighting-core-0.10.4.1/src/Skylighting/Tokenizer.hs
--- old/skylighting-core-0.10.4/src/Skylighting/Tokenizer.hs    2020-09-14 
19:59:09.000000000 +0200
+++ new/skylighting-core-0.10.4.1/src/Skylighting/Tokenizer.hs  2021-03-14 
23:04:12.000000000 +0100
@@ -31,11 +31,13 @@
 import Debug.Trace
 import Skylighting.Regex
 import Skylighting.Types
+import Data.List.NonEmpty (NonEmpty((:|)), (<|), toList)
 #if !MIN_VERSION_base(4,11,0)
 import Data.Semigroup
 #endif
 
-newtype ContextStack = ContextStack{ unContextStack :: [Context] }
+
+newtype ContextStack = ContextStack{ unContextStack :: NonEmpty Context }
   deriving (Show)
 
 data TokenizerState = TokenizerState{
@@ -131,19 +133,27 @@
 -- | Tokenize some text using 'Syntax'.
 tokenize :: TokenizerConfig -> Syntax -> Text -> Either String [SourceLine]
 tokenize config syntax inp =
-  case runTokenizerM action config initState of
+  eitherStack >>= \stack ->
+    case runTokenizerM action config (startingState stack) of
        (_, Success ls) -> Right ls
        (_, Error e)    -> Left e
        (_, Failure)    -> Left "Could not tokenize code"
   where
     action = mapM tokenizeLine (zip (BS.lines (encodeUtf8 inp)) [1..])
-    initState = startingState{ endline = Text.null inp
-                             , contextStack =
-                                   case lookupContext
-                                         (sStartingContext syntax) syntax of
-                                         Just c  -> ContextStack [c]
-                                         Nothing -> ContextStack [] }
-
+    eitherStack = case lookupContext (sStartingContext syntax) syntax of
+                    Just c  -> Right $ ContextStack (c :| [])
+                    Nothing -> Left "No starting context specified"
+    startingState stack =
+      TokenizerState{ input = BS.empty
+                    , endline = Text.null inp
+                    , prevChar = '\n'
+                    , contextStack = stack
+                    , captures = mempty
+                    , column = 0
+                    , lineContinuation = False
+                    , firstNonspaceColumn = Nothing
+                    , compiledRegexes = Map.empty
+                    }
 
 info :: String -> TokenizerM ()
 info s = do
@@ -155,35 +165,28 @@
   tr <- asks traceOutput
   when tr $ do
     ContextStack stack <- gets contextStack
-    info $ "CONTEXT STACK " ++ show (map cName stack)
+    info $ "CONTEXT STACK " ++ show (map cName $ toList stack)
 
 popContextStack :: TokenizerM ()
 popContextStack = do
   ContextStack cs <- gets contextStack
   case cs of
-       []     -> throwError "Empty context stack (the impossible happened)"
-       -- programming error
-       (_:[]) -> return ()
-       (_:rest) -> do
-         modify (\st -> st{ contextStack = ContextStack rest })
-         currentContext >>= checkLineEnd
+       (_ :| []) -> info "WARNING: Tried to pop only element on context stack!"
+       (_ :| (x:xs)) -> do
+         modify (\st -> st{ contextStack = ContextStack (x :| xs) })
          infoContextStack
 
 pushContextStack :: Context -> TokenizerM ()
 pushContextStack cont = do
   modify (\st -> st{ contextStack =
-                      ContextStack (cont : unContextStack (contextStack st)) } 
)
-  -- not sure why we need this in pop but not here, but if we
-  -- put it here we can get loops...
-  -- checkLineEnd cont
+                      ContextStack
+                       ((cont <|) . unContextStack $ contextStack st) } )
   infoContextStack
 
 currentContext :: TokenizerM Context
 currentContext = do
-  ContextStack cs <- gets contextStack
-  case cs of
-       []    -> throwError "Empty context stack" -- programming error
-       (c:_) -> return c
+  ContextStack (c :| _) <- gets contextStack
+  return c
 
 doContextSwitch :: ContextSwitch -> TokenizerM ()
 doContextSwitch Pop = popContextStack
@@ -194,9 +197,7 @@
        Nothing  -> throwError $ "Unknown syntax or context: " ++ show (syn, c)
 
 doContextSwitches :: [ContextSwitch] -> TokenizerM ()
-doContextSwitches [] = return ()
-doContextSwitches xs = do
-  mapM_ doContextSwitch xs
+doContextSwitches = mapM_ doContextSwitch
 
 lookupContext :: Text -> Syntax -> Maybe Context
 lookupContext name syntax | Text.null name =
@@ -205,19 +206,6 @@
      else lookupContext (sStartingContext syntax) syntax
 lookupContext name syntax = Map.lookup name $ sContexts syntax
 
-startingState :: TokenizerState
-startingState =
-  TokenizerState{ input = BS.empty
-                , endline = True
-                , prevChar = '\n'
-                , contextStack = ContextStack []
-                , captures = mempty
-                , column = 0
-                , lineContinuation = False
-                , firstNonspaceColumn = Nothing
-                , compiledRegexes = Map.empty
-                }
-
 tokenizeLine :: (ByteString, Int) -> TokenizerM [Token]
 tokenizeLine (ln, linenum) = do
   modify $ \st -> st{ input = ln, endline = BS.null ln, prevChar = '\n' }
@@ -432,15 +420,15 @@
 
 checkLineEnd :: Context -> TokenizerM ()
 checkLineEnd c = do
-  if null (cLineEndContext c)
-     then return ()
-     else do
-       eol <- gets endline
-       info $ "checkLineEnd for " ++ show (cName c) ++ " eol = " ++ show eol 
++ " cLineEndContext = " ++ show (cLineEndContext c)
-       when eol $ do
-         lineCont' <- gets lineContinuation
-         unless lineCont' $
-           doContextSwitches (cLineEndContext c)
+  unless (null (cLineEndContext c)) $ do
+    eol <- gets endline
+    info $ "checkLineEnd for " ++ show (cName c) ++ " eol = " ++ show eol ++ " 
cLineEndContext = " ++ show (cLineEndContext c)
+    when eol $ do
+      lineCont' <- gets lineContinuation
+      unless lineCont' $ do
+        doContextSwitches (cLineEndContext c)
+        c' <- currentContext
+        unless (c == c') $ checkLineEnd c'
 
 detectChar :: Bool -> Char -> ByteString -> TokenizerM Text
 detectChar dynamic c inp = do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/skylighting-core-0.10.4/test/test-skylighting.hs 
new/skylighting-core-0.10.4.1/test/test-skylighting.hs
--- old/skylighting-core-0.10.4/test/test-skylighting.hs        2021-02-27 
20:54:28.000000000 +0100
+++ new/skylighting-core-0.10.4.1/test/test-skylighting.hs      2021-03-14 
23:08:12.000000000 +0100
@@ -116,6 +116,8 @@
                              (lookupSyntax "html" sMap)
           cpp  = maybe (error "could not find CPP syntax") id
                              (lookupSyntax "cpp" sMap)
+          bash  = maybe (error "could not find bash syntax") id
+                             (lookupSyntax "bash" sMap)
           c    = maybe (error "could not find C syntax") id
                              (lookupSyntax "c" sMap) in
       [ testCase "perl NUL case" $ Right
@@ -179,6 +181,19 @@
           [ [ ( NormalTok , "\35797\65306" ) , ( KeywordTok , "<a>" ) ]
           ] @=? tokenize defConfig html "??????<a>"
 
+      , testCase "Bash closing brace (#119)" $ Right
+          [ [ ( FunctionTok , "f()" )
+            , ( NormalTok , " " )
+            , ( KeywordTok , "{" ) ]
+          , [ ( NormalTok , "    " )
+            , ( BuiltInTok , "echo" )
+            , ( NormalTok , " " )
+            , ( OperatorTok , ">" )
+            , ( NormalTok , " f" ) ]
+          , [ ( KeywordTok , "}" ) ] ]
+             @=? tokenize defConfig bash
+                     "f() {\n    echo > f\n}\n"
+
       ]
     ]
 

Reply via email to