Fix printing and comparing uninitialized strings
This commit is contained in:
parent
ce05a850a5
commit
2b03bed2db
4 changed files with 20 additions and 9 deletions
|
|
@ -228,6 +228,7 @@ proc cstrToNimstr(c: cstring): string {.asmNoStackFrame, compilerproc.} =
|
|||
|
||||
proc toJSStr(s: string): cstring {.asmNoStackFrame, compilerproc.} =
|
||||
asm """
|
||||
if (`s` === null) return "";
|
||||
var len = `s`.length;
|
||||
var asciiPart = new Array(len);
|
||||
var fcc = String.fromCharCode;
|
||||
|
|
@ -330,6 +331,8 @@ proc cmp(x, y: string): int =
|
|||
proc eqStrings(a, b: string): bool {.asmNoStackFrame, compilerProc.} =
|
||||
asm """
|
||||
if (`a` == `b`) return true;
|
||||
if (`a` === null && `b`.length == 0) return true;
|
||||
if (`b` === null && `a`.length == 0) return true;
|
||||
if ((!`a`) || (!`b`)) return false;
|
||||
var alen = `a`.length;
|
||||
if (alen != `b`.length) return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue