summary refs log tree commit diff stats
path: root/lib/system/jssys.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system/jssys.nim')
-rw-r--r--lib/system/jssys.nim21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim
index a31de0d86..9dfa80877 100644
--- a/lib/system/jssys.nim
+++ b/lib/system/jssys.nim
@@ -725,15 +725,20 @@ const
   IdentChars = {'a'..'z', 'A'..'Z', '0'..'9', '_'}
 
 
-proc parseFloatNative(a: string): float =
-  let a2 = a.cstring
+proc parseFloatNative(a: openarray[char]): float =
+  var str = ""
+  for x in a:
+    str.add x
+
+  let cstr = cstring str
+
   asm """
-  `result` = Number(`a2`);
+  `result` = Number(`cstr`);
   """
 
-proc nimParseBiggestFloat(s: string, number: var BiggestFloat, start: int): int {.compilerproc.} =
+proc nimParseBiggestFloat(s: openarray[char], number: var BiggestFloat): int {.compilerproc.} =
   var sign: bool
-  var i = start
+  var i = 0
   if s[i] == '+': inc(i)
   elif s[i] == '-':
     sign = true
@@ -743,14 +748,14 @@ proc nimParseBiggestFloat(s: string, number: var BiggestFloat, start: int): int
       if s[i+2] == 'N' or s[i+2] == 'n':
         if s[i+3] notin IdentChars:
           number = NaN
-          return i+3 - start
+          return i+3
     return 0
   if s[i] == 'I' or s[i] == 'i':
     if s[i+1] == 'N' or s[i+1] == 'n':
       if s[i+2] == 'F' or s[i+2] == 'f':
         if s[i+3] notin IdentChars:
           number = if sign: -Inf else: Inf
-          return i+3 - start
+          return i+3
     return 0
 
   var buf: string
@@ -782,7 +787,7 @@ proc nimParseBiggestFloat(s: string, number: var BiggestFloat, start: int): int
       addInc()
       eatUnderscores()
   number = parseFloatNative(buf)
-  result = i - start
+  result = i
 
 # Workaround for IE, IE up to version 11 lacks 'Math.trunc'. We produce
 # 'Math.trunc' for Nim's ``div`` and ``mod`` operators: