Merge branch 'devel'

This commit is contained in:
Felix Krause 2016-06-27 21:09:55 +02:00
commit 0f4f13cee5
4 changed files with 20 additions and 4 deletions

View File

@ -1,3 +1,10 @@
### 0.6.1
Bugfixes:
* Fixed deserialization of floats (#17)
* Handle IndexError from queues properly
### 0.6.0 ### 0.6.0
Features: Features:

View File

@ -321,6 +321,14 @@ proc writeTagAndAnchor(target: Stream, tag: TagId, tagLib: TagLibrary,
e.parent = getCurrentException() e.parent = getCurrentException()
raise e raise e
proc nextItem(c: var Queue, s: var YamlStream):
YamlStreamEvent {.raises: [YamlStreamError].} =
if c.len > 0:
try: result = c.dequeue
except IndexError: assert false
else:
result = s.next()
proc present*(s: var YamlStream, target: Stream, tagLib: TagLibrary, proc present*(s: var YamlStream, target: Stream, tagLib: TagLibrary,
options: PresentationOptions = defaultPresentationOptions) = options: PresentationOptions = defaultPresentationOptions) =
var var
@ -330,7 +338,7 @@ proc present*(s: var YamlStream, target: Stream, tagLib: TagLibrary,
let newline = if options.newlines == nlLF: "\l" let newline = if options.newlines == nlLF: "\l"
elif options.newlines == nlCRLF: "\c\l" else: "\n" elif options.newlines == nlCRLF: "\c\l" else: "\n"
while cached.len > 0 or not s.finished(): while cached.len > 0 or not s.finished():
let item = if cached.len > 0: cached.dequeue else: s.next() let item = nextItem(cached, s)
case item.kind case item.kind
of yamlStartDoc: of yamlStartDoc:
if options.style != psJson: if options.style != psJson:

View File

@ -140,7 +140,8 @@ proc constructObject*[T: float|float32|float64](
constructScalarItem(s, item, T): constructScalarItem(s, item, T):
let hint = guessType(item.scalarContent) let hint = guessType(item.scalarContent)
case hint case hint
of yTypeFloat: result = T(parseBiggestFloat(item.scalarContent)) of yTypeFloat:
discard parseBiggestFloat(item.scalarContent, result)
of yTypeFloatInf: of yTypeFloatInf:
if item.scalarContent[0] == '-': result = NegInf if item.scalarContent[0] == '-': result = NegInf
else: result = Inf else: result = Inf
@ -877,4 +878,4 @@ proc dump*[K](value: K, target: Stream, tagStyle: TagStyle = tsRootOnly,
try: present(events, target, serializationTagLibrary, options) try: present(events, target, serializationTagLibrary, options)
except YamlStreamError: except YamlStreamError:
# serializing object does not raise any errors, so we can ignore this # serializing object does not raise any errors, so we can ignore this
assert false, "Can never happen" assert false, "Can never happen"

View File

@ -1,6 +1,6 @@
# Package # Package
version = "0.6.0" version = "0.6.1"
author = "Felix Krause" author = "Felix Krause"
description = "YAML 1.2 implementation for Nim" description = "YAML 1.2 implementation for Nim"
license = "MIT" license = "MIT"