JS strings have no trailing zero anymore (#8936)

This commit is contained in:
LemonBoy 2018-09-11 11:45:02 +02:00 • committed by Andreas Rumpf
commit 9ba80d2044
3 changed files with 22 additions and 35 deletions

View file

@ -2741,12 +2741,11 @@ type
when defined(JS):
proc add*(x: var string, y: cstring) {.asmNoStackFrame.} =
asm """
var len = `x`.length-1;
var len = `x`.length;
for (var i = 0; i < `y`.length; ++i) {
`x`[len] = `y`.charCodeAt(i);
++len;
}
`x`[len] = 0
"""
proc add*(x: var cstring, y: cstring) {.magic: "AppendStrStr".}