Skip to content

Commit 48feb1f

Browse files
committed
fixes for Nim 0.20.0, closes #1
1 parent 87f9a62 commit 48feb1f

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sudo: required
2+
services:
3+
- docker
4+
before_install:
5+
- docker pull nimlang/nim
6+
script:
7+
- docker run nimlang/nim nim --version
8+
- docker run -v "$(pwd):/project" -w /project nimlang/nim sh -c "nimble install -dy && nimble test"

src/xml.nim

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ iterator tokens*(input: string): XmlToken {.inline.} =
111111
inc(pos)
112112
var next_ch = input.find(ch, pos)
113113
if next_ch == -1:
114-
error(fmt"unable to find matching string quote last found {pos}")
114+
error(fmt"unable to find matching string quote last found {pos}")
115115
yield token(STRING, input[pos..<next_ch])
116116
pos = next_ch+1
117117
of '>':
@@ -167,7 +167,7 @@ proc newNode(name: string, text = ""): XmlNode =
167167
proc child*(node: XmlNode, name: string): XmlNode =
168168
## finds the first element of `node` with name `name`
169169
## returns `nil` on failure
170-
if not node.children.isNil:
170+
if node.children.len > 0:
171171
for n in node.children:
172172
if n.name == name:
173173
result = n
@@ -179,22 +179,22 @@ proc `$`*(node: XmlNode): string =
179179
if not node.attributes.isNil:
180180
for k, v in node.attributes.pairs:
181181
result.add(fmt" {k}=""{v}""")
182-
if node.text.len == 0 and node.children.isNil:
182+
if node.text.len == 0 and node.children.len == 0:
183183
result.add(" />")
184184
return
185185
elif node.text.len > 0:
186186
result.add(">" & node.text)
187187
else:
188188
result.add(">")
189189
190-
if not node.children.isNil:
190+
if node.children.len > 0:
191191
for child in node.children:
192192
result.add($child)
193193
result.add("</" & node.name & ">")
194194
195195
196196
proc addChild*(node, child: XmlNode) =
197-
if node.children.isNil:
197+
if node.children.len == 0:
198198
node.children = @[]
199199
node.children.add(child)
200200
@@ -302,7 +302,3 @@ when isMainModule:
302302
303303
assert class1.children[3].hasAttr("type")
304304
assert class1.children[3].attr("type") == "Date"
305-
306-
307-
308-

src/xml/selector.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ proc searchCombined(parent: XmlNode, selectors: seq[Selector], found: var seq[Xm
115115
matches = @[]
116116

117117
for j in starts:
118-
if parent.children.isNil:
118+
if parent.children.len == 0:
119119
continue
120120
for k in j..parent.children.len-1:
121121
var child = parent.children[k]
@@ -148,7 +148,7 @@ proc parseSelector(token: string): Selector =
148148
# Type selector
149149
elif token =~ pselectors:
150150
for i in 0..matches.len-1:
151-
if matches[i].isNil:
151+
if matches[i].len == 0:
152152
continue
153153

154154
let ch = matches[i][0]

xml.nimble

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Package
22

3-
version = "0.1.1"
3+
version = "0.1.2"
44
author = "Huy Doan"
55
description = "Pure Nim XML parser"
66
license = "MIT"
77
srcDir = "src"
88

99
# Dependencies
1010

11-
requires "nim >= 0.18.1"
11+
requires "nim >= 0.19.6"

0 commit comments

Comments
 (0)