Replaced deprecated repeatChar() with repeat() or spaces().
This commit is contained in:
parent
8f43979cf6
commit
58186f6c1d
21 changed files with 59 additions and 59 deletions
|
|
@ -816,7 +816,7 @@ proc copy*(p: JsonNode): JsonNode =
|
|||
# ------------- pretty printing ----------------------------------------------
|
||||
|
||||
proc indent(s: var string, i: int) =
|
||||
s.add(repeatChar(i))
|
||||
s.add(spaces(i))
|
||||
|
||||
proc newIndent(curr, indent: int, ml: bool): int =
|
||||
if ml: return curr + indent
|
||||
|
|
|
|||
|
|
@ -165,5 +165,5 @@ proc getCurrentLine(L: BaseLexer, marker: bool = true): string =
|
|||
inc(i)
|
||||
add(result, "\n")
|
||||
if marker:
|
||||
add(result, repeatChar(getColNumber(L, L.bufpos)) & "^\n")
|
||||
add(result, spaces(getColNumber(L, L.bufpos)) & "^\n")
|
||||
|
||||
|
|
|
|||
|
|
@ -628,25 +628,25 @@ proc formatToken(info: TimeInfo, token: string, buf: var string) =
|
|||
var fr = ($info.year).len()-2
|
||||
if fr < 0: fr = 0
|
||||
var fyear = ($info.year)[fr .. ($info.year).len()-1]
|
||||
if fyear.len != 2: fyear = repeatChar(2-fyear.len(), '0') & fyear
|
||||
if fyear.len != 2: fyear = repeat('0', 2-fyear.len()) & fyear
|
||||
buf.add(fyear)
|
||||
of "yyy":
|
||||
var fr = ($info.year).len()-3
|
||||
if fr < 0: fr = 0
|
||||
var fyear = ($info.year)[fr .. ($info.year).len()-1]
|
||||
if fyear.len != 3: fyear = repeatChar(3-fyear.len(), '0') & fyear
|
||||
if fyear.len != 3: fyear = repeat('0', 3-fyear.len()) & fyear
|
||||
buf.add(fyear)
|
||||
of "yyyy":
|
||||
var fr = ($info.year).len()-4
|
||||
if fr < 0: fr = 0
|
||||
var fyear = ($info.year)[fr .. ($info.year).len()-1]
|
||||
if fyear.len != 4: fyear = repeatChar(4-fyear.len(), '0') & fyear
|
||||
if fyear.len != 4: fyear = repeat('0', 4-fyear.len()) & fyear
|
||||
buf.add(fyear)
|
||||
of "yyyyy":
|
||||
var fr = ($info.year).len()-5
|
||||
if fr < 0: fr = 0
|
||||
var fyear = ($info.year)[fr .. ($info.year).len()-1]
|
||||
if fyear.len != 5: fyear = repeatChar(5-fyear.len(), '0') & fyear
|
||||
if fyear.len != 5: fyear = repeat('0', 5-fyear.len()) & fyear
|
||||
buf.add(fyear)
|
||||
of "z":
|
||||
let hrs = (info.timezone div 60) div 60
|
||||
|
|
|
|||
|
|
@ -1083,7 +1083,7 @@ proc addEscaped(s: string): string =
|
|||
else: result.add(c)
|
||||
|
||||
proc nodeToXml(n: PNode, indent: int = 0): string =
|
||||
result = repeatChar(indent, ' ') & "<" & n.nodeName
|
||||
result = spaces(indent) & "<" & n.nodeName
|
||||
if not isNil(n.attributes):
|
||||
for i in items(n.attributes):
|
||||
result.add(" " & i.name & "=\"" & addEscaped(i.value) & "\"")
|
||||
|
|
@ -1098,23 +1098,23 @@ proc nodeToXml(n: PNode, indent: int = 0): string =
|
|||
of ElementNode:
|
||||
result.add(nodeToXml(i, indent + 2))
|
||||
of TextNode:
|
||||
result.add(repeatChar(indent * 2, ' '))
|
||||
result.add(spaces(indent * 2))
|
||||
result.add(addEscaped(i.nodeValue))
|
||||
of CDataSectionNode:
|
||||
result.add(repeatChar(indent * 2, ' '))
|
||||
result.add(spaces(indent * 2))
|
||||
result.add("<![CDATA[" & i.nodeValue & "]]>")
|
||||
of ProcessingInstructionNode:
|
||||
result.add(repeatChar(indent * 2, ' '))
|
||||
result.add(spaces(indent * 2))
|
||||
result.add("<?" & PProcessingInstruction(i).target & " " &
|
||||
PProcessingInstruction(i).data & " ?>")
|
||||
of CommentNode:
|
||||
result.add(repeatChar(indent * 2, ' '))
|
||||
result.add(spaces(indent * 2))
|
||||
result.add("<!-- " & i.nodeValue & " -->")
|
||||
else:
|
||||
continue
|
||||
result.add("\n")
|
||||
# Add the ending tag - </tag>
|
||||
result.add(repeatChar(indent, ' ') & "</" & n.nodeName & ">")
|
||||
result.add(spaces(indent) & "</" & n.nodeName & ">")
|
||||
|
||||
proc `$`*(doc: PDocument): string =
|
||||
## Converts a PDocument object into a string representation of it's XML
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue