case consistency part 5

This commit is contained in:
Araq 2013-12-28 00:37:45 +01:00
commit 9c3751a37c
10 changed files with 42 additions and 42 deletions

View file

@ -568,7 +568,7 @@ proc suggestWriteln*(s: string) =
writeln(stdout, s) writeln(stdout, s)
stdoutSocket.send(s & "\c\L") stdoutSocket.send(s & "\c\L")
else: else:
Writeln(stdout, s) writeln(stdout, s)
if eInMemory in errorOutputs: if eInMemory in errorOutputs:
bufferedMsgs.safeAdd(s) bufferedMsgs.safeAdd(s)

View file

@ -110,16 +110,16 @@ proc findStartNimrod: string =
# If these fail, we try to build nimrod with the "build.(sh|bat)" script. # If these fail, we try to build nimrod with the "build.(sh|bat)" script.
var nimrod = "nimrod".exe var nimrod = "nimrod".exe
result = "bin" / nimrod result = "bin" / nimrod
if ExistsFile(result): return if existsFile(result): return
for dir in split(getEnv("PATH"), PathSep): for dir in split(getEnv("PATH"), PathSep):
if ExistsFile(dir / nimrod): return nimrod if existsFile(dir / nimrod): return nimrod
when defined(Posix): when defined(Posix):
const buildScript = "build.sh" const buildScript = "build.sh"
if ExistsFile(buildScript): if ExistsFile(buildScript):
if tryExec("./" & buildScript): return "bin" / nimrod if tryExec("./" & buildScript): return "bin" / nimrod
else: else:
const buildScript = "build.bat" const buildScript = "build.bat"
if ExistsFile(buildScript): if existsFile(buildScript):
if tryExec(buildScript): return "bin" / nimrod if tryExec(buildScript): return "bin" / nimrod
echo("Found no nimrod compiler and every attempt to build one failed!") echo("Found no nimrod compiler and every attempt to build one failed!")
@ -188,14 +188,14 @@ proc removePattern(pattern: string) =
removeFile(f) removeFile(f)
proc clean(args: string) = proc clean(args: string) =
if ExistsFile("koch.dat"): removeFile("koch.dat") if existsFile("koch.dat"): removeFile("koch.dat")
removePattern("web/*.html") removePattern("web/*.html")
removePattern("doc/*.html") removePattern("doc/*.html")
cleanAux(getCurrentDir()) cleanAux(getCurrentDir())
for kind, path in walkDir(getCurrentDir() / "build"): for kind, path in walkDir(getCurrentDir() / "build"):
if kind == pcDir: if kind == pcDir:
echo "removing dir: ", path echo "removing dir: ", path
RemoveDir(path) removeDir(path)
# -------------- update ------------------------------------------------------- # -------------- update -------------------------------------------------------

View file

@ -113,7 +113,7 @@ proc handleHexChar(c: var TCfgParser, xi: var int) =
xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('A') + 10) xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('A') + 10)
inc(c.bufpos) inc(c.bufpos)
else: else:
nil discard
proc handleDecChars(c: var TCfgParser, xi: var int) = proc handleDecChars(c: var TCfgParser, xi: var int) =
while c.buf[c.bufpos] in {'0'..'9'}: while c.buf[c.bufpos] in {'0'..'9'}:
@ -125,54 +125,54 @@ proc getEscapedChar(c: var TCfgParser, tok: var TToken) =
case c.buf[c.bufpos] case c.buf[c.bufpos]
of 'n', 'N': of 'n', 'N':
add(tok.literal, "\n") add(tok.literal, "\n")
Inc(c.bufpos) inc(c.bufpos)
of 'r', 'R', 'c', 'C': of 'r', 'R', 'c', 'C':
add(tok.literal, '\c') add(tok.literal, '\c')
Inc(c.bufpos) inc(c.bufpos)
of 'l', 'L': of 'l', 'L':
add(tok.literal, '\L') add(tok.literal, '\L')
Inc(c.bufpos) inc(c.bufpos)
of 'f', 'F': of 'f', 'F':
add(tok.literal, '\f') add(tok.literal, '\f')
inc(c.bufpos) inc(c.bufpos)
of 'e', 'E': of 'e', 'E':
add(tok.literal, '\e') add(tok.literal, '\e')
Inc(c.bufpos) inc(c.bufpos)
of 'a', 'A': of 'a', 'A':
add(tok.literal, '\a') add(tok.literal, '\a')
Inc(c.bufpos) inc(c.bufpos)
of 'b', 'B': of 'b', 'B':
add(tok.literal, '\b') add(tok.literal, '\b')
Inc(c.bufpos) inc(c.bufpos)
of 'v', 'V': of 'v', 'V':
add(tok.literal, '\v') add(tok.literal, '\v')
Inc(c.bufpos) inc(c.bufpos)
of 't', 'T': of 't', 'T':
add(tok.literal, '\t') add(tok.literal, '\t')
Inc(c.bufpos) inc(c.bufpos)
of '\'', '"': of '\'', '"':
add(tok.literal, c.buf[c.bufpos]) add(tok.literal, c.buf[c.bufpos])
Inc(c.bufpos) inc(c.bufpos)
of '\\': of '\\':
add(tok.literal, '\\') add(tok.literal, '\\')
Inc(c.bufpos) inc(c.bufpos)
of 'x', 'X': of 'x', 'X':
inc(c.bufpos) inc(c.bufpos)
var xi = 0 var xi = 0
handleHexChar(c, xi) handleHexChar(c, xi)
handleHexChar(c, xi) handleHexChar(c, xi)
add(tok.literal, Chr(xi)) add(tok.literal, chr(xi))
of '0'..'9': of '0'..'9':
var xi = 0 var xi = 0
handleDecChars(c, xi) handleDecChars(c, xi)
if (xi <= 255): add(tok.literal, Chr(xi)) if (xi <= 255): add(tok.literal, chr(xi))
else: tok.kind = tkInvalid else: tok.kind = tkInvalid
else: tok.kind = tkInvalid else: tok.kind = tkInvalid
proc HandleCRLF(c: var TCfgParser, pos: int): int = proc handleCRLF(c: var TCfgParser, pos: int): int =
case c.buf[pos] case c.buf[pos]
of '\c': result = lexbase.HandleCR(c, pos) of '\c': result = lexbase.handleCR(c, pos)
of '\L': result = lexbase.HandleLF(c, pos) of '\L': result = lexbase.handleLF(c, pos)
else: result = pos else: result = pos
proc getString(c: var TCfgParser, tok: var TToken, rawMode: bool) = proc getString(c: var TCfgParser, tok: var TToken, rawMode: bool) =
@ -183,16 +183,16 @@ proc getString(c: var TCfgParser, tok: var TToken, rawMode: bool) =
# long string literal: # long string literal:
inc(pos, 2) # skip "" inc(pos, 2) # skip ""
# skip leading newline: # skip leading newline:
pos = HandleCRLF(c, pos) pos = handleCRLF(c, pos)
buf = c.buf buf = c.buf
while true: while true:
case buf[pos] case buf[pos]
of '"': of '"':
if (buf[pos + 1] == '"') and (buf[pos + 2] == '"'): break if (buf[pos + 1] == '"') and (buf[pos + 2] == '"'): break
add(tok.literal, '"') add(tok.literal, '"')
Inc(pos) inc(pos)
of '\c', '\L': of '\c', '\L':
pos = HandleCRLF(c, pos) pos = handleCRLF(c, pos)
buf = c.buf buf = c.buf
add(tok.literal, "\n") add(tok.literal, "\n")
of lexbase.EndOfFile: of lexbase.EndOfFile:
@ -200,7 +200,7 @@ proc getString(c: var TCfgParser, tok: var TToken, rawMode: bool) =
break break
else: else:
add(tok.literal, buf[pos]) add(tok.literal, buf[pos])
Inc(pos) inc(pos)
c.bufpos = pos + 3 # skip the three """ c.bufpos = pos + 3 # skip the three """
else: else:
# ordinary string literal # ordinary string literal
@ -218,7 +218,7 @@ proc getString(c: var TCfgParser, tok: var TToken, rawMode: bool) =
pos = c.bufPos pos = c.bufPos
else: else:
add(tok.literal, ch) add(tok.literal, ch)
Inc(pos) inc(pos)
c.bufpos = pos c.bufpos = pos
proc getSymbol(c: var TCfgParser, tok: var TToken) = proc getSymbol(c: var TCfgParser, tok: var TToken) =
@ -226,7 +226,7 @@ proc getSymbol(c: var TCfgParser, tok: var TToken) =
var buf = c.buf var buf = c.buf
while true: while true:
add(tok.literal, buf[pos]) add(tok.literal, buf[pos])
Inc(pos) inc(pos)
if not (buf[pos] in SymChars): break if not (buf[pos] in SymChars): break
c.bufpos = pos c.bufpos = pos
tok.kind = tkSymbol tok.kind = tkSymbol
@ -237,11 +237,11 @@ proc skip(c: var TCfgParser) =
while true: while true:
case buf[pos] case buf[pos]
of ' ', '\t': of ' ', '\t':
Inc(pos) inc(pos)
of '#', ';': of '#', ';':
while not (buf[pos] in {'\c', '\L', lexbase.EndOfFile}): inc(pos) while not (buf[pos] in {'\c', '\L', lexbase.EndOfFile}): inc(pos)
of '\c', '\L': of '\c', '\L':
pos = HandleCRLF(c, pos) pos = handleCRLF(c, pos)
buf = c.buf buf = c.buf
else: else:
break # EndOfFile also leaves the loop break # EndOfFile also leaves the loop
@ -249,7 +249,7 @@ proc skip(c: var TCfgParser) =
proc rawGetTok(c: var TCfgParser, tok: var TToken) = proc rawGetTok(c: var TCfgParser, tok: var TToken) =
tok.kind = tkInvalid tok.kind = tkInvalid
setlen(tok.literal, 0) setLen(tok.literal, 0)
skip(c) skip(c)
case c.buf[c.bufpos] case c.buf[c.bufpos]
of '=': of '=':
@ -267,7 +267,7 @@ proc rawGetTok(c: var TCfgParser, tok: var TToken) =
tok.literal = ":" tok.literal = ":"
of 'r', 'R': of 'r', 'R':
if c.buf[c.bufPos + 1] == '\"': if c.buf[c.bufPos + 1] == '\"':
Inc(c.bufPos) inc(c.bufPos)
getString(c, tok, true) getString(c, tok, true)
else: else:
getSymbol(c, tok) getSymbol(c, tok)
@ -277,7 +277,7 @@ proc rawGetTok(c: var TCfgParser, tok: var TToken) =
tok.literal = "]" tok.literal = "]"
of ']': of ']':
tok.kind = tkBracketRi tok.kind = tkBracketRi
Inc(c.bufpos) inc(c.bufpos)
tok.literal = "]" tok.literal = "]"
of '"': of '"':
getString(c, tok, false) getString(c, tok, false)

View file

@ -1,5 +1,5 @@
#! stdtmpl(subsChar='?') | standard #! stdtmpl(subsChar='?') | standard
#proc GenerateBuildBatchScript(c: TConfigData, winIndex, cpuIndex: int): string = #proc generateBuildBatchScript(c: TConfigData, winIndex, cpuIndex: int): string =
# result = "@echo off\nREM Generated by niminst\n" # result = "@echo off\nREM Generated by niminst\n"
SET CC=gcc SET CC=gcc
SET LINKER=gcc SET LINKER=gcc

View file

@ -1,5 +1,5 @@
#! stdtmpl(subsChar='?') | standard #! stdtmpl(subsChar='?') | standard
#proc GenerateBuildShellScript(c: TConfigData): string = #proc generateBuildShellScript(c: TConfigData): string =
# result = "#! /bin/sh\n# Generated from niminst\n" & # result = "#! /bin/sh\n# Generated from niminst\n" &
# "# Template is in tools/buildsh.tmpl\n" & # "# Template is in tools/buildsh.tmpl\n" &
# "# To regenerate run ``niminst csource`` or ``koch csource``\n" # "# To regenerate run ``niminst csource`` or ``koch csource``\n"

View file

@ -101,7 +101,7 @@ proc createChangelog(pkgName, version, maintainer: string): string =
addN(" * Initial release.") addN(" * Initial release.")
addN("") addN("")
addN(" -- " & maintainer & " " & addN(" -- " & maintainer & " " &
formatDateTime(getGmTime(getTime()), "+0000")) formatDateTime(getGMTime(getTime()), "+0000"))
proc createRules(): string = proc createRules(): string =
## Creates a nimrod application-agnostic rules file for building deb packages. ## Creates a nimrod application-agnostic rules file for building deb packages.

View file

@ -1,5 +1,5 @@
#! stdtmpl(subsChar='?') | standard #! stdtmpl(subsChar='?') | standard
#proc GenerateDeinstallScript(c: TConfigData): string = #proc generateDeinstallScript(c: TConfigData): string =
# result = "#! /bin/sh\n# Generated by niminst\n" # result = "#! /bin/sh\n# Generated by niminst\n"
# var proj = c.name.toLower # var proj = c.name.toLower

View file

@ -1,5 +1,5 @@
#! stdtmpl | standard #! stdtmpl | standard
#proc GenerateInnoSetup(c: TConfigData): string = #proc generateInnoSetup(c: TConfigData): string =
# result = "" # result = ""
; Default Template for NimInst ; Default Template for NimInst
[Setup] [Setup]

View file

@ -1,5 +1,5 @@
#! stdtmpl(subsChar = '?') | standard #! stdtmpl(subsChar = '?') | standard
#proc GenerateInstallScript(c: TConfigData): string = #proc generateInstallScript(c: TConfigData): string =
# result = "#! /bin/sh\n# Generated by niminst\n" # result = "#! /bin/sh\n# Generated by niminst\n"
# var proj = c.name.toLower # var proj = c.name.toLower

View file

@ -188,7 +188,7 @@ proc parseCmdLine(c: var TConfigData) =
proc walkDirRecursively(s: var seq[string], root: string) = proc walkDirRecursively(s: var seq[string], root: string) =
for k, f in walkDir(root): for k, f in walkDir(root):
case k case k
of pcFile, pcLinkToFile: add(s, UnixToNativePath(f)) of pcFile, pcLinkToFile: add(s, unixToNativePath(f))
of pcDir: walkDirRecursively(s, f) of pcDir: walkDirRecursively(s, f)
of pcLinkToDir: nil of pcLinkToDir: nil
@ -199,7 +199,7 @@ proc addFiles(s: var seq[string], patterns: seq[string]) =
else: else:
var i = 0 var i = 0
for f in walkFiles(p): for f in walkFiles(p):
add(s, UnixToNativePath(f)) add(s, unixToNativePath(f))
inc(i) inc(i)
if i == 0: echo("[Warning] No file found that matches: " & p) if i == 0: echo("[Warning] No file found that matches: " & p)
@ -286,7 +286,7 @@ proc parseIniFile(c: var TConfigData) =
of "console": c.app = appConsole of "console": c.app = appConsole
of "gui": c.app = appGUI of "gui": c.app = appGUI
else: quit(errorStr(p, "expected: console or gui")) else: quit(errorStr(p, "expected: console or gui"))
of "license": c.license = UnixToNativePath(k.value) of "license": c.license = unixToNativePath(k.value)
else: quit(errorStr(p, "unknown variable: " & k.key)) else: quit(errorStr(p, "unknown variable: " & k.key))
of "var": nil of "var": nil
of "winbin": filesOnly(p, k.key, v, c.cat[fcWinBin]) of "winbin": filesOnly(p, k.key, v, c.cat[fcWinBin])