From 06ad80cc4555ec1cb80d46baac2d93525137314c Mon Sep 17 00:00:00 2001 From: def Date: Mon, 5 Jan 2015 01:30:03 +0100 Subject: [PATCH 01/15] indent = 0 looks better for `$`(node: JsonNode) --- lib/pure/json.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 385787d6c4..c5510a50e2 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -864,7 +864,7 @@ proc pretty*(node: JsonNode, indent = 2): string = proc `$`*(node: JsonNode): string = ## Converts `node` to its JSON Representation on one line. result = "" - toPretty(result, node, 1, false) + toPretty(result, node, 0, false) iterator items*(node: JsonNode): JsonNode = ## Iterator for the items of `node`. `node` has to be a JArray. From f223e94ccd98448e245e5a7bd7e7da396b9ae9c8 Mon Sep 17 00:00:00 2001 From: def Date: Mon, 5 Jan 2015 01:30:30 +0100 Subject: [PATCH 02/15] Add operator `%*` to JSON --- lib/pure/json.nim | 77 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/lib/pure/json.nim b/lib/pure/json.nim index c5510a50e2..eed01e3761 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -30,9 +30,28 @@ ## ## 1.3000000000000000e+00 ## true +## +## This module can also be used to comfortably create JSON using the `%*` +## operator: +## +## .. code-block:: nim +## +## var hisName = "John" +## let herAge = 31 +## var j = %* +## [ +## { +## "name": hisName, +## "age": 30 +## }, +## { +## "name": "Susan", +## "age": herAge +## } +## ] import - hashes, strutils, lexbase, streams, unicode + hashes, strutils, lexbase, streams, unicode, macros type JsonEventKind* = enum ## enumeration of all events that may occur when parsing @@ -625,6 +644,31 @@ proc `%`*(elements: openArray[JsonNode]): JsonNode = newSeq(result.elems, elements.len) for i, p in pairs(elements): result.elems[i] = p +proc toJson(x: expr): expr {.compiletime.} = + case x.kind + of nnkBracket: + result = newNimNode(nnkBracket) + for i in 0 .. Date: Mon, 5 Jan 2015 13:19:10 +0100 Subject: [PATCH 03/15] Remove debugging echos again --- lib/pure/json.nim | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/pure/json.nim b/lib/pure/json.nim index eed01e3761..1b4b135b63 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -665,9 +665,7 @@ proc toJson(x: expr): expr {.compiletime.} = macro `%*`*(x: expr): expr = ## Convert an expression to a JsonParser directly, without having to specify ## `%` for every element. - echo x.treeRepr result = toJson(x) - echo result.treeRepr proc `==`* (a,b: JsonNode): bool = ## Check two nodes for equality From 39839fda8a428d0d1626d9f2520b79ab68fa472b Mon Sep 17 00:00:00 2001 From: def Date: Tue, 3 Feb 2015 09:04:24 +0100 Subject: [PATCH 04/15] Rename *.nimrod.cfg to *.nim.cfg --- compiler/{nim.nimrod.cfg => nim.nim.cfg} | 0 koch.nimrod.cfg => koch.nim.cfg | 0 lib/{nimrtl.nimrod.cfg => nimrtl.nim.cfg} | 0 lib/pure/{asyncdispatch.nimrod.cfg => asyncdispatch.nim.cfg} | 0 lib/pure/{nimprof.nimrod.cfg => nimprof.nim.cfg} | 0 lib/pure/{smtp.nimrod.cfg => smtp.nim.cfg} | 0 tests/dll/{client.nimrod.cfg => client.nim.cfg} | 0 tests/dll/{server.nimrod.cfg => server.nim.cfg} | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename compiler/{nim.nimrod.cfg => nim.nim.cfg} (100%) rename koch.nimrod.cfg => koch.nim.cfg (100%) rename lib/{nimrtl.nimrod.cfg => nimrtl.nim.cfg} (100%) rename lib/pure/{asyncdispatch.nimrod.cfg => asyncdispatch.nim.cfg} (100%) rename lib/pure/{nimprof.nimrod.cfg => nimprof.nim.cfg} (100%) rename lib/pure/{smtp.nimrod.cfg => smtp.nim.cfg} (100%) rename tests/dll/{client.nimrod.cfg => client.nim.cfg} (100%) rename tests/dll/{server.nimrod.cfg => server.nim.cfg} (100%) diff --git a/compiler/nim.nimrod.cfg b/compiler/nim.nim.cfg similarity index 100% rename from compiler/nim.nimrod.cfg rename to compiler/nim.nim.cfg diff --git a/koch.nimrod.cfg b/koch.nim.cfg similarity index 100% rename from koch.nimrod.cfg rename to koch.nim.cfg diff --git a/lib/nimrtl.nimrod.cfg b/lib/nimrtl.nim.cfg similarity index 100% rename from lib/nimrtl.nimrod.cfg rename to lib/nimrtl.nim.cfg diff --git a/lib/pure/asyncdispatch.nimrod.cfg b/lib/pure/asyncdispatch.nim.cfg similarity index 100% rename from lib/pure/asyncdispatch.nimrod.cfg rename to lib/pure/asyncdispatch.nim.cfg diff --git a/lib/pure/nimprof.nimrod.cfg b/lib/pure/nimprof.nim.cfg similarity index 100% rename from lib/pure/nimprof.nimrod.cfg rename to lib/pure/nimprof.nim.cfg diff --git a/lib/pure/smtp.nimrod.cfg b/lib/pure/smtp.nim.cfg similarity index 100% rename from lib/pure/smtp.nimrod.cfg rename to lib/pure/smtp.nim.cfg diff --git a/tests/dll/client.nimrod.cfg b/tests/dll/client.nim.cfg similarity index 100% rename from tests/dll/client.nimrod.cfg rename to tests/dll/client.nim.cfg diff --git a/tests/dll/server.nimrod.cfg b/tests/dll/server.nim.cfg similarity index 100% rename from tests/dll/server.nimrod.cfg rename to tests/dll/server.nim.cfg From b594c332cacf5294d8d6e3139f3100a307567ed4 Mon Sep 17 00:00:00 2001 From: def Date: Tue, 3 Feb 2015 17:27:29 +0100 Subject: [PATCH 05/15] Add termios wrapper --- lib/posix/termios.nim | 255 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 lib/posix/termios.nim diff --git a/lib/posix/termios.nim b/lib/posix/termios.nim new file mode 100644 index 0000000000..492a1456f4 --- /dev/null +++ b/lib/posix/termios.nim @@ -0,0 +1,255 @@ +{.deadCodeElim: on.} +import posix + +type + Speed* = cuint + Tcflag* = cuint + +const + NCCS* = 32 + +type + Termios* = object {.importc: "struct termios", header: "termios.h>", final, pure.} + iflag*: Tcflag # input mode flags + oflag*: Tcflag # output mode flags + cflag*: Tcflag # control mode flags + lflag*: Tcflag # local mode flags + line*: cuchar # line discipline + cc*: array[NCCS, cuchar] # control characters + ispeed*: Speed # input speed + ospeed*: Speed # output speed + + +# cc characters + +const + VINTR* = 0 + VQUIT* = 1 + VERASE* = 2 + VKILL* = 3 + VEOF* = 4 + VTIME* = 5 + VMIN* = 6 + VSWTC* = 7 + VSTART* = 8 + VSTOP* = 9 + VSUSP* = 10 + VEOL* = 11 + VREPRINT* = 12 + VDISCARD* = 13 + VWERASE* = 14 + VLNEXT* = 15 + VEOL2* = 16 + +# iflag bits + +const + IGNBRK* = 1 + BRKINT* = 2 + IGNPAR* = 4 + PARMRK* = 10 + INPCK* = 20 + ISTRIP* = 40 + INLCR* = 100 + IGNCR* = 200 + ICRNL* = 400 + IUCLC* = 1000 + IXON* = 2000 + IXANY* = 4000 + IXOFF* = 10000 + IMAXBEL* = 20000 + IUTF8* = 40000 + +# oflag bits + +const + OPOST* = 1 + OLCUC* = 2 + ONLCR* = 4 + OCRNL* = 10 + ONOCR* = 20 + ONLRET* = 40 + OFILL* = 100 + OFDEL* = 200 + NLDLY* = 400 + NL0* = 0 + NL1* = 400 + CRDLY* = 3000 + CR0* = 0 + CR1* = 1000 + CR2* = 2000 + CR3* = 3000 + TABDLY* = 14000 + TAB0* = 0 + TAB1* = 4000 + TAB2* = 10000 + TAB3* = 14000 + BSDLY* = 20000 + BS0* = 0 + BS1* = 20000 + FFDLY* = 0o000000100000 + FF0* = 0 + FF1* = 0o000000100000 + VTDLY* = 40000 + VT0* = 0 + VT1* = 40000 + XTABS* = 14000 + +# cflag bit meaning + +const + CBAUD* = 10017 + B0* = 0 + B50* = 1 + B75* = 2 + B110* = 3 + B134* = 4 + B150* = 5 + B200* = 6 + B300* = 7 + B600* = 10 + B1200* = 11 + B1800* = 12 + B2400* = 13 + B4800* = 14 + B9600* = 15 + B19200* = 16 + B38400* = 17 + EXTA* = B19200 + EXTB* = B38400 + CSIZE* = 60 + CS5* = 0 + CS6* = 20 + CS7* = 40 + CS8* = 60 + CSTOPB* = 100 + CREAD* = 200 + PARENB* = 400 + PARODD* = 1000 + HUPCL* = 2000 + CLOCAL* = 4000 + CBAUDEX* = 10000 + B57600* = 10001 + B115200* = 10002 + B230400* = 10003 + B460800* = 10004 + B500000* = 10005 + B576000* = 10006 + B921600* = 10007 + B1000000* = 10010 + B1152000* = 10011 + B1500000* = 10012 + B2000000* = 10013 + B2500000* = 10014 + B3000000* = 10015 + B3500000* = 10016 + B4000000* = 10017 + MAX_BAUD* = B4000000 + CIBAUD* = 2003600000 + CMSPAR* = 0o010000000000 + CRTSCTS* = 0o020000000000 + +# lflag bits + +const + ISIG* = 1 + ICANON* = 2 + XCASE* = 4 + ECHO* = 10 + ECHOE* = 20 + ECHOK* = 40 + ECHONL* = 100 + NOFLSH* = 200 + TOSTOP* = 400 + ECHOCTL* = 1000 + ECHOPRT* = 2000 + ECHOKE* = 4000 + FLUSHO* = 10000 + PENDIN* = 40000 + IEXTEN* = 0o000000100000 + EXTPROC* = 0o000000200000 + +# tcflow() and TCXONC use these + +const + TCOOFF* = 0 + TCOON* = 1 + TCIOFF* = 2 + TCION* = 3 + +# tcflush() and TCFLSH use these + +const + TCIFLUSH* = 0 + TCOFLUSH* = 1 + TCIOFLUSH* = 2 + +# tcsetattr uses these + +const + TCSANOW* = 0 + TCSADRAIN* = 1 + TCSAFLUSH* = 2 + +# Compare a character C to a value VAL from the `cc' array in a +# `struct termios'. If VAL is _POSIX_VDISABLE, no character can match it. + +template CCEQ*(val, c: expr): expr = + ((c) == (val) and (val) != POSIX_VDISABLE) + +# Return the output baud rate stored in *TERMIOS_P. + +proc cfgetospeed*(termios: ptr Termios): Speed {.importc: "cfgetospeed", + header: "".} +# Return the input baud rate stored in *TERMIOS_P. + +proc cfgetispeed*(termios: ptr Termios): Speed {.importc: "cfgetispeed", + header: "".} +# Set the output baud rate stored in *TERMIOS_P to SPEED. + +proc cfsetospeed*(termios: ptr Termios; speed: Speed): cint {. + importc: "cfsetospeed", header: "".} +# Set the input baud rate stored in *TERMIOS_P to SPEED. + +proc cfsetispeed*(termios: ptr Termios; speed: Speed): cint {. + importc: "cfsetispeed", header: "".} +# Set both the input and output baud rates in *TERMIOS_OP to SPEED. + +proc cfsetspeed*(termios: ptr Termios; speed: Speed): cint {. + importc: "cfsetspeed", header: "".} +# Put the state of FD into *TERMIOS_P. + +proc tcgetattr*(fd: cint; termios: ptr Termios): cint {. + importc: "tcgetattr", header: "".} +# Set the state of FD to *TERMIOS_P. +# Values for OPTIONAL_ACTIONS (TCSA*) are in . + +proc tcsetattr*(fd: cint; optional_actions: cint; termios: ptr Termios): cint {. + importc: "tcsetattr", header: "".} +# Set *TERMIOS_P to indicate raw mode. + +proc cfmakeraw*(termios: ptr Termios) {.importc: "cfmakeraw", + header: "".} +# Send zero bits on FD. + +proc tcsendbreak*(fd: cint; duration: cint): cint {.importc: "tcsendbreak", + header: "".} +# Wait for pending output to be written on FD. +# +# This function is a cancellation point and therefore not marked with +# . + +proc tcdrain*(fd: cint): cint {.importc: "tcdrain", header: "".} +# Flush pending data on FD. +# Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in . + +proc tcflush*(fd: cint; queue_selector: cint): cint {.importc: "tcflush", + header: "".} +# Suspend or restart transmission on FD. +# Values for ACTION (TC[IO]{OFF,ON}) are in . + +proc tcflow*(fd: cint; action: cint): cint {.importc: "tcflow", + header: "".} +# Get process group ID for session leader for controlling terminal FD. + +proc tcgetsid*(fd: cint): TPid {.importc: "tcgetsid", header: "".} From 3b68d9e93c603117a301aa5048bfd61774434eb2 Mon Sep 17 00:00:00 2001 From: def Date: Tue, 3 Feb 2015 17:29:09 +0100 Subject: [PATCH 06/15] Add copyright header --- lib/posix/termios.nim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/posix/termios.nim b/lib/posix/termios.nim index 492a1456f4..88aed73c8d 100644 --- a/lib/posix/termios.nim +++ b/lib/posix/termios.nim @@ -1,3 +1,12 @@ +# +# +# Nim's Runtime Library +# (c) Copyright 2015 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + {.deadCodeElim: on.} import posix From dcd23ae1f1b52f48f3d32a753ae4db065b3985f8 Mon Sep 17 00:00:00 2001 From: def Date: Tue, 3 Feb 2015 17:47:27 +0100 Subject: [PATCH 07/15] Add readPasswordFromStdin to rdstdin --- lib/impure/rdstdin.nim | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/lib/impure/rdstdin.nim b/lib/impure/rdstdin.nim index 07ef13fd97..258da22072 100644 --- a/lib/impure/rdstdin.nim +++ b/lib/impure/rdstdin.nim @@ -31,9 +31,27 @@ when defined(Windows): stdout.write(prompt) result = readLine(stdin, line) + proc getch(): cint {.header: "", importc: "_getch".} + + proc readPasswordFromStdin*(prompt: string, password: var TaintedString) = + ## Reads a `password` from stdin without printing it. `password` must not + ## be ``nil``! + 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) + else: - import readline, history - + import readline, history, termios, unsigned + proc readLineFromStdin*(prompt: string): TaintedString {. tags: [ReadIOEffect, WriteIOEffect].} = var buffer = readline.readLine(prompt) @@ -55,8 +73,24 @@ else: result = true # initialization: - # disable auto-complete: + # disable auto-complete: proc doNothing(a, b: cint): cint {.cdecl, procvar.} = discard - + discard readline.bind_key('\t'.ord, doNothing) + proc readPasswordFromStdin*(prompt: string, password: var TaintedString) = + password.setLen(0) + let fd = stdin.getFileHandle() + var cur, old: Termios + discard fd.tcgetattr(cur.addr) + old = cur + cur.lflag = cur.lflag and not Tcflag(ECHO) + discard fd.tcsetattr(TCSADRAIN, cur.addr) + stdout.write prompt + discard stdin.readLine(password) + discard fd.tcsetattr(TCSADRAIN, old.addr) + +proc readPasswordFromStdin*(prompt: string): TaintedString = + ## Reads a password from stdin without printing it. + result = TaintedString("") + readPasswordFromStdin(prompt, result) From 769652ac9060a9a382bae679d819f320eaec936b Mon Sep 17 00:00:00 2001 From: Flaviu Tamas Date: Tue, 3 Feb 2015 21:21:32 -0500 Subject: [PATCH 08/15] Expose exception parent This can be safely exposed because a proc accessor can be created if the representation changes. --- lib/system.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/system.nim b/lib/system.nim index 12c5c63036..958372bb53 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -343,7 +343,7 @@ type ## ## Each exception has to inherit from `Exception`. See the full `exception ## hierarchy`_. - parent: ref Exception ## parent exception (can be used as a stack) + parent*: ref Exception ## parent exception (can be used as a stack) name: cstring ## The exception's name is its Nim identifier. ## This field is filled automatically in the ## ``raise`` statement. From c3ca9bf79e1ec05ae99728f19d66869e1c675819 Mon Sep 17 00:00:00 2001 From: Flaviu Tamas Date: Tue, 3 Feb 2015 21:22:28 -0500 Subject: [PATCH 09/15] Change formatting according to style guide --- lib/system.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index 958372bb53..a6939472b4 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -343,10 +343,10 @@ type ## ## Each exception has to inherit from `Exception`. See the full `exception ## hierarchy`_. - parent*: ref Exception ## parent exception (can be used as a stack) - name: cstring ## The exception's name is its Nim identifier. - ## This field is filled automatically in the - ## ``raise`` statement. + parent*: ref Exception ## parent exception (can be used as a stack) + name: cstring ## The exception's name is its Nim identifier. + ## This field is filled automatically in the + ## ``raise`` statement. msg* {.exportc: "message".}: string ## the exception's message. Not ## providing an exception message ## is bad style. From 4712c6951280befa162687cc98611e052fe71788 Mon Sep 17 00:00:00 2001 From: def Date: Wed, 4 Feb 2015 11:18:24 +0100 Subject: [PATCH 10/15] Fix typo --- lib/posix/termios.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/posix/termios.nim b/lib/posix/termios.nim index 88aed73c8d..94258772fb 100644 --- a/lib/posix/termios.nim +++ b/lib/posix/termios.nim @@ -18,7 +18,7 @@ const NCCS* = 32 type - Termios* = object {.importc: "struct termios", header: "termios.h>", final, pure.} + Termios* = object {.importc: "struct termios", header: "", final, pure.} iflag*: Tcflag # input mode flags oflag*: Tcflag # output mode flags cflag*: Tcflag # control mode flags From 8f18c936c3e15c71141323c1cbdca757938bcc0a Mon Sep 17 00:00:00 2001 From: def Date: Wed, 4 Feb 2015 11:25:58 +0100 Subject: [PATCH 11/15] Change termios proc capitalization --- lib/posix/termios.nim | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/posix/termios.nim b/lib/posix/termios.nim index 94258772fb..2a44624764 100644 --- a/lib/posix/termios.nim +++ b/lib/posix/termios.nim @@ -204,61 +204,61 @@ const # `struct termios'. If VAL is _POSIX_VDISABLE, no character can match it. template CCEQ*(val, c: expr): expr = - ((c) == (val) and (val) != POSIX_VDISABLE) + c == val and val != POSIX_VDISABLE # Return the output baud rate stored in *TERMIOS_P. -proc cfgetospeed*(termios: ptr Termios): Speed {.importc: "cfgetospeed", +proc cfGetOspeed*(termios: ptr Termios): Speed {.importc: "cfgetospeed", header: "".} # Return the input baud rate stored in *TERMIOS_P. -proc cfgetispeed*(termios: ptr Termios): Speed {.importc: "cfgetispeed", +proc cfGetIspeed*(termios: ptr Termios): Speed {.importc: "cfgetispeed", header: "".} # Set the output baud rate stored in *TERMIOS_P to SPEED. -proc cfsetospeed*(termios: ptr Termios; speed: Speed): cint {. +proc cfSetOspeed*(termios: ptr Termios; speed: Speed): cint {. importc: "cfsetospeed", header: "".} # Set the input baud rate stored in *TERMIOS_P to SPEED. -proc cfsetispeed*(termios: ptr Termios; speed: Speed): cint {. +proc cfSetIspeed*(termios: ptr Termios; speed: Speed): cint {. importc: "cfsetispeed", header: "".} # Set both the input and output baud rates in *TERMIOS_OP to SPEED. -proc cfsetspeed*(termios: ptr Termios; speed: Speed): cint {. +proc cfSetSpeed*(termios: ptr Termios; speed: Speed): cint {. importc: "cfsetspeed", header: "".} # Put the state of FD into *TERMIOS_P. -proc tcgetattr*(fd: cint; termios: ptr Termios): cint {. +proc tcGetAttr*(fd: cint; termios: ptr Termios): cint {. importc: "tcgetattr", header: "".} # Set the state of FD to *TERMIOS_P. # Values for OPTIONAL_ACTIONS (TCSA*) are in . -proc tcsetattr*(fd: cint; optional_actions: cint; termios: ptr Termios): cint {. +proc tcSetAttr*(fd: cint; optional_actions: cint; termios: ptr Termios): cint {. importc: "tcsetattr", header: "".} # Set *TERMIOS_P to indicate raw mode. -proc cfmakeraw*(termios: ptr Termios) {.importc: "cfmakeraw", +proc cfMakeRaw*(termios: ptr Termios) {.importc: "cfmakeraw", header: "".} # Send zero bits on FD. -proc tcsendbreak*(fd: cint; duration: cint): cint {.importc: "tcsendbreak", +proc tcSendBreak*(fd: cint; duration: cint): cint {.importc: "tcsendbreak", header: "".} # Wait for pending output to be written on FD. # # This function is a cancellation point and therefore not marked with # . -proc tcdrain*(fd: cint): cint {.importc: "tcdrain", header: "".} +proc tcDrain*(fd: cint): cint {.importc: "tcdrain", header: "".} # Flush pending data on FD. # Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in . -proc tcflush*(fd: cint; queue_selector: cint): cint {.importc: "tcflush", +proc tcFlush*(fd: cint; queue_selector: cint): cint {.importc: "tcflush", header: "".} # Suspend or restart transmission on FD. # Values for ACTION (TC[IO]{OFF,ON}) are in . -proc tcflow*(fd: cint; action: cint): cint {.importc: "tcflow", +proc tcFlow*(fd: cint; action: cint): cint {.importc: "tcflow", header: "".} # Get process group ID for session leader for controlling terminal FD. -proc tcgetsid*(fd: cint): TPid {.importc: "tcgetsid", header: "".} +proc tcGetSid*(fd: cint): TPid {.importc: "tcgetsid", header: "".} From 12ad32e951374c31ff951c8023ef683f454277bc Mon Sep 17 00:00:00 2001 From: def Date: Wed, 4 Feb 2015 13:01:11 +0100 Subject: [PATCH 12/15] Typos --- compiler/msgs.nim | 2 +- compiler/nimconf.nim | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 35a1217692..a80f4a4982 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -460,7 +460,7 @@ type TLineInfo*{.final.} = object # This is designed to be as small as possible, # because it is used - # in syntax nodes. We safe space here by using + # in syntax nodes. We save space here by using # two int16 and an int32. # On 64 bit and on 32 bit systems this is # only 8 bytes. diff --git a/compiler/nimconf.nim b/compiler/nimconf.nim index bcf9b53596..cd1fa784ff 100644 --- a/compiler/nimconf.nim +++ b/compiler/nimconf.nim @@ -14,7 +14,7 @@ import options, idents, wordrecg # ---------------- configuration file parser ----------------------------- -# we use Nim's scanner here to safe space and work +# we use Nim's scanner here to save space and work proc ppGetTok(L: var TLexer, tok: var TToken) = # simple filter @@ -157,7 +157,7 @@ proc checkSymbol(L: TLexer, tok: TToken) = proc parseAssignment(L: var TLexer, tok: var TToken) = if tok.ident.id == getIdent("-").id or tok.ident.id == getIdent("--").id: confTok(L, tok) # skip unnecessary prefix - var info = getLineInfo(L, tok) # safe for later in case of an error + var info = getLineInfo(L, tok) # save for later in case of an error checkSymbol(L, tok) var s = tokToStr(tok) confTok(L, tok) # skip symbol From 2b9d7068cbb38fd9281dde00936eac6d48fe91b1 Mon Sep 17 00:00:00 2001 From: def Date: Wed, 4 Feb 2015 13:01:21 +0100 Subject: [PATCH 13/15] Add support for nimcfg and warning for nimrod.cfg --- compiler/nimconf.nim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/compiler/nimconf.nim b/compiler/nimconf.nim index cd1fa784ff..5304dc2659 100644 --- a/compiler/nimconf.nim +++ b/compiler/nimconf.nim @@ -246,6 +246,11 @@ proc loadConfigs*(cfg: string) = if gProjectName.len != 0: # new project wide config file: - let projectConfig = changeFileExt(gProjectFull, "nim.cfg") - if fileExists(projectConfig): readConfigFile(projectConfig) - else: readConfigFile(changeFileExt(gProjectFull, "nimrod.cfg")) + var projectConfig = changeFileExt(gProjectFull, "nimcfg") + if not fileExists(projectConfig): + projectConfig = changeFileExt(gProjectFull, "nim.cfg") + if not fileExists(projectConfig): + projectConfig = changeFileExt(gProjectFull, "nimrod.cfg") + if fileExists(projectConfig): + rawMessage(warnDeprecated, projectConfig) + readConfigFile(projectConfig) From 5b26c1360b5f56368f533aa26690431eb5ae5f7c Mon Sep 17 00:00:00 2001 From: def Date: Wed, 4 Feb 2015 19:18:09 +0100 Subject: [PATCH 14/15] Rename termios template CCEQ to cceq --- lib/posix/termios.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/posix/termios.nim b/lib/posix/termios.nim index 2a44624764..830e8a2076 100644 --- a/lib/posix/termios.nim +++ b/lib/posix/termios.nim @@ -203,7 +203,7 @@ const # Compare a character C to a value VAL from the `cc' array in a # `struct termios'. If VAL is _POSIX_VDISABLE, no character can match it. -template CCEQ*(val, c: expr): expr = +template cceq*(val, c: expr): expr = c == val and val != POSIX_VDISABLE # Return the output baud rate stored in *TERMIOS_P. From f3922bc4e5f2d01e8b594fbe30f24b2619bec993 Mon Sep 17 00:00:00 2001 From: def Date: Wed, 4 Feb 2015 19:27:56 +0100 Subject: [PATCH 15/15] Fix documentation and toJson signature --- lib/pure/json.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 1b4b135b63..0dc7991d10 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -644,7 +644,7 @@ proc `%`*(elements: openArray[JsonNode]): JsonNode = newSeq(result.elems, elements.len) for i, p in pairs(elements): result.elems[i] = p -proc toJson(x: expr): expr {.compiletime.} = +proc toJson(x: PNimrodNode): PNimrodNode {.compiletime.} = case x.kind of nnkBracket: result = newNimNode(nnkBracket) @@ -663,7 +663,7 @@ proc toJson(x: expr): expr {.compiletime.} = result = prefix(result, "%") macro `%*`*(x: expr): expr = - ## Convert an expression to a JsonParser directly, without having to specify + ## Convert an expression to a JsonNode directly, without having to specify ## `%` for every element. result = toJson(x)