Hello community, here is the log from the commit of package ghc-libyaml for openSUSE:Factory checked in at 2019-02-24 17:18:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-libyaml (Old) and /work/SRC/openSUSE:Factory/.ghc-libyaml.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-libyaml" Sun Feb 24 17:18:43 2019 rev:2 rq:678029 version:0.1.1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-libyaml/ghc-libyaml.changes 2018-10-25 08:17:44.212034143 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-libyaml.new.28833/ghc-libyaml.changes 2019-02-24 17:18:45.500414663 +0100 @@ -1,0 +2,8 @@ +Wed Feb 13 03:01:57 UTC 2019 - psim...@suse.com + +- Update libyaml to version 0.1.1.0. + ## 0.1.1.0 + + * Add options to `FormatOptions` to govern when tags rendered explicitly and when they are left implicit. [#165](https://github.com/snoyberg/yaml/issues/165) + +------------------------------------------------------------------- Old: ---- libyaml-0.1.0.0.tar.gz New: ---- libyaml-0.1.1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-libyaml.spec ++++++ --- /var/tmp/diff_new_pack.YbnRtk/_old 2019-02-24 17:18:47.000414396 +0100 +++ /var/tmp/diff_new_pack.YbnRtk/_new 2019-02-24 17:18:47.004414395 +0100 @@ -1,7 +1,7 @@ # # spec file for package ghc-libyaml # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %global pkg_name libyaml Name: ghc-%{pkg_name} -Version: 0.1.0.0 +Version: 0.1.1.0 Release: 0 Summary: Low-level, streaming YAML interface License: BSD-3-Clause ++++++ libyaml-0.1.0.0.tar.gz -> libyaml-0.1.1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libyaml-0.1.0.0/ChangeLog.md new/libyaml-0.1.1.0/ChangeLog.md --- old/libyaml-0.1.0.0/ChangeLog.md 2018-10-12 08:00:28.000000000 +0200 +++ new/libyaml-0.1.1.0/ChangeLog.md 2019-02-12 09:55:32.000000000 +0100 @@ -1,5 +1,9 @@ # Changelog for libyaml +## 0.1.1.0 + +* Add options to `FormatOptions` to govern when tags rendered explicitly and when they are left implicit. [#165](https://github.com/snoyberg/yaml/issues/165) + ## 0.1.0.0 * Split `libyaml` into a separate package from `yaml`. This split occurred at diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libyaml-0.1.0.0/libyaml.cabal new/libyaml-0.1.1.0/libyaml.cabal --- old/libyaml-0.1.0.0/libyaml.cabal 2018-10-12 08:00:36.000000000 +0200 +++ new/libyaml-0.1.1.0/libyaml.cabal 2019-02-12 09:55:57.000000000 +0100 @@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.30.0. +-- This file has been generated from package.yaml by hpack version 0.31.1. -- -- see: https://github.com/sol/hpack -- --- hash: c0c9e64cc05c465e85aae41e88455f4a22e41825e6263f9745c9b5d6f786aeb5 +-- hash: d20fe3a9f7ef759a6555e0219f0728d8a3d1f073384d6d705d588c1160f3743e name: libyaml -version: 0.1.0.0 +version: 0.1.1.0 synopsis: Low-level, streaming YAML interface. description: README and API documentation are available at <https://www.stackage.org/package/libyaml> category: Text diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libyaml-0.1.0.0/src/Text/Libyaml.hs new/libyaml-0.1.1.0/src/Text/Libyaml.hs --- old/libyaml-0.1.0.0/src/Text/Libyaml.hs 2018-10-12 08:00:28.000000000 +0200 +++ new/libyaml-0.1.1.0/src/Text/Libyaml.hs 2019-02-12 09:55:54.000000000 +0100 @@ -32,6 +32,11 @@ , FormatOptions , defaultFormatOptions , setWidth + , setTagRendering + , renderScalarTags + , renderAllTags + , renderNoTags + , renderUriTags -- * Error handling , YamlException (..) , YamlMark (..) @@ -121,6 +126,11 @@ | NoTag deriving (Show, Eq, Read, Data, Typeable) +tagSuppressed :: Tag -> Bool +tagSuppressed (NoTag) = True +tagSuppressed (UriTag "") = True +tagSuppressed _ = False + type AnchorName = String type Anchor = Maybe AnchorName @@ -446,8 +456,8 @@ -> Ptr CUChar -> IO CInt -toEventRaw :: Event -> (EventRaw -> IO a) -> IO a -toEventRaw e f = allocaBytes eventSize $ \er -> do +toEventRaw :: FormatOptions -> Event -> (EventRaw -> IO a) -> IO a +toEventRaw opts e f = allocaBytes eventSize $ \er -> do ret <- case e of EventStreamStart -> c_yaml_stream_start_event_initialize @@ -465,13 +475,13 @@ len' = fromIntegral len :: CInt let thetag' = tagToString thetag withCString thetag' $ \tag' -> do - let (pi, style) = - case style0 of - PlainNoTag -> (1, Plain) - x -> (0, x) + let pi0 = tagsImplicit e + (pi, style) = + case style0 of + PlainNoTag -> (1, Plain) + x -> (pi0, x) style' = toEnum $ fromEnum style tagP = castPtr tag' - qi = if null thetag' then 1 else 0 case anchor of Nothing -> c_yaml_scalar_event_initialize @@ -481,7 +491,7 @@ value' -- value len' -- length pi -- plain_implicit - qi -- quoted_implicit + pi -- quoted_implicit style' -- style Just anchor' -> withCString anchor' $ \anchorP' -> do @@ -493,7 +503,7 @@ value' -- value len' -- length 0 -- plain_implicit - qi -- quoted_implicit + pi -- quoted_implicit style' -- style EventSequenceStart tag style Nothing -> withCString (tagToString tag) $ \tag' -> do @@ -502,7 +512,7 @@ er nullPtr tagP - 1 + (tagsImplicit e) (toEnum $ fromEnum style) EventSequenceStart tag style (Just anchor) -> withCString (tagToString tag) $ \tag' -> do @@ -513,7 +523,7 @@ er anchorP tagP - 1 + (tagsImplicit e) (toEnum $ fromEnum style) EventSequenceEnd -> c_yaml_sequence_end_event_initialize er @@ -524,7 +534,7 @@ er nullPtr tagP - 1 + (tagsImplicit e) (toEnum $ fromEnum style) EventMappingStart tag style (Just anchor) -> withCString (tagToString tag) $ \tag' -> do @@ -535,7 +545,7 @@ er anchorP tagP - 1 + (tagsImplicit e) (toEnum $ fromEnum style) EventMappingEnd -> c_yaml_mapping_end_event_initialize er @@ -547,6 +557,11 @@ anchorP unless (ret == 1) $ throwIO $ ToEventRawException ret f er + where + tagsImplicit (EventScalar _ t _ _) | tagSuppressed t = 1 + tagsImplicit (EventMappingStart t _ _) | tagSuppressed t = 1 + tagsImplicit (EventSequenceStart t _ _) | tagSuppressed t = 1 + tagsImplicit evt = toImplicitParam $ formatOptionsRenderTags opts evt newtype ToEventRawException = ToEventRawException CInt deriving (Show, Typeable) @@ -663,11 +678,58 @@ return $ Left $ YamlParseException problem context problemMark else Right <$> getEvent er +-- | Whether a tag should be rendered explicitly in the output or left +-- implicit. +-- +-- @since 0.1.1.0 +data TagRender = Explicit | Implicit + deriving (Enum) + +toImplicitParam :: TagRender -> CInt +toImplicitParam Explicit = 0 +toImplicitParam Implicit = 1 + +-- | A value for 'formatOptionsRenderTags' that renders no +-- collection tags but all scalar tags (unless suppressed with styles +-- 'NoTag or 'PlainNoTag'). +-- +-- @since 0.1.1.0 +renderScalarTags :: Event -> TagRender +renderScalarTags (EventScalar _ _ _ _) = Explicit +renderScalarTags (EventSequenceStart _ _ _) = Implicit +renderScalarTags (EventMappingStart _ _ _) = Implicit +renderScalarTags _ = Implicit + +-- | A value for 'formatOptionsRenderTags' that renders all +-- tags (except 'NoTag' tag and 'PlainNoTag' style). +-- +-- @since 0.1.1.0 +renderAllTags :: Event -> TagRender +renderAllTags _ = Explicit + +-- | A value for 'formatOptionsRenderTags' that renders no +-- tags. +-- +-- @since 0.1.1.0 +renderNoTags :: Event -> TagRender +renderNoTags _ = Implicit + +-- | A value for 'formatOptionsRenderCollectionTags' that renders tags +-- which are instances of 'UriTag' +-- +-- @since 0.1.1.0 +renderUriTags :: Event -> TagRender +renderUriTags (EventScalar _ UriTag{} _ _) = Explicit +renderUriTags (EventSequenceStart UriTag{} _ _) = Explicit +renderUriTags (EventMappingStart UriTag{} _ _) = Explicit +renderUriTags _ = Implicit + -- | Contains options relating to the formatting (indendation, width) of the YAML output. -- -- @since 0.10.2.0 data FormatOptions = FormatOptions { formatOptionsWidth :: Maybe Int + , formatOptionsRenderTags :: Event -> TagRender } -- | @@ -675,6 +737,7 @@ defaultFormatOptions :: FormatOptions defaultFormatOptions = FormatOptions { formatOptionsWidth = Just 80 -- by default the width is set to 0 in the C code, which gets turned into 80 in yaml_emitter_emit_stream_start + , formatOptionsRenderTags = renderScalarTags } -- | Set the maximum number of columns in the YAML output, or 'Nothing' for infinite. By default, the limit is 80 characters. @@ -683,6 +746,12 @@ setWidth :: Maybe Int -> FormatOptions -> FormatOptions setWidth w opts = opts { formatOptionsWidth = w } +-- | Control when and whether tags are rendered to output. +-- +-- @since 0.1.1.0 +setTagRendering :: (Event -> TagRender) -> FormatOptions -> FormatOptions +setTagRendering f opts = opts { formatOptionsRenderTags = f } + encode :: MonadResource m => ConduitM Event o m ByteString encode = encodeWith defaultFormatOptions @@ -756,7 +825,7 @@ loop = await >>= maybe (close ()) push push e = do - _ <- liftIO $ toEventRaw e $ c_yaml_emitter_emit emitter + _ <- liftIO $ toEventRaw opts e $ c_yaml_emitter_emit emitter loop close u = liftIO $ closeI u a