From a79579da6fd03f11dc48f03cc9e8598603fa3863 Mon Sep 17 00:00:00 2001 From: Charlie Barto Date: Wed, 26 Feb 2014 22:25:02 -0500 Subject: [PATCH 1/3] added an overload for highlight.initGeneralTokenizer that accepts a cstring. I use this when calling the highlighter from C#. --- lib/packages/docutils/highlite.nim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/packages/docutils/highlite.nim b/lib/packages/docutils/highlite.nim index 4ca0c79e03..c507f5e1cd 100644 --- a/lib/packages/docutils/highlite.nim +++ b/lib/packages/docutils/highlite.nim @@ -61,9 +61,8 @@ proc getSourceLanguage*(name: string): TSourceLanguage = if cmpIgnoreStyle(name, sourceLanguageToStr[i]) == 0: return i result = langNone - -proc initGeneralTokenizer*(g: var TGeneralTokenizer, buf: string) = - g.buf = cstring(buf) +proc initGeneralTokenizer*(g: var TGeneralTokenizer, buf: cstring) = + g.buf = buf g.kind = low(TTokenClass) g.start = 0 g.length = 0 @@ -71,6 +70,8 @@ proc initGeneralTokenizer*(g: var TGeneralTokenizer, buf: string) = var pos = 0 # skip initial whitespace: while g.buf[pos] in {' ', '\x09'..'\x0D'}: inc(pos) g.pos = pos +proc initGeneralTokenizer*(g: var TGeneralTokenizer, buf: string) = + initGeneralTokenizer(g, cstring(buf)) proc deinitGeneralTokenizer*(g: var TGeneralTokenizer) = discard From f4371bfef85e5a1340de803d90ec176291094d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Thu, 27 Feb 2014 19:48:53 +0100 Subject: [PATCH 2/3] osproc: add warning about using waitForExit without poParentStreams --- lib/pure/osproc.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 2a685f3fb4..582b3c9604 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -168,6 +168,9 @@ proc processID*(p: PProcess): int {.rtl, extern: "nosp$1".} = proc waitForExit*(p: PProcess, timeout: int = -1): int {.rtl, extern: "nosp$1", tags: [].} ## waits for the process to finish and returns `p`'s error code. + ## + ## **Warning**: Be careful when using waitForExit for processes created without + ## poParentStreams because they may fill output buffers, causing deadlock. proc peekExitCode*(p: PProcess): int {.tags: [].} ## return -1 if the process is still running. Otherwise the process' exit code From 0d263f155bc19fcd3797b212d177c22dc213a2d4 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Fri, 28 Feb 2014 19:31:12 +0000 Subject: [PATCH 3/3] Fixes sockets2 on Windows. --- lib/pure/sockets2.nim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/pure/sockets2.nim b/lib/pure/sockets2.nim index 031217b904..3542a0694f 100644 --- a/lib/pure/sockets2.nim +++ b/lib/pure/sockets2.nim @@ -17,7 +17,6 @@ when hostos == "solaris": when defined(Windows): import winlean - export ioctlsocket else: import posix export fcntl, F_GETFL, O_NONBLOCK, F_SETFL @@ -66,6 +65,16 @@ type when defined(windows): let osInvalidSocket* = winlean.INVALID_SOCKET + + const + IOCPARM_MASK* = 127 + IOC_IN* = int(-2147483648) + FIONBIO* = IOC_IN.int32 or ((sizeof(int32) and IOCPARM_MASK) shl 16) or + (102 shl 8) or 126 + + proc ioctlsocket*(s: TSocketHandle, cmd: clong, + argptr: ptr clong): cint {. + stdcall, importc: "ioctlsocket", dynlib: "ws2_32.dll".} else: let osInvalidSocket* = posix.INVALID_SOCKET