mirror of https://github.com/status-im/NimYAML.git
make sure to also append '\0' for JS as well as C backend
Also remove now unnecessary `os` (was imported for internal `assertStringEqual` test) module import in `tserialization`.
This commit is contained in:
parent
2d47de8c4e
commit
8a7750cb6c
|
@ -5,7 +5,7 @@
|
|||
# distribution, for details about the copyright.
|
||||
|
||||
import "../yaml"
|
||||
import unittest, strutils, tables, times, math, os
|
||||
import unittest, strutils, tables, times, math
|
||||
|
||||
type
|
||||
MyTuple = tuple
|
||||
|
|
|
@ -1161,22 +1161,22 @@ when not defined(JS):
|
|||
|
||||
proc newYamlLexer*(source: string, startAt: int = 0): YamlLexer
|
||||
{.raises: [].} =
|
||||
# append a `\0` at the very end to work around null terminator being
|
||||
# inaccessible
|
||||
let sourceNull = source & '\0'
|
||||
when defined(JS):
|
||||
let sSource = StringSource(pos: startAt, lineStart: startAt, line: 1,
|
||||
src: source)
|
||||
src: sourceNull)
|
||||
result = YamlLexer(buf: "", sSource: sSource,
|
||||
inFlow: false, c: sSource.src[startAt], newlines: 0, folded: true)
|
||||
else:
|
||||
let sSource = new(StringSource)
|
||||
sSource[] = StringSource(pos: startAt, lineStart: startAt, line: 1,
|
||||
src: source)
|
||||
src: sourceNull)
|
||||
GC_ref(sSource)
|
||||
new(result, proc(x: ref YamlLexerObj) {.nimcall.} =
|
||||
GC_unref(cast[ref StringSource](x.source))
|
||||
)
|
||||
# append a `\0` at the very end to work around null terminator being
|
||||
# inaccessible
|
||||
sSource.src.add '\0'
|
||||
result[] = YamlLexerObj(buf: "", source: cast[pointer](sSource),
|
||||
inFlow: false, c: sSource.src[startAt], newlines: 0, folded: true)
|
||||
init[StringSource](result)
|
||||
|
|
Loading…
Reference in New Issue