From fb05fcc95fa8130e7d4ce0cd0e76afc0f47be87a Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Sun, 26 Jun 2016 12:37:15 +0200 Subject: [PATCH 1/3] Fixed undeclared possible IndexError from queues --- private/presenter.nim | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/private/presenter.nim b/private/presenter.nim index 072ff04..fd54732 100644 --- a/private/presenter.nim +++ b/private/presenter.nim @@ -321,6 +321,14 @@ proc writeTagAndAnchor(target: Stream, tag: TagId, tagLib: TagLibrary, e.parent = getCurrentException() 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, options: PresentationOptions = defaultPresentationOptions) = var @@ -330,7 +338,7 @@ proc present*(s: var YamlStream, target: Stream, tagLib: TagLibrary, let newline = if options.newlines == nlLF: "\l" elif options.newlines == nlCRLF: "\c\l" else: "\n" 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 of yamlStartDoc: if options.style != psJson: From b01270dc9e0d3f613e711bba7666fcb44242129c Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Sun, 26 Jun 2016 12:41:06 +0200 Subject: [PATCH 2/3] Fixes #17 --- private/serialization.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/private/serialization.nim b/private/serialization.nim index 662cea4..2ea7eb3 100644 --- a/private/serialization.nim +++ b/private/serialization.nim @@ -140,7 +140,8 @@ proc constructObject*[T: float|float32|float64]( constructScalarItem(s, item, T): let hint = guessType(item.scalarContent) case hint - of yTypeFloat: result = T(parseBiggestFloat(item.scalarContent)) + of yTypeFloat: + discard parseBiggestFloat(item.scalarContent, result) of yTypeFloatInf: if item.scalarContent[0] == '-': result = NegInf else: result = Inf @@ -877,4 +878,4 @@ proc dump*[K](value: K, target: Stream, tagStyle: TagStyle = tsRootOnly, try: present(events, target, serializationTagLibrary, options) except YamlStreamError: # serializing object does not raise any errors, so we can ignore this - assert false, "Can never happen" \ No newline at end of file + assert false, "Can never happen" From a3c3237b62e4be93512ec842472ef1f9a8da16fb Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Mon, 27 Jun 2016 21:09:34 +0200 Subject: [PATCH 3/3] Version 0.6.1 --- CHANGELOG.md | 7 +++++++ yaml.nimble | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ca2c95..734c487 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### 0.6.1 + +Bugfixes: + + * Fixed deserialization of floats (#17) + * Handle IndexError from queues properly + ### 0.6.0 Features: diff --git a/yaml.nimble b/yaml.nimble index fae8f2b..b45bf68 100644 --- a/yaml.nimble +++ b/yaml.nimble @@ -1,6 +1,6 @@ # Package -version = "0.6.0" +version = "0.6.1" author = "Felix Krause" description = "YAML 1.2 implementation for Nim" license = "MIT"