summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-02-08 15:47:55 +0100
committerAraq <rumpf_a@web.de>2015-02-08 15:47:55 +0100
commit008b0f19bb73e4c2ef4b636415a1d703aca05ada (patch)
treeb958a4ad4aa1cfa25667b6c1bbd4019026095193
parent34b4e9fc9624042d9fb94a73535baa76b3033376 (diff)
downloadNim-008b0f19bb73e4c2ef4b636415a1d703aca05ada.tar.gz
'nimsuggest' compiles again
-rw-r--r--lib/impure/rdstdin.nim24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/impure/rdstdin.nim b/lib/impure/rdstdin.nim
index 258da2207..b188ead1f 100644
--- a/lib/impure/rdstdin.nim
+++ b/lib/impure/rdstdin.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nim's Runtime Library
-#        (c) Copyright 2012 Andreas Rumpf
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -13,6 +13,8 @@
 ## is used. This suffices because Windows' console already provides the 
 ## wanted functionality.
 
+{.deadCodeElim: on.}
+
 when defined(Windows):
   proc readLineFromStdin*(prompt: string): TaintedString {.
                           tags: [ReadIOEffect, WriteIOEffect].} = 
@@ -31,23 +33,23 @@ when defined(Windows):
     stdout.write(prompt)
     result = readLine(stdin, line)
 
-  proc getch(): cint {.header: "<conio.h>", importc: "_getch".}
-
   proc readPasswordFromStdin*(prompt: string, password: var TaintedString) =
     ## Reads a `password` from stdin without printing it. `password` must not
     ## be ``nil``!
+    proc getch(): cint {.header: "<conio.h>", importc: "_getch".}
+
     password.setLen(0)
     var c: char
     echo prompt
     while true:
-       c = getch().char
-       case c
-       of '\r', chr(0xA):
-          break
-       of '\b':
-          password.setLen(result.len - 1)
-       else:
-          password.add(c)
+      c = getch().char
+      case c
+      of '\r', chr(0xA):
+        break
+      of '\b':
+        password.setLen(password.len - 1)
+      else:
+        password.add(c)
 
 else:
   import readline, history, termios, unsigned