mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 13:30:33 +00:00
more niminst fixes
This commit is contained in:
@@ -48,7 +48,6 @@ Start: "doc/overview.html"
|
||||
[Other]
|
||||
Files: "readme.txt;install.txt;contributors.txt;copying.txt"
|
||||
Files: "makefile"
|
||||
Files: "*.ini"
|
||||
Files: "koch.nim"
|
||||
|
||||
Files: "icons/nim.ico"
|
||||
@@ -66,7 +65,6 @@ Files: "tools"
|
||||
Files: "web/website.ini"
|
||||
Files: "web/ticker.html"
|
||||
Files: "web/*.nim"
|
||||
Files: "web/*.txt"
|
||||
Files: "web/*.rst"
|
||||
Files: "web/*.csv"
|
||||
Files: "web/news/*.rst"
|
||||
|
||||
@@ -202,14 +202,34 @@ proc parseCmdLine(c: var ConfigData) =
|
||||
if c.infile.len == 0: quit(Usage)
|
||||
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 html = if not allowHtml: ".html" else: ""
|
||||
let explicit = splitPath(root).tail
|
||||
result = (ext in ["", ".exe", ".idx"] or
|
||||
ext == html or name[0] == '.') and name & ext != explicit
|
||||
result = (ext in ["", ".exe", ".idx", ".o", ".obj", ".dylib"] or
|
||||
ext == html or name[0] == '.') and not eqT(f, explicit, tPath)
|
||||
|
||||
proc walkDirRecursively(s: var seq[string], root: string,
|
||||
proc walkDirRecursively(s: var seq[string], root, explicit: string,
|
||||
allowHtml: bool) =
|
||||
let tail = splitPath(root).tail
|
||||
if tail == "nimcache" or tail[0] == '.':
|
||||
@@ -221,22 +241,22 @@ proc walkDirRecursively(s: var seq[string], root: string,
|
||||
else:
|
||||
case k
|
||||
of pcFile, pcLinkToFile:
|
||||
if not ignoreFile(f, root, allowHtml):
|
||||
if not ignoreFile(f, explicit, allowHtml):
|
||||
add(s, unixToNativePath(f))
|
||||
of pcDir:
|
||||
walkDirRecursively(s, f, allowHtml)
|
||||
walkDirRecursively(s, f, explicit, allowHtml)
|
||||
of pcLinkToDir: discard
|
||||
|
||||
proc addFiles(s: var seq[string], patterns: seq[string]) =
|
||||
for p in items(patterns):
|
||||
if existsDir(p):
|
||||
walkDirRecursively(s, p, false)
|
||||
walkDirRecursively(s, p, p, false)
|
||||
else:
|
||||
var i = 0
|
||||
for f in walkFiles(p):
|
||||
if existsDir(f):
|
||||
walkDirRecursively(s, f, false)
|
||||
elif not ignoreFile(f, p, false):
|
||||
walkDirRecursively(s, f, p, false)
|
||||
elif not ignoreFile(f, f, false):
|
||||
add(s, unixToNativePath(f))
|
||||
inc(i)
|
||||
if i == 0: echo("[Warning] No file found that matches: " & p)
|
||||
|
||||
Reference in New Issue
Block a user