more niminst fixes
This commit is contained in:
parent
112cde69c8
commit
7e8c9eda45
2 changed files with 30 additions and 12 deletions
|
|
@ -48,7 +48,6 @@ Start: "doc/overview.html"
|
||||||
[Other]
|
[Other]
|
||||||
Files: "readme.txt;install.txt;contributors.txt;copying.txt"
|
Files: "readme.txt;install.txt;contributors.txt;copying.txt"
|
||||||
Files: "makefile"
|
Files: "makefile"
|
||||||
Files: "*.ini"
|
|
||||||
Files: "koch.nim"
|
Files: "koch.nim"
|
||||||
|
|
||||||
Files: "icons/nim.ico"
|
Files: "icons/nim.ico"
|
||||||
|
|
@ -66,7 +65,6 @@ Files: "tools"
|
||||||
Files: "web/website.ini"
|
Files: "web/website.ini"
|
||||||
Files: "web/ticker.html"
|
Files: "web/ticker.html"
|
||||||
Files: "web/*.nim"
|
Files: "web/*.nim"
|
||||||
Files: "web/*.txt"
|
|
||||||
Files: "web/*.rst"
|
Files: "web/*.rst"
|
||||||
Files: "web/*.csv"
|
Files: "web/*.csv"
|
||||||
Files: "web/news/*.rst"
|
Files: "web/news/*.rst"
|
||||||
|
|
|
||||||
|
|
@ -202,14 +202,34 @@ proc parseCmdLine(c: var ConfigData) =
|
||||||
if c.infile.len == 0: quit(Usage)
|
if c.infile.len == 0: quit(Usage)
|
||||||
if c.mainfile.len == 0: c.mainfile = changeFileExt(c.infile, "nim")
|
if c.mainfile.len == 0: c.mainfile = changeFileExt(c.infile, "nim")
|
||||||
|
|
||||||
proc ignoreFile(f, root: string, allowHtml: bool): bool =
|
proc eqT(a, b: string; t: proc (a: char): char{.nimcall.}): bool =
|
||||||
|
## equality under a transformation ``t``. candidate for the stdlib?
|
||||||
|
var i = 0
|
||||||
|
var j = 0
|
||||||
|
while i < a.len and j < b.len:
|
||||||
|
let aa = t a[i]
|
||||||
|
let bb = t b[j]
|
||||||
|
if aa == '\0':
|
||||||
|
inc i
|
||||||
|
if bb == '\0': inc j
|
||||||
|
elif bb == '\0': inc j
|
||||||
|
else:
|
||||||
|
if aa != bb: return false
|
||||||
|
inc i
|
||||||
|
inc j
|
||||||
|
result = i >= a.len and j >= b.len
|
||||||
|
|
||||||
|
proc tPath(c: char): char =
|
||||||
|
if c == '\\': '/'
|
||||||
|
else: c
|
||||||
|
|
||||||
|
proc ignoreFile(f, explicit: string, allowHtml: bool): bool =
|
||||||
let (_, name, ext) = splitFile(f)
|
let (_, name, ext) = splitFile(f)
|
||||||
let html = if not allowHtml: ".html" else: ""
|
let html = if not allowHtml: ".html" else: ""
|
||||||
let explicit = splitPath(root).tail
|
result = (ext in ["", ".exe", ".idx", ".o", ".obj", ".dylib"] or
|
||||||
result = (ext in ["", ".exe", ".idx"] or
|
ext == html or name[0] == '.') and not eqT(f, explicit, tPath)
|
||||||
ext == html or name[0] == '.') and name & ext != explicit
|
|
||||||
|
|
||||||
proc walkDirRecursively(s: var seq[string], root: string,
|
proc walkDirRecursively(s: var seq[string], root, explicit: string,
|
||||||
allowHtml: bool) =
|
allowHtml: bool) =
|
||||||
let tail = splitPath(root).tail
|
let tail = splitPath(root).tail
|
||||||
if tail == "nimcache" or tail[0] == '.':
|
if tail == "nimcache" or tail[0] == '.':
|
||||||
|
|
@ -221,22 +241,22 @@ proc walkDirRecursively(s: var seq[string], root: string,
|
||||||
else:
|
else:
|
||||||
case k
|
case k
|
||||||
of pcFile, pcLinkToFile:
|
of pcFile, pcLinkToFile:
|
||||||
if not ignoreFile(f, root, allowHtml):
|
if not ignoreFile(f, explicit, allowHtml):
|
||||||
add(s, unixToNativePath(f))
|
add(s, unixToNativePath(f))
|
||||||
of pcDir:
|
of pcDir:
|
||||||
walkDirRecursively(s, f, allowHtml)
|
walkDirRecursively(s, f, explicit, allowHtml)
|
||||||
of pcLinkToDir: discard
|
of pcLinkToDir: discard
|
||||||
|
|
||||||
proc addFiles(s: var seq[string], patterns: seq[string]) =
|
proc addFiles(s: var seq[string], patterns: seq[string]) =
|
||||||
for p in items(patterns):
|
for p in items(patterns):
|
||||||
if existsDir(p):
|
if existsDir(p):
|
||||||
walkDirRecursively(s, p, false)
|
walkDirRecursively(s, p, p, false)
|
||||||
else:
|
else:
|
||||||
var i = 0
|
var i = 0
|
||||||
for f in walkFiles(p):
|
for f in walkFiles(p):
|
||||||
if existsDir(f):
|
if existsDir(f):
|
||||||
walkDirRecursively(s, f, false)
|
walkDirRecursively(s, f, p, false)
|
||||||
elif not ignoreFile(f, p, false):
|
elif not ignoreFile(f, f, false):
|
||||||
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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue