Skip to content

Commit

Permalink
Merge pull request #1642 from ringabout/patch-1
Browse files Browse the repository at this point in the history
fixes `LinenoiseCompletions` types incompatible with gcc 14
  • Loading branch information
drkameleon authored May 22, 2024
2 parents 28965c2 + f186c5d commit 72879cf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
3 changes: 1 addition & 2 deletions config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ proc defaultConfig() =
if hostOS != "windows":
--passL:"-pthread"
--path:src
--passC:"-Wno-error=incompatible-pointer-types"


proc configGMPOnWindows() =
Expand Down Expand Up @@ -93,4 +92,4 @@ proc main() =
if not defined(windows) and defined(ssl):
configUnixSSL()

main()
main()
6 changes: 3 additions & 3 deletions src/extras/linenoise.nim
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import os

type
constChar* {.importc:"const char*".} = cstring
LinenoiseCompletions* {.bycopy.} = object
LinenoiseCompletions* {.bycopy, importc: "linenoiseCompletions".} = object
len*: csize_t
cvec*: cstringArray

Expand All @@ -51,8 +51,8 @@ type

{.push header: "linenoise/linenoise.h", cdecl.}

proc linenoiseSetCompletionCallback*(cback: ptr LinenoiseCompletionCallback, userdata: pointer): ptr LinenoiseCompletionCallback {.importc: "linenoiseSetCompletionCallback".}
proc linenoiseSetHintsCallback*(callback: ptr LinenoiseHintsCallback, userdata: pointer) {.importc: "linenoiseSetHintsCallback".}
proc linenoiseSetCompletionCallback*(cback: LinenoiseCompletionCallback, userdata: pointer): LinenoiseCompletionCallback {.importc: "linenoiseSetCompletionCallback".}
proc linenoiseSetHintsCallback*(callback: LinenoiseHintsCallback, userdata: pointer) {.importc: "linenoiseSetHintsCallback".}
proc linenoiseAddCompletion*(a2: ptr LinenoiseCompletions; a3: cstring) {.importc: "linenoiseAddCompletion".}
proc linenoiseReadLine*(prompt: cstring): cstring {.importc: "linenoise".}
proc linenoiseHistoryAdd*(line: cstring): cint {.importc: "linenoiseHistoryAdd", discardable.}
Expand Down
6 changes: 3 additions & 3 deletions src/extras/md4c.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{.compile: "md4c/entity.c".}

type
memBuffer* = ref object
memBuffer* {.importc: "struct membuffer", bycopy.} = object
data*: cstring
asize*: csize_t
size*: csize_t
Expand All @@ -13,10 +13,10 @@ type
func toMarkdown*(
input: cstring,
input_size: cint,
userdata: memBuffer,
userdata: ptr memBuffer,
parser_flags: cint,
renderer_flags: cint): cint {.importc: "toMarkdown",header: "<md4c/md4c-html.h>".}

func freeMarkdownBuffer*(
userdata: memBuffer,
userdata: ptr memBuffer,
) {.importc: "membuf_fini",header: "<md4c/md4c-html.h>".}
4 changes: 2 additions & 2 deletions src/helpers/markdown.nim
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ when not defined(NOPARSERS):
else:
func parseMarkdownInput*(input: string): Value =
var ret: memBuffer = memBuffer(size: 0, asize: 0, data: "")
discard toMarkdown( cstring(input), cint(len(input)),ret,0,0)
discard toMarkdown( cstring(input), cint(len(input)), addr ret,0,0)
var str = newString(ret.size)
copyMem(addr(str[0]), ret.data, ret.size)
freeMarkdownBuffer(ret)
freeMarkdownBuffer(addr ret)
return newString(str)
8 changes: 3 additions & 5 deletions src/helpers/repl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ when not defined(WEB):
createDir(parentDir(path))
discard linenoiseHistoryLoad(path)

var completionCallback: ptr LinenoiseCompletionCallback = cast[ptr LinenoiseCompletionCallback](completionsCback)
discard linenoiseSetCompletionCallback(completionCallback, nil)
discard linenoiseSetCompletionCallback(completionsCback, nil)

var hintCallback: ptr LinenoiseHintsCallback = cast[ptr LinenoiseHintsCallback](hintsCback)
linenoiseSetHintsCallback(hintCallback, nil)
linenoiseSetHintsCallback(hintsCback, nil)

ReplInitialized = true

Expand Down Expand Up @@ -112,4 +110,4 @@ when not defined(WEB):
discard linenoiseHistorySave(historyPath)
result = ($(got),false)

free(got)
free(got)

0 comments on commit 72879cf

Please sign in to comment.