summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorMarkus F.X.J. Oberhumer <markus.oberhumer@oberhumer.com>2017-06-15 20:42:23 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-06-15 20:42:23 +0200
commita0f39e0ab4b050a0ef189917e3892a07f92b57dc (patch)
tree76b392a0a77214f2ea440b6e7f31c21430d227c7 /lib
parent6ca9ad6608b92246198b613c40dcea8ee2b36b5d (diff)
downloadNim-a0f39e0ab4b050a0ef189917e3892a07f92b57dc.tar.gz
Ascii character code 127 (DEL) is not printable and must be quoted. (#5984)
This is a follow-up to #5823.
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/json.nim2
-rw-r--r--lib/pure/pegs.nim2
-rw-r--r--lib/pure/strutils.nim4
-rw-r--r--lib/system/repr.nim4
-rw-r--r--lib/system/reprjs.nim4
5 files changed, 8 insertions, 8 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index 6780ca164..e3d5191c6 100644
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -1001,7 +1001,7 @@ proc escapeJson*(s: string; result: var string) =
   result.add("\"")
   for x in runes(s):
     var r = int(x)
-    if r >= 32 and r <= 127:
+    if r >= 32 and r <= 126:
       var c = chr(r)
       case c
       of '"': result.add("\\\"")
diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim
index 5c978a2f8..6a52e2cd5 100644
--- a/lib/pure/pegs.nim
+++ b/lib/pure/pegs.nim
@@ -371,7 +371,7 @@ proc esc(c: char, reserved = {'\0'..'\255'}): string =
   of '\a': result = "\\a"
   of '\\': result = "\\\\"
   of 'a'..'z', 'A'..'Z', '0'..'9', '_': result = $c
-  elif c < ' ' or c >= '\128': result = '\\' & $ord(c)
+  elif c < ' ' or c >= '\127': result = '\\' & $ord(c)
   elif c in reserved: result = '\\' & c
   else: result = $c
 
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim
index 458c22f3a..20b2657f6 100644
--- a/lib/pure/strutils.nim
+++ b/lib/pure/strutils.nim
@@ -1643,7 +1643,7 @@ proc escape*(s: string, prefix = "\"", suffix = "\""): string {.noSideEffect,
   ## * replaces any ``\`` by ``\\``
   ## * replaces any ``'`` by ``\'``
   ## * replaces any ``"`` by ``\"``
-  ## * replaces any other character in the set ``{'\0'..'\31', '\128'..'\255'}``
+  ## * replaces any other character in the set ``{'\0'..'\31', '\127'..'\255'}``
   ##   by ``\xHH`` where ``HH`` is its hexadecimal value.
   ## The procedure has been designed so that its output is usable for many
   ## different common syntaxes. The resulting string is prefixed with
@@ -1653,7 +1653,7 @@ proc escape*(s: string, prefix = "\"", suffix = "\""): string {.noSideEffect,
   result.add(prefix)
   for c in items(s):
     case c
-    of '\0'..'\31', '\128'..'\255':
+    of '\0'..'\31', '\127'..'\255':
       add(result, "\\x")
       add(result, toHex(ord(c), 2))
     of '\\': add(result, "\\\\")
diff --git a/lib/system/repr.nim b/lib/system/repr.nim
index d9aa03b53..ab02c58a2 100644
--- a/lib/system/repr.nim
+++ b/lib/system/repr.nim
@@ -49,7 +49,7 @@ proc reprStrAux(result: var string, s: cstring; len: int) =
     of '"': add result, "\\\""
     of '\\': add result, "\\\\" # BUGFIX: forgotten
     of '\10': add result, "\\10\"\n\"" # " \n " # better readability
-    of '\128' .. '\255', '\0'..'\9', '\11'..'\31':
+    of '\127' .. '\255', '\0'..'\9', '\11'..'\31':
       add result, "\\" & reprInt(ord(c))
     else:
       result.add(c)
@@ -68,7 +68,7 @@ proc reprChar(x: char): string {.compilerRtl.} =
   case x
   of '"': add result, "\\\""
   of '\\': add result, "\\\\"
-  of '\128' .. '\255', '\0'..'\31': add result, "\\" & reprInt(ord(x))
+  of '\127' .. '\255', '\0'..'\31': add result, "\\" & reprInt(ord(x))
   else: add result, x
   add result, "\'"
 
diff --git a/lib/system/reprjs.nim b/lib/system/reprjs.nim
index 6b0e32191..5c265a891 100644
--- a/lib/system/reprjs.nim
+++ b/lib/system/reprjs.nim
@@ -44,7 +44,7 @@ proc reprChar(x: char): string {.compilerRtl.} =
   case x
   of '"': add(result, "\\\"")
   of '\\': add(result, "\\\\")
-  of '\128'..'\255', '\0'..'\31': add( result, "\\" & reprInt(ord(x)) )
+  of '\127'..'\255', '\0'..'\31': add( result, "\\" & reprInt(ord(x)) )
   else: add(result, x)
   add(result, "\'")
 
@@ -56,7 +56,7 @@ proc reprStrAux(result: var string, s: cstring, len: int) =
     of '"': add(result, "\\\"")
     of '\\': add(result, "\\\\")
     of '\10': add(result, "\\10\"\n\"")
-    of '\128'..'\255', '\0'..'\9', '\11'..'\31':
+    of '\127'..'\255', '\0'..'\9', '\11'..'\31':
       add( result, "\\" & reprInt(ord(c)) )
     else:
       add( result, reprInt(ord(c)) ) # Not sure about this.