summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-09-03 11:13:59 +0200
committerAraq <rumpf_a@web.de>2018-09-03 11:13:59 +0200
commite0fd1cdb5fda1dd3e2e38d7741dcb899c9c5d5bb (patch)
treeec6c2ecff3604d8d9b041c623dea18cb124fab4c /lib
parentb3c3a463177ebb0aeb6e9eb11788230ab91c3f08 (diff)
downloadNim-e0fd1cdb5fda1dd3e2e38d7741dcb899c9c5d5bb.tar.gz
fix items for cstring for the JS target; makes tests green again
Diffstat (limited to 'lib')
-rw-r--r--lib/system.nim15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 973a09e99..3a18a715c 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -2195,10 +2195,17 @@ iterator items*[T](a: set[T]): T {.inline.} =
 
 iterator items*(a: cstring): char {.inline.} =
   ## iterates over each item of `a`.
-  var i = 0
-  while a[i] != '\0':
-    yield a[i]
-    inc(i)
+  when defined(js):
+    var i = 0
+    var L = len(a)
+    while i < L:
+      yield a[i]
+      inc(i)
+  else:
+    var i = 0
+    while a[i] != '\0':
+      yield a[i]
+      inc(i)
 
 iterator mitems*(a: var cstring): var char {.inline.} =
   ## iterates over each item of `a` so that you can modify the yielded value.