summary refs log tree commit diff stats
path: root/lib/impure/re.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-08-13 11:41:33 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-08-13 11:41:33 +0200
commitdae5450947e93e2e5222ae2710874186bf27bf39 (patch)
treeddb9da438bb516d81491af41ef646abf34d67406 /lib/impure/re.nim
parent32afc1a562579d38e82ebb385186767dfb1bc3c8 (diff)
downloadNim-dae5450947e93e2e5222ae2710874186bf27bf39.tar.gz
WIP: disallow 'nil' for strings and seqs
Diffstat (limited to 'lib/impure/re.nim')
-rw-r--r--lib/impure/re.nim8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/impure/re.nim b/lib/impure/re.nim
index 201c490f3..50a5441e8 100644
--- a/lib/impure/re.nim
+++ b/lib/impure/re.nim
@@ -113,7 +113,7 @@ proc matchOrFind(buf: cstring, pattern: Regex, matches: var openArray[string],
     var b = rawMatches[i * 2 + 1]
     if a >= 0'i32:
       matches[i-1] = bufSubstr(buf, int(a), int(b))
-    else: matches[i-1] = nil
+    else: matches[i-1] = ""
   return rawMatches[1] - rawMatches[0]
 
 proc findBounds*(buf: cstring, pattern: Regex, matches: var openArray[string],
@@ -133,7 +133,7 @@ proc findBounds*(buf: cstring, pattern: Regex, matches: var openArray[string],
     var a = rawMatches[i * 2]
     var b = rawMatches[i * 2 + 1]
     if a >= 0'i32: matches[i-1] = bufSubstr(buf, int(a), int(b))
-    else: matches[i-1] = nil
+    else: matches[i-1] = ""
   return (rawMatches[0].int, rawMatches[1].int - 1)
 
 proc findBounds*(s: string, pattern: Regex, matches: var openArray[string],
@@ -287,7 +287,7 @@ proc find*(buf: cstring, pattern: Regex, matches: var openArray[string],
     var a = rawMatches[i * 2]
     var b = rawMatches[i * 2 + 1]
     if a >= 0'i32: matches[i-1] = bufSubstr(buf, int(a), int(b))
-    else: matches[i-1] = nil
+    else: matches[i-1] = ""
   return rawMatches[0]
 
 proc find*(s: string, pattern: Regex, matches: var openArray[string],
@@ -456,8 +456,6 @@ proc replacef*(s: string, sub: Regex, by: string): string =
   while true:
     var match = findBounds(s, sub, caps, prev)
     if match.first < 0: break
-    assert result != nil
-    assert s != nil
     add(result, substr(s, prev, match.first-1))
     addf(result, by, caps)
     prev = match.last + 1