case consistency: next steps
This commit is contained in:
parent
1101a40f91
commit
438703f59e
77 changed files with 513 additions and 514 deletions
|
|
@ -428,7 +428,7 @@ proc clikeNextToken(g: var TGeneralTokenizer, keywords: openArray[string],
|
|||
g.kind = gtOperator
|
||||
of 'a'..'z', 'A'..'Z', '_', '\x80'..'\xFF':
|
||||
var id = ""
|
||||
while g.buf[pos] in SymChars:
|
||||
while g.buf[pos] in symChars:
|
||||
add(id, g.buf[pos])
|
||||
inc(pos)
|
||||
if isKeyword(keywords, id) >= 0: g.kind = gtKeyword
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ const
|
|||
mwUnsupportedLanguage: "language '$1' not supported"
|
||||
]
|
||||
|
||||
proc rstnodeToRefname*(n: PRSTNode): string
|
||||
proc addNodes*(n: PRSTNode): string
|
||||
proc getFieldValue*(n: PRSTNode, fieldname: string): string
|
||||
proc getArgument*(n: PRSTNode): string
|
||||
proc rstnodeToRefname*(n: PRstNode): string
|
||||
proc addNodes*(n: PRstNode): string
|
||||
proc getFieldValue*(n: PRstNode, fieldname: string): string
|
||||
proc getArgument*(n: PRstNode): string
|
||||
|
||||
# ----------------------------- scanner part --------------------------------
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ proc getThing(L: var TLexer, tok: var TToken, s: TCharSet) =
|
|||
tok.line = L.line
|
||||
tok.col = L.col
|
||||
var pos = L.bufpos
|
||||
while True:
|
||||
while true:
|
||||
add(tok.symbol, L.buf[pos])
|
||||
inc(pos)
|
||||
if L.buf[pos] notin s: break
|
||||
|
|
@ -143,7 +143,7 @@ proc getAdornment(L: var TLexer, tok: var TToken) =
|
|||
tok.col = L.col
|
||||
var pos = L.bufpos
|
||||
var c = L.buf[pos]
|
||||
while True:
|
||||
while true:
|
||||
add(tok.symbol, L.buf[pos])
|
||||
inc(pos)
|
||||
if L.buf[pos] != c: break
|
||||
|
|
@ -162,7 +162,7 @@ proc getIndentAux(L: var TLexer, start: int): int =
|
|||
if L.skipPounds:
|
||||
if buf[pos] == '#': inc(pos)
|
||||
if buf[pos] == '#': inc(pos)
|
||||
while True:
|
||||
while true:
|
||||
case buf[pos]
|
||||
of ' ', '\x0B', '\x0C':
|
||||
inc(pos)
|
||||
|
|
@ -251,10 +251,10 @@ proc getTokens(buffer: string, skipPounds: bool, tokens: var TTokenSeq): int =
|
|||
tokens[0].kind = tkIndent
|
||||
|
||||
type
|
||||
TLevelMap = array[Char, int]
|
||||
TLevelMap = array[char, int]
|
||||
TSubstitution{.final.} = object
|
||||
key*: string
|
||||
value*: PRSTNode
|
||||
value*: PRstNode
|
||||
|
||||
TSharedState {.final.} = object
|
||||
options: TRstParseOptions # parsing options
|
||||
|
|
@ -351,7 +351,7 @@ proc initParser(p: var TRstParser, sharedState: PSharedState) =
|
|||
p.line = 1
|
||||
p.s = sharedState
|
||||
|
||||
proc addNodesAux(n: PRSTNode, result: var string) =
|
||||
proc addNodesAux(n: PRstNode, result: var string) =
|
||||
if n.kind == rnLeaf:
|
||||
add(result, n.text)
|
||||
else:
|
||||
|
|
@ -361,7 +361,7 @@ proc addNodes(n: PRstNode): string =
|
|||
result = ""
|
||||
addNodesAux(n, result)
|
||||
|
||||
proc rstnodeToRefnameAux(n: PRSTNode, r: var string, b: var bool) =
|
||||
proc rstnodeToRefnameAux(n: PRstNode, r: var string, b: var bool) =
|
||||
if n.kind == rnLeaf:
|
||||
for i in countup(0, len(n.text) - 1):
|
||||
case n.text[i]
|
||||
|
|
@ -391,7 +391,7 @@ proc rstnodeToRefname(n: PRstNode): string =
|
|||
var b = false
|
||||
rstnodeToRefnameAux(n, result, b)
|
||||
|
||||
proc findSub(p: var TRstParser, n: PRSTNode): int =
|
||||
proc findSub(p: var TRstParser, n: PRstNode): int =
|
||||
var key = addNodes(n)
|
||||
# the spec says: if no exact match, try one without case distinction:
|
||||
for i in countup(0, high(p.s.subs)):
|
||||
|
|
@ -402,7 +402,7 @@ proc findSub(p: var TRstParser, n: PRSTNode): int =
|
|||
return i
|
||||
result = -1
|
||||
|
||||
proc setSub(p: var TRstParser, key: string, value: PRSTNode) =
|
||||
proc setSub(p: var TRstParser, key: string, value: PRstNode) =
|
||||
var length = len(p.s.subs)
|
||||
for i in countup(0, length - 1):
|
||||
if key == p.s.subs[i].key:
|
||||
|
|
@ -412,7 +412,7 @@ proc setSub(p: var TRstParser, key: string, value: PRSTNode) =
|
|||
p.s.subs[length].key = key
|
||||
p.s.subs[length].value = value
|
||||
|
||||
proc setRef(p: var TRstParser, key: string, value: PRSTNode) =
|
||||
proc setRef(p: var TRstParser, key: string, value: PRstNode) =
|
||||
var length = len(p.s.refs)
|
||||
for i in countup(0, length - 1):
|
||||
if key == p.s.refs[i].key:
|
||||
|
|
@ -425,15 +425,15 @@ proc setRef(p: var TRstParser, key: string, value: PRSTNode) =
|
|||
p.s.refs[length].key = key
|
||||
p.s.refs[length].value = value
|
||||
|
||||
proc findRef(p: var TRstParser, key: string): PRSTNode =
|
||||
proc findRef(p: var TRstParser, key: string): PRstNode =
|
||||
for i in countup(0, high(p.s.refs)):
|
||||
if key == p.s.refs[i].key:
|
||||
return p.s.refs[i].value
|
||||
|
||||
proc newLeaf(p: var TRstParser): PRSTNode =
|
||||
proc newLeaf(p: var TRstParser): PRstNode =
|
||||
result = newRstNode(rnLeaf, p.tok[p.idx].symbol)
|
||||
|
||||
proc getReferenceName(p: var TRstParser, endStr: string): PRSTNode =
|
||||
proc getReferenceName(p: var TRstParser, endStr: string): PRstNode =
|
||||
var res = newRstNode(rnInner)
|
||||
while true:
|
||||
case p.tok[p.idx].kind
|
||||
|
|
@ -451,7 +451,7 @@ proc getReferenceName(p: var TRstParser, endStr: string): PRSTNode =
|
|||
inc(p.idx)
|
||||
result = res
|
||||
|
||||
proc untilEol(p: var TRstParser): PRSTNode =
|
||||
proc untilEol(p: var TRstParser): PRstNode =
|
||||
result = newRstNode(rnInner)
|
||||
while not (p.tok[p.idx].kind in {tkIndent, tkEof}):
|
||||
add(result, newLeaf(p))
|
||||
|
|
@ -550,7 +550,7 @@ proc match(p: TRstParser, start: int, expr: string): bool =
|
|||
inc(i)
|
||||
result = true
|
||||
|
||||
proc fixupEmbeddedRef(n, a, b: PRSTNode) =
|
||||
proc fixupEmbeddedRef(n, a, b: PRstNode) =
|
||||
var sep = - 1
|
||||
for i in countdown(len(n) - 2, 0):
|
||||
if n.sons[i].text == "<":
|
||||
|
|
@ -560,7 +560,7 @@ proc fixupEmbeddedRef(n, a, b: PRSTNode) =
|
|||
for i in countup(0, sep - incr): add(a, n.sons[i])
|
||||
for i in countup(sep + 1, len(n) - 2): add(b, n.sons[i])
|
||||
|
||||
proc parsePostfix(p: var TRstParser, n: PRSTNode): PRSTNode =
|
||||
proc parsePostfix(p: var TRstParser, n: PRstNode): PRstNode =
|
||||
result = n
|
||||
if isInlineMarkupEnd(p, "_"):
|
||||
inc(p.idx)
|
||||
|
|
@ -613,7 +613,7 @@ proc matchVerbatim(p: TRstParser, start: int, expr: string): int =
|
|||
inc result
|
||||
if j < expr.len: result = 0
|
||||
|
||||
proc parseSmiley(p: var TRstParser): PRSTNode =
|
||||
proc parseSmiley(p: var TRstParser): PRstNode =
|
||||
if p.tok[p.idx].symbol[0] notin SmileyStartChars: return
|
||||
for key, val in items(Smilies):
|
||||
let m = matchVerbatim(p, p.idx, key)
|
||||
|
|
@ -629,14 +629,14 @@ when false:
|
|||
'$', '(', ')', '~', '_', '?', '+', '-', '=', '\\', '.', '&',
|
||||
'\128'..'\255'}
|
||||
|
||||
proc isURL(p: TRstParser, i: int): bool =
|
||||
proc isUrl(p: TRstParser, i: int): bool =
|
||||
result = (p.tok[i+1].symbol == ":") and (p.tok[i+2].symbol == "//") and
|
||||
(p.tok[i+3].kind == tkWord) and
|
||||
(p.tok[i].symbol in ["http", "https", "ftp", "telnet", "file"])
|
||||
|
||||
proc parseURL(p: var TRstParser, father: PRSTNode) =
|
||||
proc parseUrl(p: var TRstParser, father: PRstNode) =
|
||||
#if p.tok[p.idx].symbol[strStart] == '<':
|
||||
if isURL(p, p.idx):
|
||||
if isUrl(p, p.idx):
|
||||
var n = newRstNode(rnStandaloneHyperlink)
|
||||
while true:
|
||||
case p.tok[p.idx].kind
|
||||
|
|
@ -654,7 +654,7 @@ proc parseURL(p: var TRstParser, father: PRSTNode) =
|
|||
if p.tok[p.idx].symbol == "_": n = parsePostfix(p, n)
|
||||
add(father, n)
|
||||
|
||||
proc parseBackslash(p: var TRstParser, father: PRSTNode) =
|
||||
proc parseBackslash(p: var TRstParser, father: PRstNode) =
|
||||
assert(p.tok[p.idx].kind == tkPunct)
|
||||
if p.tok[p.idx].symbol == "\\\\":
|
||||
add(father, newRstNode(rnLeaf, "\\"))
|
||||
|
|
@ -692,7 +692,7 @@ when false:
|
|||
if p.tok[p.idx].symbol == "_": n = parsePostfix(p, n)
|
||||
add(father, n)
|
||||
|
||||
proc parseUntil(p: var TRstParser, father: PRSTNode, postfix: string,
|
||||
proc parseUntil(p: var TRstParser, father: PRstNode, postfix: string,
|
||||
interpretBackslash: bool) =
|
||||
let
|
||||
line = p.tok[p.idx].line
|
||||
|
|
@ -723,7 +723,7 @@ proc parseUntil(p: var TRstParser, father: PRSTNode, postfix: string,
|
|||
inc(p.idx)
|
||||
else: rstMessage(p, meExpected, postfix, line, col)
|
||||
|
||||
proc parseMarkdownCodeblock(p: var TRstParser): PRSTNode =
|
||||
proc parseMarkdownCodeblock(p: var TRstParser): PRstNode =
|
||||
var args = newRstNode(rnDirArg)
|
||||
if p.tok[p.idx].kind == tkWord:
|
||||
add(args, newLeaf(p))
|
||||
|
|
@ -753,7 +753,7 @@ proc parseMarkdownCodeblock(p: var TRstParser): PRSTNode =
|
|||
add(result, nil)
|
||||
add(result, lb)
|
||||
|
||||
proc parseInline(p: var TRstParser, father: PRSTNode) =
|
||||
proc parseInline(p: var TRstParser, father: PRstNode) =
|
||||
case p.tok[p.idx].kind
|
||||
of tkPunct:
|
||||
if isInlineMarkupStart(p, "***"):
|
||||
|
|
@ -797,7 +797,7 @@ proc parseInline(p: var TRstParser, father: PRSTNode) =
|
|||
if n != nil:
|
||||
add(father, n)
|
||||
return
|
||||
parseURL(p, father)
|
||||
parseUrl(p, father)
|
||||
of tkAdornment, tkOther, tkWhite:
|
||||
if roSupportSmilies in p.s.options:
|
||||
let n = parseSmiley(p)
|
||||
|
|
@ -828,21 +828,21 @@ proc getDirective(p: var TRstParser): string =
|
|||
else:
|
||||
result = ""
|
||||
|
||||
proc parseComment(p: var TRstParser): PRSTNode =
|
||||
proc parseComment(p: var TRstParser): PRstNode =
|
||||
case p.tok[p.idx].kind
|
||||
of tkIndent, tkEof:
|
||||
if p.tok[p.idx].kind != tkEof and p.tok[p.idx + 1].kind == tkIndent:
|
||||
inc(p.idx) # empty comment
|
||||
else:
|
||||
var indent = p.tok[p.idx].ival
|
||||
while True:
|
||||
while true:
|
||||
case p.tok[p.idx].kind
|
||||
of tkEof:
|
||||
break
|
||||
of tkIndent:
|
||||
if (p.tok[p.idx].ival < indent): break
|
||||
else:
|
||||
nil
|
||||
discard
|
||||
inc(p.idx)
|
||||
else:
|
||||
while p.tok[p.idx].kind notin {tkIndent, tkEof}: inc(p.idx)
|
||||
|
|
@ -863,25 +863,25 @@ proc getDirKind(s: string): TDirKind =
|
|||
if i >= 0: result = TDirKind(i)
|
||||
else: result = dkNone
|
||||
|
||||
proc parseLine(p: var TRstParser, father: PRSTNode) =
|
||||
while True:
|
||||
proc parseLine(p: var TRstParser, father: PRstNode) =
|
||||
while true:
|
||||
case p.tok[p.idx].kind
|
||||
of tkWhite, tkWord, tkOther, tkPunct: parseInline(p, father)
|
||||
else: break
|
||||
|
||||
proc parseUntilNewline(p: var TRstParser, father: PRSTNode) =
|
||||
while True:
|
||||
proc parseUntilNewline(p: var TRstParser, father: PRstNode) =
|
||||
while true:
|
||||
case p.tok[p.idx].kind
|
||||
of tkWhite, tkWord, tkAdornment, tkOther, tkPunct: parseInline(p, father)
|
||||
of tkEof, tkIndent: break
|
||||
|
||||
proc parseSection(p: var TRstParser, result: PRSTNode)
|
||||
proc parseField(p: var TRstParser): PRSTNode =
|
||||
proc parseSection(p: var TRstParser, result: PRstNode)
|
||||
proc parseField(p: var TRstParser): PRstNode =
|
||||
result = newRstNode(rnField)
|
||||
var col = p.tok[p.idx].col
|
||||
var fieldname = newRstNode(rnFieldname)
|
||||
var fieldname = newRstNode(rnFieldName)
|
||||
parseUntil(p, fieldname, ":", false)
|
||||
var fieldbody = newRstNode(rnFieldbody)
|
||||
var fieldbody = newRstNode(rnFieldBody)
|
||||
if p.tok[p.idx].kind != tkIndent: parseLine(p, fieldbody)
|
||||
if p.tok[p.idx].kind == tkIndent:
|
||||
var indent = p.tok[p.idx].ival
|
||||
|
|
@ -892,7 +892,7 @@ proc parseField(p: var TRstParser): PRSTNode =
|
|||
add(result, fieldname)
|
||||
add(result, fieldbody)
|
||||
|
||||
proc parseFields(p: var TRstParser): PRSTNode =
|
||||
proc parseFields(p: var TRstParser): PRstNode =
|
||||
result = nil
|
||||
var atStart = p.idx == 0 and p.tok[0].symbol == ":"
|
||||
if (p.tok[p.idx].kind == tkIndent) and (p.tok[p.idx + 1].symbol == ":") or
|
||||
|
|
@ -926,14 +926,14 @@ proc getArgument(n: PRstNode): string =
|
|||
if n.sons[0] == nil: result = ""
|
||||
else: result = addNodes(n.sons[0])
|
||||
|
||||
proc parseDotDot(p: var TRstParser): PRSTNode
|
||||
proc parseLiteralBlock(p: var TRstParser): PRSTNode =
|
||||
proc parseDotDot(p: var TRstParser): PRstNode
|
||||
proc parseLiteralBlock(p: var TRstParser): PRstNode =
|
||||
result = newRstNode(rnLiteralBlock)
|
||||
var n = newRstNode(rnLeaf, "")
|
||||
if p.tok[p.idx].kind == tkIndent:
|
||||
var indent = p.tok[p.idx].ival
|
||||
inc(p.idx)
|
||||
while True:
|
||||
while true:
|
||||
case p.tok[p.idx].kind
|
||||
of tkEof:
|
||||
break
|
||||
|
|
@ -1032,7 +1032,7 @@ proc whichSection(p: TRstParser): TRstNodeKind =
|
|||
else: result = rnParagraph
|
||||
else: result = rnLeaf
|
||||
|
||||
proc parseLineBlock(p: var TRstParser): PRSTNode =
|
||||
proc parseLineBlock(p: var TRstParser): PRstNode =
|
||||
result = nil
|
||||
if p.tok[p.idx + 1].kind == tkWhite:
|
||||
var col = p.tok[p.idx].col
|
||||
|
|
@ -1051,8 +1051,8 @@ proc parseLineBlock(p: var TRstParser): PRSTNode =
|
|||
break
|
||||
popInd(p)
|
||||
|
||||
proc parseParagraph(p: var TRstParser, result: PRSTNode) =
|
||||
while True:
|
||||
proc parseParagraph(p: var TRstParser, result: PRstNode) =
|
||||
while true:
|
||||
case p.tok[p.idx].kind
|
||||
of tkIndent:
|
||||
if p.tok[p.idx + 1].kind == tkIndent:
|
||||
|
|
@ -1082,7 +1082,7 @@ proc parseParagraph(p: var TRstParser, result: PRSTNode) =
|
|||
parseInline(p, result)
|
||||
else: break
|
||||
|
||||
proc parseHeadline(p: var TRstParser): PRSTNode =
|
||||
proc parseHeadline(p: var TRstParser): PRstNode =
|
||||
result = newRstNode(rnHeadline)
|
||||
parseUntilNewline(p, result)
|
||||
assert(p.tok[p.idx].kind == tkIndent)
|
||||
|
|
@ -1112,16 +1112,16 @@ proc getColumns(p: var TRstParser, cols: var TIntSeq) =
|
|||
# last column has no limit:
|
||||
cols[L - 1] = 32000
|
||||
|
||||
proc parseDoc(p: var TRstParser): PRSTNode
|
||||
proc parseDoc(p: var TRstParser): PRstNode
|
||||
|
||||
proc parseSimpleTable(p: var TRstParser): PRSTNode =
|
||||
proc parseSimpleTable(p: var TRstParser): PRstNode =
|
||||
var
|
||||
cols: TIntSeq
|
||||
row: seq[string]
|
||||
i, last, line: int
|
||||
c: char
|
||||
q: TRstParser
|
||||
a, b: PRSTNode
|
||||
a, b: PRstNode
|
||||
result = newRstNode(rnTable)
|
||||
cols = @[]
|
||||
row = @[]
|
||||
|
|
@ -1167,13 +1167,13 @@ proc parseSimpleTable(p: var TRstParser): PRSTNode =
|
|||
add(a, b)
|
||||
add(result, a)
|
||||
|
||||
proc parseTransition(p: var TRstParser): PRSTNode =
|
||||
proc parseTransition(p: var TRstParser): PRstNode =
|
||||
result = newRstNode(rnTransition)
|
||||
inc(p.idx)
|
||||
if p.tok[p.idx].kind == tkIndent: inc(p.idx)
|
||||
if p.tok[p.idx].kind == tkIndent: inc(p.idx)
|
||||
|
||||
proc parseOverline(p: var TRstParser): PRSTNode =
|
||||
proc parseOverline(p: var TRstParser): PRstNode =
|
||||
var c = p.tok[p.idx].symbol[0]
|
||||
inc(p.idx, 2)
|
||||
result = newRstNode(rnOverline)
|
||||
|
|
@ -1192,7 +1192,7 @@ proc parseOverline(p: var TRstParser): PRSTNode =
|
|||
inc(p.idx) # XXX: check?
|
||||
if p.tok[p.idx].kind == tkIndent: inc(p.idx)
|
||||
|
||||
proc parseBulletList(p: var TRstParser): PRSTNode =
|
||||
proc parseBulletList(p: var TRstParser): PRstNode =
|
||||
result = nil
|
||||
if p.tok[p.idx + 1].kind == tkWhite:
|
||||
var bullet = p.tok[p.idx].symbol
|
||||
|
|
@ -1212,7 +1212,7 @@ proc parseBulletList(p: var TRstParser): PRSTNode =
|
|||
break
|
||||
popInd(p)
|
||||
|
||||
proc parseOptionList(p: var TRstParser): PRSTNode =
|
||||
proc parseOptionList(p: var TRstParser): PRstNode =
|
||||
result = newRstNode(rnOptionList)
|
||||
while true:
|
||||
if isOptionList(p):
|
||||
|
|
@ -1241,7 +1241,7 @@ proc parseOptionList(p: var TRstParser): PRSTNode =
|
|||
else:
|
||||
break
|
||||
|
||||
proc parseDefinitionList(p: var TRstParser): PRSTNode =
|
||||
proc parseDefinitionList(p: var TRstParser): PRstNode =
|
||||
result = nil
|
||||
var j = tokenAfterNewline(p) - 1
|
||||
if (j >= 1) and (p.tok[j].kind == tkIndent) and
|
||||
|
|
@ -1272,12 +1272,12 @@ proc parseDefinitionList(p: var TRstParser): PRSTNode =
|
|||
j = tokenAfterNewline(p) - 1
|
||||
if j >= 1 and p.tok[j].kind == tkIndent and p.tok[j].ival > col and
|
||||
p.tok[j-1].symbol != "::" and p.tok[j+1].kind != tkIndent:
|
||||
nil
|
||||
discard
|
||||
else:
|
||||
break
|
||||
if len(result) == 0: result = nil
|
||||
|
||||
proc parseEnumList(p: var TRstParser): PRSTNode =
|
||||
proc parseEnumList(p: var TRstParser): PRstNode =
|
||||
const
|
||||
wildcards: array[0..2, string] = ["(e) ", "e) ", "e. "]
|
||||
wildpos: array[0..2, int] = [1, 0, 0]
|
||||
|
|
@ -1307,7 +1307,7 @@ proc parseEnumList(p: var TRstParser): PRSTNode =
|
|||
dec(p.idx, wildpos[w] + 3)
|
||||
result = nil
|
||||
|
||||
proc sonKind(father: PRSTNode, i: int): TRstNodeKind =
|
||||
proc sonKind(father: PRstNode, i: int): TRstNodeKind =
|
||||
result = rnLeaf
|
||||
if i < len(father): result = father.sons[i].kind
|
||||
|
||||
|
|
@ -1328,14 +1328,14 @@ proc parseSection(p: var TRstParser, result: PRstNode) =
|
|||
leave = true
|
||||
break
|
||||
if leave or p.tok[p.idx].kind == tkEof: break
|
||||
var a: PRSTNode = nil
|
||||
var a: PRstNode = nil
|
||||
var k = whichSection(p)
|
||||
case k
|
||||
of rnLiteralBlock:
|
||||
inc(p.idx) # skip '::'
|
||||
a = parseLiteralBlock(p)
|
||||
of rnBulletList: a = parseBulletList(p)
|
||||
of rnLineblock: a = parseLineBlock(p)
|
||||
of rnLineBlock: a = parseLineBlock(p)
|
||||
of rnDirective: a = parseDotDot(p)
|
||||
of rnEnumList: a = parseEnumList(p)
|
||||
of rnLeaf: rstMessage(p, meNewSectionExpected)
|
||||
|
|
@ -1359,7 +1359,7 @@ proc parseSection(p: var TRstParser, result: PRstNode) =
|
|||
if sonKind(result, 0) == rnParagraph and sonKind(result, 1) != rnParagraph:
|
||||
result.sons[0].kind = rnInner
|
||||
|
||||
proc parseSectionWrapper(p: var TRstParser): PRSTNode =
|
||||
proc parseSectionWrapper(p: var TRstParser): PRstNode =
|
||||
result = newRstNode(rnInner)
|
||||
parseSection(p, result)
|
||||
while (result.kind == rnInner) and (len(result) == 1):
|
||||
|
|
@ -1385,16 +1385,16 @@ type
|
|||
TDirFlag = enum
|
||||
hasArg, hasOptions, argIsFile, argIsWord
|
||||
TDirFlags = set[TDirFlag]
|
||||
TSectionParser = proc (p: var TRstParser): PRSTNode {.nimcall.}
|
||||
TSectionParser = proc (p: var TRstParser): PRstNode {.nimcall.}
|
||||
|
||||
proc parseDirective(p: var TRstParser, flags: TDirFlags): PRSTNode =
|
||||
proc parseDirective(p: var TRstParser, flags: TDirFlags): PRstNode =
|
||||
result = newRstNode(rnDirective)
|
||||
var args: PRSTNode = nil
|
||||
var options: PRSTNode = nil
|
||||
var args: PRstNode = nil
|
||||
var options: PRstNode = nil
|
||||
if hasArg in flags:
|
||||
args = newRstNode(rnDirArg)
|
||||
if argIsFile in flags:
|
||||
while True:
|
||||
while true:
|
||||
case p.tok[p.idx].kind
|
||||
of tkWord, tkOther, tkPunct, tkAdornment:
|
||||
add(args, newLeaf(p))
|
||||
|
|
@ -1420,7 +1420,7 @@ proc indFollows(p: TRstParser): bool =
|
|||
result = p.tok[p.idx].kind == tkIndent and p.tok[p.idx].ival > currInd(p)
|
||||
|
||||
proc parseDirective(p: var TRstParser, flags: TDirFlags,
|
||||
contentParser: TSectionParser): PRSTNode =
|
||||
contentParser: TSectionParser): PRstNode =
|
||||
result = parseDirective(p, flags)
|
||||
if not isNil(contentParser) and indFollows(p):
|
||||
pushInd(p, p.tok[p.idx].ival)
|
||||
|
|
@ -1430,13 +1430,13 @@ proc parseDirective(p: var TRstParser, flags: TDirFlags,
|
|||
else:
|
||||
add(result, nil)
|
||||
|
||||
proc parseDirBody(p: var TRstParser, contentParser: TSectionParser): PRSTNode =
|
||||
proc parseDirBody(p: var TRstParser, contentParser: TSectionParser): PRstNode =
|
||||
if indFollows(p):
|
||||
pushInd(p, p.tok[p.idx].ival)
|
||||
result = contentParser(p)
|
||||
popInd(p)
|
||||
|
||||
proc dirInclude(p: var TRstParser): PRSTNode =
|
||||
proc dirInclude(p: var TRstParser): PRstNode =
|
||||
#
|
||||
#The following options are recognized:
|
||||
#
|
||||
|
|
@ -1474,7 +1474,7 @@ proc dirInclude(p: var TRstParser): PRSTNode =
|
|||
# InternalError("Too many binary zeros in include file")
|
||||
result = parseDoc(q)
|
||||
|
||||
proc dirCodeBlock(p: var TRstParser): PRSTNode =
|
||||
proc dirCodeBlock(p: var TRstParser): PRstNode =
|
||||
result = parseDirective(p, {hasArg, hasOptions}, parseLiteralBlock)
|
||||
var filename = strip(getFieldValue(result, "file"))
|
||||
if filename != "":
|
||||
|
|
@ -1485,34 +1485,34 @@ proc dirCodeBlock(p: var TRstParser): PRSTNode =
|
|||
result.sons[2] = n
|
||||
result.kind = rnCodeBlock
|
||||
|
||||
proc dirContainer(p: var TRstParser): PRSTNode =
|
||||
proc dirContainer(p: var TRstParser): PRstNode =
|
||||
result = parseDirective(p, {hasArg}, parseSectionWrapper)
|
||||
assert(result.kind == rnDirective)
|
||||
assert(len(result) == 3)
|
||||
result.kind = rnContainer
|
||||
|
||||
proc dirImage(p: var TRstParser): PRSTNode =
|
||||
proc dirImage(p: var TRstParser): PRstNode =
|
||||
result = parseDirective(p, {hasOptions, hasArg, argIsFile}, nil)
|
||||
result.kind = rnImage
|
||||
|
||||
proc dirFigure(p: var TRstParser): PRSTNode =
|
||||
proc dirFigure(p: var TRstParser): PRstNode =
|
||||
result = parseDirective(p, {hasOptions, hasArg, argIsFile},
|
||||
parseSectionWrapper)
|
||||
result.kind = rnFigure
|
||||
|
||||
proc dirTitle(p: var TRstParser): PRSTNode =
|
||||
proc dirTitle(p: var TRstParser): PRstNode =
|
||||
result = parseDirective(p, {hasArg}, nil)
|
||||
result.kind = rnTitle
|
||||
|
||||
proc dirContents(p: var TRstParser): PRSTNode =
|
||||
proc dirContents(p: var TRstParser): PRstNode =
|
||||
result = parseDirective(p, {hasArg}, nil)
|
||||
result.kind = rnContents
|
||||
|
||||
proc dirIndex(p: var TRstParser): PRSTNode =
|
||||
proc dirIndex(p: var TRstParser): PRstNode =
|
||||
result = parseDirective(p, {}, parseSectionWrapper)
|
||||
result.kind = rnIndex
|
||||
|
||||
proc dirRawAux(p: var TRstParser, result: var PRSTNode, kind: TRstNodeKind,
|
||||
proc dirRawAux(p: var TRstParser, result: var PRstNode, kind: TRstNodeKind,
|
||||
contentParser: TSectionParser) =
|
||||
var filename = getFieldValue(result, "file")
|
||||
if filename.len > 0:
|
||||
|
|
@ -1527,7 +1527,7 @@ proc dirRawAux(p: var TRstParser, result: var PRSTNode, kind: TRstNodeKind,
|
|||
result.kind = kind
|
||||
add(result, parseDirBody(p, contentParser))
|
||||
|
||||
proc dirRaw(p: var TRstParser): PRSTNode =
|
||||
proc dirRaw(p: var TRstParser): PRstNode =
|
||||
#
|
||||
#The following options are recognized:
|
||||
#
|
||||
|
|
@ -1566,7 +1566,7 @@ proc parseDotDot(p: var TRstParser): PRstNode =
|
|||
result = dirRaw(p)
|
||||
else:
|
||||
rstMessage(p, meInvalidDirective, d)
|
||||
of dkCodeblock: result = dirCodeBlock(p)
|
||||
of dkCodeBlock: result = dirCodeBlock(p)
|
||||
of dkIndex: result = dirIndex(p)
|
||||
else: rstMessage(p, meInvalidDirective, d)
|
||||
popInd(p)
|
||||
|
|
@ -1581,7 +1581,7 @@ proc parseDotDot(p: var TRstParser): PRstNode =
|
|||
# substitution definitions:
|
||||
inc(p.idx, 2)
|
||||
var a = getReferenceName(p, "|")
|
||||
var b: PRSTNode
|
||||
var b: PRstNode
|
||||
if p.tok[p.idx].kind == tkWhite: inc(p.idx)
|
||||
if cmpIgnoreStyle(p.tok[p.idx].symbol, "replace") == 0:
|
||||
inc(p.idx)
|
||||
|
|
@ -1603,7 +1603,7 @@ proc parseDotDot(p: var TRstParser): PRstNode =
|
|||
else:
|
||||
result = parseComment(p)
|
||||
|
||||
proc resolveSubs(p: var TRstParser, n: PRSTNode): PRSTNode =
|
||||
proc resolveSubs(p: var TRstParser, n: PRstNode): PRstNode =
|
||||
result = n
|
||||
if n == nil: return
|
||||
case n.kind
|
||||
|
|
@ -1634,7 +1634,7 @@ proc rstParse*(text, filename: string,
|
|||
line, column: int, hasToc: var bool,
|
||||
options: TRstParseOptions,
|
||||
findFile: TFindFileHandler = nil,
|
||||
msgHandler: TMsgHandler = nil): PRSTNode =
|
||||
msgHandler: TMsgHandler = nil): PRstNode =
|
||||
var p: TRstParser
|
||||
initParser(p, newSharedState(options, findFile, msgHandler))
|
||||
p.filename = filename
|
||||
|
|
|
|||
|
|
@ -62,34 +62,34 @@ type
|
|||
# leaf val
|
||||
|
||||
|
||||
PRSTNode* = ref TRSTNode ## an RST node
|
||||
TRstNodeSeq* = seq[PRSTNode]
|
||||
TRSTNode* {.acyclic, final.} = object ## an RST node's description
|
||||
PRstNode* = ref TRstNode ## an RST node
|
||||
TRstNodeSeq* = seq[PRstNode]
|
||||
TRstNode* {.acyclic, final.} = object ## an RST node's description
|
||||
kind*: TRstNodeKind ## the node's kind
|
||||
text*: string ## valid for leafs in the AST; and the title of
|
||||
## the document or the section
|
||||
level*: int ## valid for some node kinds
|
||||
sons*: TRstNodeSeq ## the node's sons
|
||||
|
||||
proc len*(n: PRSTNode): int =
|
||||
proc len*(n: PRstNode): int =
|
||||
result = len(n.sons)
|
||||
|
||||
proc newRstNode*(kind: TRstNodeKind): PRSTNode =
|
||||
proc newRstNode*(kind: TRstNodeKind): PRstNode =
|
||||
new(result)
|
||||
result.sons = @[]
|
||||
result.kind = kind
|
||||
|
||||
proc newRstNode*(kind: TRstNodeKind, s: string): PRSTNode =
|
||||
proc newRstNode*(kind: TRstNodeKind, s: string): PRstNode =
|
||||
result = newRstNode(kind)
|
||||
result.text = s
|
||||
|
||||
proc lastSon*(n: PRSTNode): PRSTNode =
|
||||
proc lastSon*(n: PRstNode): PRstNode =
|
||||
result = n.sons[len(n.sons)-1]
|
||||
|
||||
proc add*(father, son: PRSTNode) =
|
||||
proc add*(father, son: PRstNode) =
|
||||
add(father.sons, son)
|
||||
|
||||
proc addIfNotNil*(father, son: PRSTNode) =
|
||||
proc addIfNotNil*(father, son: PRstNode) =
|
||||
if son != nil: add(father, son)
|
||||
|
||||
|
||||
|
|
@ -98,9 +98,9 @@ type
|
|||
indent: int
|
||||
verbatim: int
|
||||
|
||||
proc renderRstToRst(d: var TRenderContext, n: PRSTNode, result: var string)
|
||||
proc renderRstToRst(d: var TRenderContext, n: PRstNode, result: var string)
|
||||
|
||||
proc renderRstSons(d: var TRenderContext, n: PRSTNode, result: var string) =
|
||||
proc renderRstSons(d: var TRenderContext, n: PRstNode, result: var string) =
|
||||
for i in countup(0, len(n) - 1):
|
||||
renderRstToRst(d, n.sons[i], result)
|
||||
|
||||
|
|
@ -281,7 +281,7 @@ proc renderRstToRst(d: var TRenderContext, n: PRstNode, result: var string) =
|
|||
else:
|
||||
result.add("Error: cannot render: " & $n.kind)
|
||||
|
||||
proc renderRstToRst*(n: PRSTNode, result: var string) =
|
||||
proc renderRstToRst*(n: PRstNode, result: var string) =
|
||||
## renders `n` into its string representation and appends to `result`.
|
||||
var d: TRenderContext
|
||||
renderRstToRst(d, n, result)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ type
|
|||
outLatex # output is Latex
|
||||
|
||||
TTocEntry{.final.} = object
|
||||
n*: PRSTNode
|
||||
n*: PRstNode
|
||||
refname*, header*: string
|
||||
|
||||
TMetaEnum* = enum
|
||||
|
|
@ -196,7 +196,7 @@ proc dispA(target: TOutputTarget, dest: var string,
|
|||
if target != outLatex: addf(dest, xml, args)
|
||||
else: addf(dest, tex, args)
|
||||
|
||||
proc renderRstToOut*(d: var TRstGenerator, n: PRSTNode, result: var string)
|
||||
proc renderRstToOut*(d: var TRstGenerator, n: PRstNode, result: var string)
|
||||
## Writes into ``result`` the rst ast ``n`` using the ``d`` configuration.
|
||||
##
|
||||
## Before using this proc you need to initialise a ``TRstGenerator`` with
|
||||
|
|
@ -210,10 +210,10 @@ proc renderRstToOut*(d: var TRstGenerator, n: PRSTNode, result: var string)
|
|||
## renderRstToOut(gen, rst, generatedHTML)
|
||||
## echo generatedHTML
|
||||
|
||||
proc renderAux(d: PDoc, n: PRSTNode, result: var string) =
|
||||
proc renderAux(d: PDoc, n: PRstNode, result: var string) =
|
||||
for i in countup(0, len(n)-1): renderRstToOut(d, n.sons[i], result)
|
||||
|
||||
proc renderAux(d: PDoc, n: PRSTNode, frmtA, frmtB: string, result: var string) =
|
||||
proc renderAux(d: PDoc, n: PRstNode, frmtA, frmtB: string, result: var string) =
|
||||
var tmp = ""
|
||||
for i in countup(0, len(n)-1): renderRstToOut(d, n.sons[i], tmp)
|
||||
if d.target != outLatex:
|
||||
|
|
@ -232,7 +232,7 @@ proc setIndexTerm*(d: var TRstGenerator, id, term: string) =
|
|||
d.theIndex.add(id)
|
||||
d.theIndex.add("\n")
|
||||
|
||||
proc hash(n: PRSTNode): int =
|
||||
proc hash(n: PRstNode): int =
|
||||
if n.kind == rnLeaf:
|
||||
result = hash(n.text)
|
||||
elif n.len > 0:
|
||||
|
|
@ -241,7 +241,7 @@ proc hash(n: PRSTNode): int =
|
|||
result = result !& hash(n.sons[i])
|
||||
result = !$result
|
||||
|
||||
proc renderIndexTerm(d: PDoc, n: PRSTNode, result: var string) =
|
||||
proc renderIndexTerm(d: PDoc, n: PRstNode, result: var string) =
|
||||
let id = rstnodeToRefname(n) & '_' & $abs(hash(n))
|
||||
var term = ""
|
||||
renderAux(d, n, term)
|
||||
|
|
@ -314,7 +314,7 @@ proc mergeIndexes*(dir: string): string =
|
|||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
proc renderHeadline(d: PDoc, n: PRSTNode, result: var string) =
|
||||
proc renderHeadline(d: PDoc, n: PRstNode, result: var string) =
|
||||
var tmp = ""
|
||||
for i in countup(0, len(n) - 1): renderRstToOut(d, n.sons[i], tmp)
|
||||
var refname = rstnodeToRefname(n)
|
||||
|
|
@ -336,7 +336,7 @@ proc renderHeadline(d: PDoc, n: PRSTNode, result: var string) =
|
|||
$n.level, refname, tmp,
|
||||
$chr(n.level - 1 + ord('A'))])
|
||||
|
||||
proc renderOverline(d: PDoc, n: PRSTNode, result: var string) =
|
||||
proc renderOverline(d: PDoc, n: PRstNode, result: var string) =
|
||||
if d.meta[metaTitle].len == 0:
|
||||
for i in countup(0, len(n)-1):
|
||||
renderRstToOut(d, n.sons[i], d.meta[metaTitle])
|
||||
|
|
@ -373,7 +373,7 @@ proc renderTocEntries*(d: var TRstGenerator, j: var int, lvl: int, result: var s
|
|||
else:
|
||||
result.add(tmp)
|
||||
|
||||
proc renderImage(d: PDoc, n: PRSTNode, result: var string) =
|
||||
proc renderImage(d: PDoc, n: PRstNode, result: var string) =
|
||||
var options = ""
|
||||
var s = getFieldValue(n, "scale")
|
||||
if s != "": dispA(d.target, options, " scale=\"$1\"", " scale=$1", [strip(s)])
|
||||
|
|
@ -396,13 +396,13 @@ proc renderImage(d: PDoc, n: PRSTNode, result: var string) =
|
|||
[getArgument(n), options])
|
||||
if len(n) >= 3: renderRstToOut(d, n.sons[2], result)
|
||||
|
||||
proc renderSmiley(d: PDoc, n: PRSTNode, result: var string) =
|
||||
proc renderSmiley(d: PDoc, n: PRstNode, result: var string) =
|
||||
dispA(d.target, result,
|
||||
"""<img src="/images/smilies/$1.gif" width="15"
|
||||
height="17" hspace="2" vspace="2" />""",
|
||||
"\\includegraphics{$1}", [n.text])
|
||||
|
||||
proc renderCodeBlock(d: PDoc, n: PRSTNode, result: var string) =
|
||||
proc renderCodeBlock(d: PDoc, n: PRstNode, result: var string) =
|
||||
if n.sons[2] == nil: return
|
||||
var m = n.sons[2].sons[0]
|
||||
assert m.kind == rnLeaf
|
||||
|
|
@ -433,7 +433,7 @@ proc renderCodeBlock(d: PDoc, n: PRSTNode, result: var string) =
|
|||
deinitGeneralTokenizer(g)
|
||||
dispA(d.target, result, "</pre>", "\n\\end{rstpre}\n")
|
||||
|
||||
proc renderContainer(d: PDoc, n: PRSTNode, result: var string) =
|
||||
proc renderContainer(d: PDoc, n: PRstNode, result: var string) =
|
||||
var tmp = ""
|
||||
renderRstToOut(d, n.sons[2], tmp)
|
||||
var arg = strip(getArgument(n))
|
||||
|
|
@ -442,11 +442,11 @@ proc renderContainer(d: PDoc, n: PRSTNode, result: var string) =
|
|||
else:
|
||||
dispA(d.target, result, "<div class=\"$1\">$2</div>", "$2", [arg, tmp])
|
||||
|
||||
proc texColumns(n: PRSTNode): string =
|
||||
proc texColumns(n: PRstNode): string =
|
||||
result = ""
|
||||
for i in countup(1, len(n)): add(result, "|X")
|
||||
|
||||
proc renderField(d: PDoc, n: PRSTNode, result: var string) =
|
||||
proc renderField(d: PDoc, n: PRstNode, result: var string) =
|
||||
var b = false
|
||||
if d.target == outLatex:
|
||||
var fieldname = addNodes(n.sons[0])
|
||||
|
|
|
|||
|
|
@ -645,7 +645,7 @@ proc hasKey*(node: PJsonNode, key: string): bool =
|
|||
## Checks if `key` exists in `node`.
|
||||
assert(node.kind == JObject)
|
||||
for k, item in items(node.fields):
|
||||
if k == key: return True
|
||||
if k == key: return true
|
||||
proc existsKey*(node: PJsonNode, key: string): bool {.deprecated.} = node.hasKey(key)
|
||||
## Deprecated for `hasKey`
|
||||
|
||||
|
|
@ -730,8 +730,8 @@ proc escapeJson*(s: string): string =
|
|||
result.add(toHex(r, 4))
|
||||
result.add("\"")
|
||||
|
||||
proc toPretty(result: var string, node: PJsonNode, indent = 2, ml = True,
|
||||
lstArr = False, currIndent = 0) =
|
||||
proc toPretty(result: var string, node: PJsonNode, indent = 2, ml = true,
|
||||
lstArr = false, currIndent = 0) =
|
||||
case node.kind
|
||||
of JObject:
|
||||
if currIndent != 0 and not lstArr: result.nl(ml)
|
||||
|
|
@ -747,7 +747,7 @@ proc toPretty(result: var string, node: PJsonNode, indent = 2, ml = True,
|
|||
result.indent(newIndent(currIndent, indent, ml))
|
||||
result.add(escapeJson(node.fields[i].key))
|
||||
result.add(": ")
|
||||
toPretty(result, node.fields[i].val, indent, ml, False,
|
||||
toPretty(result, node.fields[i].val, indent, ml, false,
|
||||
newIndent(currIndent, indent, ml))
|
||||
result.nl(ml)
|
||||
result.indent(currIndent) # indent the same as {
|
||||
|
|
@ -776,7 +776,7 @@ proc toPretty(result: var string, node: PJsonNode, indent = 2, ml = True,
|
|||
result.add(", ")
|
||||
result.nl(ml) # New Line
|
||||
toPretty(result, node.elems[i], indent, ml,
|
||||
True, newIndent(currIndent, indent, ml))
|
||||
true, newIndent(currIndent, indent, ml))
|
||||
result.nl(ml)
|
||||
result.indent(currIndent)
|
||||
result.add("]")
|
||||
|
|
@ -794,7 +794,7 @@ proc pretty*(node: PJsonNode, indent = 2): string =
|
|||
proc `$`*(node: PJsonNode): string =
|
||||
## Converts `node` to its JSON Representation on one line.
|
||||
result = ""
|
||||
toPretty(result, node, 1, False)
|
||||
toPretty(result, node, 1, false)
|
||||
|
||||
iterator items*(node: PJsonNode): PJsonNode =
|
||||
## Iterator for the items of `node`. `node` has to be a JArray.
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ proc fillBuffer(L: var TBaseLexer) =
|
|||
oldBufLen = L.BufLen
|
||||
L.bufLen = L.BufLen * 2
|
||||
L.buf = cast[cstring](realloc(L.buf, L.bufLen * chrSize))
|
||||
assert(L.bufLen - oldBuflen == oldBufLen)
|
||||
assert(L.bufLen - oldBufLen == oldBufLen)
|
||||
charsRead = readData(L.input, addr(L.buf[oldBufLen]),
|
||||
oldBufLen * chrSize) div chrSize
|
||||
if charsRead < oldBufLen:
|
||||
|
|
|
|||
|
|
@ -95,8 +95,8 @@ elif defined(macos):
|
|||
const
|
||||
CurDir* = ':'
|
||||
ParDir* = "::"
|
||||
Dirsep* = ':'
|
||||
Altsep* = Dirsep
|
||||
DirSep* = ':'
|
||||
AltSep* = Dirsep
|
||||
PathSep* = ','
|
||||
FileSystemCaseSensitive* = false
|
||||
ExeExt* = ""
|
||||
|
|
@ -123,10 +123,10 @@ elif defined(macos):
|
|||
# grandparent etc.
|
||||
elif doslike:
|
||||
const
|
||||
Curdir* = '.'
|
||||
Pardir* = ".."
|
||||
Dirsep* = '\\' # seperator within paths
|
||||
Altsep* = '/'
|
||||
CurDir* = '.'
|
||||
ParDir* = ".."
|
||||
DirSep* = '\\' # seperator within paths
|
||||
AltSep* = '/'
|
||||
PathSep* = ';' # seperator between paths
|
||||
FileSystemCaseSensitive* = false
|
||||
ExeExt* = "exe"
|
||||
|
|
@ -134,19 +134,19 @@ elif doslike:
|
|||
DynlibFormat* = "$1.dll"
|
||||
elif defined(PalmOS) or defined(MorphOS):
|
||||
const
|
||||
Dirsep* = '/'
|
||||
Altsep* = Dirsep
|
||||
DirSep* = '/'
|
||||
AltSep* = Dirsep
|
||||
PathSep* = ';'
|
||||
Pardir* = ".."
|
||||
ParDir* = ".."
|
||||
FileSystemCaseSensitive* = false
|
||||
ExeExt* = ""
|
||||
ScriptExt* = ""
|
||||
DynlibFormat* = "$1.prc"
|
||||
elif defined(RISCOS):
|
||||
const
|
||||
Dirsep* = '.'
|
||||
Altsep* = '.'
|
||||
Pardir* = ".." # is this correct?
|
||||
DirSep* = '.'
|
||||
AltSep* = '.'
|
||||
ParDir* = ".." # is this correct?
|
||||
PathSep* = ','
|
||||
FileSystemCaseSensitive* = true
|
||||
ExeExt* = ""
|
||||
|
|
@ -154,10 +154,10 @@ elif defined(RISCOS):
|
|||
DynlibFormat* = "lib$1.so"
|
||||
else: # UNIX-like operating system
|
||||
const
|
||||
Curdir* = '.'
|
||||
Pardir* = ".."
|
||||
Dirsep* = '/'
|
||||
Altsep* = Dirsep
|
||||
CurDir* = '.'
|
||||
ParDir* = ".."
|
||||
DirSep* = '/'
|
||||
AltSep* = Dirsep
|
||||
PathSep* = ':'
|
||||
FileSystemCaseSensitive* = true
|
||||
ExeExt* = ""
|
||||
|
|
@ -308,7 +308,7 @@ proc unixToNativePath*(path: string): string {.
|
|||
start = 1
|
||||
elif path[0] == '.' and path[1] == '/':
|
||||
# current directory
|
||||
result = $Curdir
|
||||
result = $CurDir
|
||||
start = 2
|
||||
else:
|
||||
result = ""
|
||||
|
|
@ -538,7 +538,7 @@ proc splitPath*(path: string): tuple[head, tail: string] {.
|
|||
## splitPath("") -> ("", "")
|
||||
var sepPos = -1
|
||||
for i in countdown(len(path)-1, 0):
|
||||
if path[i] in {Dirsep, Altsep}:
|
||||
if path[i] in {DirSep, AltSep}:
|
||||
sepPos = i
|
||||
break
|
||||
if sepPos >= 0:
|
||||
|
|
@ -550,9 +550,9 @@ proc splitPath*(path: string): tuple[head, tail: string] {.
|
|||
|
||||
proc parentDirPos(path: string): int =
|
||||
var q = 1
|
||||
if path[len(path)-1] in {Dirsep, Altsep}: q = 2
|
||||
if path[len(path)-1] in {DirSep, AltSep}: q = 2
|
||||
for i in countdown(len(path)-q, 0):
|
||||
if path[i] in {Dirsep, Altsep}: return i
|
||||
if path[i] in {DirSep, AltSep}: return i
|
||||
result = -1
|
||||
|
||||
proc parentDir*(path: string): string {.
|
||||
|
|
@ -593,8 +593,8 @@ iterator parentDirs*(path: string, fromRoot=false, inclusive=true): string =
|
|||
else:
|
||||
for i in countup(0, path.len - 2): # ignore the last /
|
||||
# deal with non-normalized paths such as /foo//bar//baz
|
||||
if path[i] in {Dirsep, Altsep} and
|
||||
(i == 0 or path[i-1] notin {Dirsep, Altsep}):
|
||||
if path[i] in {DirSep, AltSep} and
|
||||
(i == 0 or path[i-1] notin {DirSep, AltSep}):
|
||||
yield path.substr(0, i)
|
||||
|
||||
if inclusive: yield path
|
||||
|
|
@ -619,7 +619,7 @@ proc searchExtPos(s: string): int =
|
|||
if s[i] == ExtSep:
|
||||
result = i
|
||||
break
|
||||
elif s[i] in {Dirsep, Altsep}:
|
||||
elif s[i] in {DirSep, AltSep}:
|
||||
break # do not skip over path
|
||||
|
||||
proc splitFile*(path: string): tuple[dir, name, ext: string] {.
|
||||
|
|
@ -639,7 +639,7 @@ proc splitFile*(path: string): tuple[dir, name, ext: string] {.
|
|||
## If `path` has no extension, `ext` is the empty string.
|
||||
## If `path` has no directory component, `dir` is the empty string.
|
||||
## If `path` has no filename component, `name` and `ext` are empty strings.
|
||||
if path.len == 0 or path[path.len-1] in {DirSep, Altsep}:
|
||||
if path.len == 0 or path[path.len-1] in {DirSep, AltSep}:
|
||||
result = (path, "", "")
|
||||
else:
|
||||
var sepPos = -1
|
||||
|
|
@ -647,8 +647,8 @@ proc splitFile*(path: string): tuple[dir, name, ext: string] {.
|
|||
for i in countdown(len(path)-1, 0):
|
||||
if path[i] == ExtSep:
|
||||
if dotPos == path.len and i > 0 and
|
||||
path[i-1] notin {Dirsep, Altsep}: dotPos = i
|
||||
elif path[i] in {Dirsep, Altsep}:
|
||||
path[i-1] notin {DirSep, AltSep}: dotPos = i
|
||||
elif path[i] in {DirSep, AltSep}:
|
||||
sepPos = i
|
||||
break
|
||||
result.dir = substr(path, 0, sepPos-1)
|
||||
|
|
@ -659,7 +659,7 @@ proc extractFilename*(path: string): string {.
|
|||
noSideEffect, rtl, extern: "nos$1".} =
|
||||
## Extracts the filename of a given `path`. This is the same as
|
||||
## ``name & ext`` from ``splitFile(path)``.
|
||||
if path.len == 0 or path[path.len-1] in {DirSep, Altsep}:
|
||||
if path.len == 0 or path[path.len-1] in {DirSep, AltSep}:
|
||||
result = ""
|
||||
else:
|
||||
result = splitPath(path).tail
|
||||
|
|
@ -814,11 +814,11 @@ proc sameFileContent*(path1, path2: string): bool {.rtl, extern: "nos$1",
|
|||
if not open(b, path2):
|
||||
close(a)
|
||||
return false
|
||||
var bufA = alloc(bufsize)
|
||||
var bufB = alloc(bufsize)
|
||||
var bufA = alloc(bufSize)
|
||||
var bufB = alloc(bufSize)
|
||||
while true:
|
||||
var readA = readBuffer(a, bufA, bufsize)
|
||||
var readB = readBuffer(b, bufB, bufsize)
|
||||
var readA = readBuffer(a, bufA, bufSize)
|
||||
var readB = readBuffer(b, bufB, bufSize)
|
||||
if readA != readB:
|
||||
result = false
|
||||
break
|
||||
|
|
@ -1159,7 +1159,7 @@ iterator walkFiles*(pattern: string): string {.tags: [FReadDir].} =
|
|||
while true:
|
||||
if not skipFindData(f):
|
||||
yield splitFile(pattern).dir / extractFilename(getFilename(f))
|
||||
if findnextFile(res, f) == 0'i32: break
|
||||
if findNextFile(res, f) == 0'i32: break
|
||||
findClose(res)
|
||||
else: # here we use glob
|
||||
var
|
||||
|
|
@ -1214,7 +1214,7 @@ iterator walkDir*(dir: string): tuple[kind: TPathComponent, path: string] {.
|
|||
if (f.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) != 0'i32:
|
||||
k = pcDir
|
||||
yield (k, dir / extractFilename(getFilename(f)))
|
||||
if findnextFile(h, f) == 0'i32: break
|
||||
if findNextFile(h, f) == 0'i32: break
|
||||
findClose(h)
|
||||
else:
|
||||
var d = openDir(dir)
|
||||
|
|
@ -1308,7 +1308,7 @@ proc createDir*(dir: string) {.rtl, extern: "nos$1", tags: [FWriteDir].} =
|
|||
when defined(doslike):
|
||||
omitNext = isAbsolute(dir)
|
||||
for i in 1.. dir.len-1:
|
||||
if dir[i] in {Dirsep, Altsep}:
|
||||
if dir[i] in {DirSep, AltSep}:
|
||||
if omitNext:
|
||||
omitNext = false
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ when defined(Windows) and not defined(useNimRtl):
|
|||
|
||||
proc startProcess(command: string,
|
||||
workingDir: string = "",
|
||||
args: openarray[string] = [],
|
||||
args: openArray[string] = [],
|
||||
env: PStringTable = nil,
|
||||
options: set[TProcessOption] = {poStdErrToStdOut}): PProcess =
|
||||
var
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ proc next*(p: var TOptParser) {.
|
|||
of '-':
|
||||
inc(i)
|
||||
if p.cmd[i] == '-':
|
||||
p.kind = cmdLongOption
|
||||
p.kind = cmdLongoption
|
||||
inc(i)
|
||||
i = parseWord(p.cmd, i, p.key.string, {'\0', ' ', '\x09', ':', '='})
|
||||
while p.cmd[i] in {'\x09', ' '}: inc(i)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
when hostos == "solaris":
|
||||
when hostOS == "solaris":
|
||||
{.passl: "-lsocket -lnsl".}
|
||||
|
||||
import os, parseutils
|
||||
|
|
@ -467,7 +467,7 @@ template acceptAddrPlain(noClientRet, successRet: expr,
|
|||
sslImplementation: stmt): stmt {.immediate.} =
|
||||
assert(client != nil)
|
||||
var sockAddress: Tsockaddr_in
|
||||
var addrLen = sizeof(sockAddress).Tsocklen
|
||||
var addrLen = sizeof(sockAddress).TSockLen
|
||||
var sock = accept(server.fd, cast[ptr TSockAddr](addr(sockAddress)),
|
||||
addr(addrLen))
|
||||
|
||||
|
|
@ -1258,10 +1258,10 @@ proc recvLine*(socket: TSocket, line: var TaintedString, timeout = -1): bool {.
|
|||
if n > 0 and c == '\L':
|
||||
discard recv(socket, addr(c), 1)
|
||||
elif n <= 0: return false
|
||||
addNlIfEmpty()
|
||||
addNLIfEmpty()
|
||||
return true
|
||||
elif c == '\L':
|
||||
addNlIfEmpty()
|
||||
addNLIfEmpty()
|
||||
return true
|
||||
add(line.string, c)
|
||||
|
||||
|
|
@ -1299,10 +1299,10 @@ proc readLine*(socket: TSocket, line: var TaintedString, timeout = -1) {.
|
|||
if n > 0 and c == '\L':
|
||||
discard recv(socket, addr(c), 1)
|
||||
elif n <= 0: osError(osLastError())
|
||||
addNlIfEmpty()
|
||||
addNLIfEmpty()
|
||||
return
|
||||
elif c == '\L':
|
||||
addNlIfEmpty()
|
||||
addNLIfEmpty()
|
||||
return
|
||||
add(line.string, c)
|
||||
|
||||
|
|
@ -1457,7 +1457,7 @@ proc recvAsync*(socket: TSocket, s: var TaintedString): bool {.
|
|||
let err = osLastError()
|
||||
when defined(windows):
|
||||
if err.int32 == WSAEWOULDBLOCK:
|
||||
return False
|
||||
return false
|
||||
else: osError(err)
|
||||
else:
|
||||
if err.int32 == EAGAIN or err.int32 == EWOULDBLOCK:
|
||||
|
|
@ -1469,7 +1469,7 @@ proc recvAsync*(socket: TSocket, s: var TaintedString): bool {.
|
|||
# increase capacity:
|
||||
setLen(s.string, s.string.len + bufSize)
|
||||
inc(pos, bytesRead)
|
||||
result = True
|
||||
result = true
|
||||
|
||||
proc recvFrom*(socket: TSocket, data: var string, length: int,
|
||||
address: var string, port: var TPort, flags = 0'i32): int {.
|
||||
|
|
@ -1510,7 +1510,7 @@ proc recvFromAsync*(socket: TSocket, data: var string, length: int,
|
|||
let err = osLastError()
|
||||
when defined(windows):
|
||||
if err.int32 == WSAEWOULDBLOCK:
|
||||
return False
|
||||
return false
|
||||
else: osError(err)
|
||||
else:
|
||||
if err.int32 == EAGAIN or err.int32 == EWOULDBLOCK:
|
||||
|
|
@ -1710,6 +1710,6 @@ proc isBlocking*(socket: TSocket): bool = not socket.nonblocking
|
|||
|
||||
when defined(Windows):
|
||||
var wsa: TWSAData
|
||||
if WSAStartup(0x0101'i16, addr wsa) != 0: osError(osLastError())
|
||||
if wsaStartup(0x0101'i16, addr wsa) != 0: osError(osLastError())
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ iterator split*(s: string, seps: set[char] = Whitespace): string =
|
|||
while last < len(s):
|
||||
while s[last] in seps: inc(last)
|
||||
var first = last
|
||||
while last < len(s) and s[last] not_in seps: inc(last) # BUGFIX!
|
||||
while last < len(s) and s[last] notin seps: inc(last) # BUGFIX!
|
||||
if first <= last-1:
|
||||
yield substr(s, first, last-1)
|
||||
|
||||
|
|
|
|||
|
|
@ -1115,10 +1115,10 @@ proc toLower*(c: TRune): TRune {.rtl, extern: "nuc$1", procvar.} =
|
|||
## Converts `c` into lower case. This works for any Unicode character.
|
||||
## If possible, prefer `toLower` over `toUpper`.
|
||||
var c = IRune(c)
|
||||
var p = binarySearch(c, tolowerRanges, len(toLowerRanges) div 3, 3)
|
||||
var p = binarySearch(c, tolowerRanges, len(tolowerRanges) div 3, 3)
|
||||
if p >= 0 and c >= tolowerRanges[p] and c <= tolowerRanges[p+1]:
|
||||
return TRune(c + tolowerRanges[p+2] - 500)
|
||||
p = binarySearch(c, toLowerSinglets, len(toLowerSinglets) div 2, 2)
|
||||
p = binarySearch(c, tolowerSinglets, len(tolowerSinglets) div 2, 2)
|
||||
if p >= 0 and c == tolowerSinglets[p]:
|
||||
return TRune(c + tolowerSinglets[p+1] - 500)
|
||||
return TRune(c)
|
||||
|
|
@ -1127,10 +1127,10 @@ proc toUpper*(c: TRune): TRune {.rtl, extern: "nuc$1", procvar.} =
|
|||
## Converts `c` into upper case. This works for any Unicode character.
|
||||
## If possible, prefer `toLower` over `toUpper`.
|
||||
var c = IRune(c)
|
||||
var p = binarySearch(c, toUpperRanges, len(toUpperRanges) div 3, 3)
|
||||
var p = binarySearch(c, toupperRanges, len(toupperRanges) div 3, 3)
|
||||
if p >= 0 and c >= toupperRanges[p] and c <= toupperRanges[p+1]:
|
||||
return TRune(c + toupperRanges[p+2] - 500)
|
||||
p = binarySearch(c, toUpperSinglets, len(toUpperSinglets) div 2, 2)
|
||||
p = binarySearch(c, toupperSinglets, len(toupperSinglets) div 2, 2)
|
||||
if p >= 0 and c == toupperSinglets[p]:
|
||||
return TRune(c + toupperSinglets[p+1] - 500)
|
||||
return TRune(c)
|
||||
|
|
@ -1147,10 +1147,10 @@ proc isLower*(c: TRune): bool {.rtl, extern: "nuc$1", procvar.} =
|
|||
## If possible, prefer `isLower` over `isUpper`.
|
||||
var c = IRune(c)
|
||||
# Note: toUpperRanges is correct here!
|
||||
var p = binarySearch(c, toUpperRanges, len(toUpperRanges) div 3, 3)
|
||||
var p = binarySearch(c, toupperRanges, len(toupperRanges) div 3, 3)
|
||||
if p >= 0 and c >= toupperRanges[p] and c <= toupperRanges[p+1]:
|
||||
return true
|
||||
p = binarySearch(c, toUpperSinglets, len(toUpperSinglets) div 2, 2)
|
||||
p = binarySearch(c, toupperSinglets, len(toupperSinglets) div 2, 2)
|
||||
if p >= 0 and c == toupperSinglets[p]:
|
||||
return true
|
||||
|
||||
|
|
@ -1159,10 +1159,10 @@ proc isUpper*(c: TRune): bool {.rtl, extern: "nuc$1", procvar.} =
|
|||
## If possible, prefer `isLower` over `isUpper`.
|
||||
var c = IRune(c)
|
||||
# Note: toLowerRanges is correct here!
|
||||
var p = binarySearch(c, toLowerRanges, len(toLowerRanges) div 3, 3)
|
||||
var p = binarySearch(c, tolowerRanges, len(tolowerRanges) div 3, 3)
|
||||
if p >= 0 and c >= tolowerRanges[p] and c <= tolowerRanges[p+1]:
|
||||
return true
|
||||
p = binarySearch(c, toLowerSinglets, len(toLowerSinglets) div 2, 2)
|
||||
p = binarySearch(c, tolowerSinglets, len(tolowerSinglets) div 2, 2)
|
||||
if p >= 0 and c == tolowerSinglets[p]:
|
||||
return true
|
||||
|
||||
|
|
|
|||
|
|
@ -1145,7 +1145,7 @@ when not defined(nimrodVM):
|
|||
## otherwise. Like any procedure dealing with raw memory this is
|
||||
## *unsafe*.
|
||||
|
||||
when hostOs != "standalone":
|
||||
when hostOS != "standalone":
|
||||
proc alloc*(size: int): pointer {.noconv, rtl, tags: [].}
|
||||
## allocates a new memory block with at least ``size`` bytes. The
|
||||
## block has to be freed with ``realloc(block, 0)`` or
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ proc objectInitAux(dest: pointer, n: ptr TNimNode) =
|
|||
var d = cast[TAddress](dest)
|
||||
case n.kind
|
||||
of nkNone: sysAssert(false, "objectInitAux")
|
||||
of nkSLot: objectInit(cast[pointer](d +% n.offset), n.typ)
|
||||
of nkSlot: objectInit(cast[pointer](d +% n.offset), n.typ)
|
||||
of nkList:
|
||||
for i in 0..n.len-1:
|
||||
objectInitAux(dest, n.sons[i])
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
# Implementation of some runtime checks.
|
||||
|
||||
proc raiseRangeError(val: BiggestInt) {.compilerproc, noreturn, noinline.} =
|
||||
when hostOs == "standalone":
|
||||
when hostOS == "standalone":
|
||||
sysFatal(EOutOfRange, "value out of range")
|
||||
else:
|
||||
sysFatal(EOutOfRange, "value out of range: ", $val)
|
||||
|
|
|
|||
|
|
@ -573,7 +573,7 @@ proc scan(s: PCell) =
|
|||
|
||||
proc collectWhite(s: PCell) =
|
||||
if s.color == rcWhite and s notin gch.cycleRoots:
|
||||
s.setcolor(rcBlack)
|
||||
s.setColor(rcBlack)
|
||||
forAllChildren(s, waCollectWhite)
|
||||
freeCyclicCell(gch, s)
|
||||
|
||||
|
|
@ -891,7 +891,7 @@ proc collectZCT(gch: var TGcHeap): bool =
|
|||
const workPackage = 100
|
||||
var L = addr(gch.zct.len)
|
||||
|
||||
when withRealtime:
|
||||
when withRealTime:
|
||||
var steps = workPackage
|
||||
var t0: TTicks
|
||||
if gch.maxPause > 0: t0 = getticks()
|
||||
|
|
@ -904,7 +904,7 @@ proc collectZCT(gch: var TGcHeap): bool =
|
|||
c.refcount = c.refcount and not ZctFlag
|
||||
gch.zct.d[0] = gch.zct.d[L[] - 1]
|
||||
dec(L[])
|
||||
when withRealtime: dec steps
|
||||
when withRealTime: dec steps
|
||||
if c.refcount <% rcIncrement:
|
||||
# It may have a RC > 0, if it is in the hardware stack or
|
||||
# it has not been removed yet from the ZCT. This is because
|
||||
|
|
@ -927,7 +927,7 @@ proc collectZCT(gch: var TGcHeap): bool =
|
|||
else:
|
||||
sysAssert(c.typ != nil, "collectZCT 2")
|
||||
zeroMem(c, sizeof(TCell))
|
||||
when withRealtime:
|
||||
when withRealTime:
|
||||
if steps == 0:
|
||||
steps = workPackage
|
||||
if gch.maxPause > 0:
|
||||
|
|
@ -952,7 +952,7 @@ proc unmarkStackAndRegisters(gch: var TGcHeap) =
|
|||
gch.decStack.len = 0
|
||||
|
||||
proc collectCTBody(gch: var TGcHeap) =
|
||||
when withRealtime:
|
||||
when withRealTime:
|
||||
let t0 = getticks()
|
||||
sysAssert(allocInv(gch.region), "collectCT: begin")
|
||||
|
||||
|
|
@ -975,7 +975,7 @@ proc collectCTBody(gch: var TGcHeap) =
|
|||
unmarkStackAndRegisters(gch)
|
||||
sysAssert(allocInv(gch.region), "collectCT: end")
|
||||
|
||||
when withRealtime:
|
||||
when withRealTime:
|
||||
let duration = getticks() - t0
|
||||
gch.stat.maxPause = max(gch.stat.maxPause, duration)
|
||||
when defined(reportMissedDeadlines):
|
||||
|
|
@ -997,7 +997,7 @@ proc collectCT(gch: var TGcHeap) =
|
|||
markForDebug(gch)
|
||||
collectCTBody(gch)
|
||||
|
||||
when withRealtime:
|
||||
when withRealTime:
|
||||
proc toNano(x: int): TNanos {.inline.} =
|
||||
result = x * 1000
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ proc write(f: TFile, i: int) =
|
|||
fprintf(f, "%ld", i)
|
||||
|
||||
proc write(f: TFile, i: BiggestInt) =
|
||||
when sizeof(Biggestint) == 8:
|
||||
when sizeof(BiggestInt) == 8:
|
||||
fprintf(f, "%lld", i)
|
||||
else:
|
||||
fprintf(f, "%ld", i)
|
||||
|
|
@ -235,17 +235,17 @@ proc fwrite(buf: pointer, size, n: int, f: TFile): int {.
|
|||
proc readBuffer(f: TFile, buffer: pointer, len: int): int =
|
||||
result = fread(buffer, 1, len, f)
|
||||
|
||||
proc readBytes(f: TFile, a: var openarray[int8], start, len: int): int =
|
||||
proc readBytes(f: TFile, a: var openArray[int8], start, len: int): int =
|
||||
result = readBuffer(f, addr(a[start]), len)
|
||||
|
||||
proc readChars(f: TFile, a: var openarray[char], start, len: int): int =
|
||||
proc readChars(f: TFile, a: var openArray[char], start, len: int): int =
|
||||
result = readBuffer(f, addr(a[start]), len)
|
||||
|
||||
{.push stackTrace:off, profiler:off.}
|
||||
proc writeBytes(f: TFile, a: openarray[int8], start, len: int): int =
|
||||
proc writeBytes(f: TFile, a: openArray[int8], start, len: int): int =
|
||||
var x = cast[ptr array[0..1000_000_000, int8]](a)
|
||||
result = writeBuffer(f, addr(x[start]), len)
|
||||
proc writeChars(f: TFile, a: openarray[char], start, len: int): int =
|
||||
proc writeChars(f: TFile, a: openArray[char], start, len: int): int =
|
||||
var x = cast[ptr array[0..1000_000_000, int8]](a)
|
||||
result = writeBuffer(f, addr(x[start]), len)
|
||||
proc writeBuffer(f: TFile, buffer: pointer, len: int): int =
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ const
|
|||
DETACHED_PROCESS* = 8'i32
|
||||
|
||||
SW_SHOWNORMAL* = 1'i32
|
||||
INVALID_HANDLE_VALUE* = THANDLE(-1)
|
||||
INVALID_HANDLE_VALUE* = THandle(-1)
|
||||
|
||||
CREATE_UNICODE_ENVIRONMENT* = 1024'i32
|
||||
|
||||
|
|
@ -418,7 +418,7 @@ type
|
|||
ai_addr*: ptr TSockAddr ## Socket address of socket.
|
||||
ai_next*: ptr TAddrInfo ## Pointer to next in list.
|
||||
|
||||
Tsocklen* = cuint
|
||||
TSockLen* = cuint
|
||||
|
||||
var
|
||||
SOMAXCONN* {.importc, header: "Winsock2.h".}: cint
|
||||
|
|
@ -457,20 +457,20 @@ proc socket*(af, typ, protocol: cint): TSocketHandle {.
|
|||
proc closesocket*(s: TSocketHandle): cint {.
|
||||
stdcall, importc: "closesocket", dynlib: ws2dll.}
|
||||
|
||||
proc accept*(s: TSocketHandle, a: ptr TSockAddr, addrlen: ptr Tsocklen): TSocketHandle {.
|
||||
proc accept*(s: TSocketHandle, a: ptr TSockAddr, addrlen: ptr TSockLen): TSocketHandle {.
|
||||
stdcall, importc: "accept", dynlib: ws2dll.}
|
||||
proc bindSocket*(s: TSocketHandle, name: ptr TSockAddr, namelen: Tsocklen): cint {.
|
||||
proc bindSocket*(s: TSocketHandle, name: ptr TSockAddr, namelen: TSockLen): cint {.
|
||||
stdcall, importc: "bind", dynlib: ws2dll.}
|
||||
proc connect*(s: TSocketHandle, name: ptr TSockAddr, namelen: Tsocklen): cint {.
|
||||
proc connect*(s: TSocketHandle, name: ptr TSockAddr, namelen: TSockLen): cint {.
|
||||
stdcall, importc: "connect", dynlib: ws2dll.}
|
||||
proc getsockname*(s: TSocketHandle, name: ptr TSockAddr,
|
||||
namelen: ptr Tsocklen): cint {.
|
||||
namelen: ptr TSockLen): cint {.
|
||||
stdcall, importc: "getsockname", dynlib: ws2dll.}
|
||||
proc getsockopt*(s: TSocketHandle, level, optname: cint, optval: pointer,
|
||||
optlen: ptr Tsocklen): cint {.
|
||||
optlen: ptr TSockLen): cint {.
|
||||
stdcall, importc: "getsockopt", dynlib: ws2dll.}
|
||||
proc setsockopt*(s: TSocketHandle, level, optname: cint, optval: pointer,
|
||||
optlen: Tsocklen): cint {.
|
||||
optlen: TSockLen): cint {.
|
||||
stdcall, importc: "setsockopt", dynlib: ws2dll.}
|
||||
|
||||
proc listen*(s: TSocketHandle, backlog: cint): cint {.
|
||||
|
|
@ -478,7 +478,7 @@ proc listen*(s: TSocketHandle, backlog: cint): cint {.
|
|||
proc recv*(s: TSocketHandle, buf: pointer, len, flags: cint): cint {.
|
||||
stdcall, importc: "recv", dynlib: ws2dll.}
|
||||
proc recvfrom*(s: TSocketHandle, buf: cstring, len, flags: cint,
|
||||
fromm: ptr TSockAddr, fromlen: ptr Tsocklen): cint {.
|
||||
fromm: ptr TSockAddr, fromlen: ptr TSockLen): cint {.
|
||||
stdcall, importc: "recvfrom", dynlib: ws2dll.}
|
||||
proc select*(nfds: cint, readfds, writefds, exceptfds: ptr TFdSet,
|
||||
timeout: ptr TTimeval): cint {.
|
||||
|
|
@ -486,15 +486,15 @@ proc select*(nfds: cint, readfds, writefds, exceptfds: ptr TFdSet,
|
|||
proc send*(s: TSocketHandle, buf: pointer, len, flags: cint): cint {.
|
||||
stdcall, importc: "send", dynlib: ws2dll.}
|
||||
proc sendto*(s: TSocketHandle, buf: pointer, len, flags: cint,
|
||||
to: ptr TSockAddr, tolen: Tsocklen): cint {.
|
||||
to: ptr TSockAddr, tolen: TSockLen): cint {.
|
||||
stdcall, importc: "sendto", dynlib: ws2dll.}
|
||||
|
||||
proc shutdown*(s: TSocketHandle, how: cint): cint {.
|
||||
stdcall, importc: "shutdown", dynlib: ws2dll.}
|
||||
|
||||
proc getnameinfo*(a1: ptr TSockAddr, a2: Tsocklen,
|
||||
a3: cstring, a4: Tsocklen, a5: cstring,
|
||||
a6: Tsocklen, a7: cint): cint {.
|
||||
proc getnameinfo*(a1: ptr TSockAddr, a2: TSockLen,
|
||||
a3: cstring, a4: TSockLen, a5: cstring,
|
||||
a6: TSockLen, a7: cint): cint {.
|
||||
stdcall, importc: "getnameinfo", dynlib: ws2dll.}
|
||||
|
||||
proc inet_addr*(cp: cstring): int32 {.
|
||||
|
|
@ -514,7 +514,7 @@ proc FD_SET*(Socket: TSocketHandle, FDSet: var TFdSet) =
|
|||
proc FD_ZERO*(FDSet: var TFdSet) =
|
||||
FDSet.fd_count = 0
|
||||
|
||||
proc WSAStartup*(wVersionRequired: int16, WSData: ptr TWSAData): cint {.
|
||||
proc wsaStartup*(wVersionRequired: int16, WSData: ptr TWSAData): cint {.
|
||||
stdcall, importc: "WSAStartup", dynlib: ws2dll.}
|
||||
|
||||
proc getaddrinfo*(nodename, servname: cstring, hints: ptr TAddrInfo,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue