Fix #110 : use '^' rather than '-' for list negative indexes
This commit is contained in:
parent
491b63cb5f
commit
87d6f908cc
5 changed files with 8 additions and 8 deletions
|
|
@ -171,7 +171,7 @@ proc parseCmdLine(): Options =
|
|||
# Parse pkg@verRange
|
||||
if '@' in key:
|
||||
let i = find(key, '@')
|
||||
let pkgTup = (key[0 .. i-1], key[i+1 .. -1].parseVersionRange())
|
||||
let pkgTup = (key[0 .. i-1], key[i+1 .. ^1].parseVersionRange())
|
||||
result.action.packages.add(pkgTup)
|
||||
else:
|
||||
result.action.packages.add((key, VersionRange(kind: verAny)))
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ proc getTagsListRemote*(url: string, meth: DownloadMethod): seq[string] =
|
|||
for i in output.splitLines():
|
||||
if i == "": continue
|
||||
let start = i.find("refs/tags/")+"refs/tags/".len
|
||||
let tag = i[start .. -1]
|
||||
let tag = i[start .. ^1]
|
||||
if not tag.endswith("^{}"): result.add(tag)
|
||||
|
||||
of DownloadMethod.hg:
|
||||
|
|
@ -118,7 +118,7 @@ proc getVersionList*(tags: seq[string]): Table[Version, string] =
|
|||
if tag != "":
|
||||
let i = skipUntil(tag, Digits) # skip any chars before the version
|
||||
# TODO: Better checking, tags can have any names. Add warnings and such.
|
||||
result[newVersion(tag[i .. -1])] = tag
|
||||
result[newVersion(tag[i .. ^1])] = tag
|
||||
|
||||
proc getDownloadMethod*(meth: string): DownloadMethod =
|
||||
case meth
|
||||
|
|
|
|||
|
|
@ -88,11 +88,11 @@ proc parseRequires(req: string): PkgTuple =
|
|||
if ' ' in req:
|
||||
var i = skipUntil(req, Whitespace)
|
||||
result.name = req[0 .. i].strip
|
||||
result.ver = parseVersionRange(req[i .. -1])
|
||||
result.ver = parseVersionRange(req[i .. ^1])
|
||||
elif '#' in req:
|
||||
var i = skipUntil(req, {'#'})
|
||||
result.name = req[0 .. i-1]
|
||||
result.ver = parseVersionRange(req[i .. -1])
|
||||
result.ver = parseVersionRange(req[i .. ^1])
|
||||
else:
|
||||
result.name = req.strip
|
||||
result.ver = VersionRange(kind: verAny)
|
||||
|
|
@ -339,7 +339,7 @@ proc getNameVersion*(pkgpath: string): tuple[name, version: string] =
|
|||
for i in countdown(tail.len-1, 0):
|
||||
if tail[i] == '-':
|
||||
result.name = tail[0 .. i-1]
|
||||
result.version = tail[i+1 .. -1]
|
||||
result.version = tail[i+1 .. ^1]
|
||||
break
|
||||
|
||||
proc echoPackage*(pkg: Package) =
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ proc changeRoot*(origRoot, newRoot, path: string): string =
|
|||
## path: /home/dom/bar/blah/2/foo.txt
|
||||
## Return value -> /home/test/bar/blah/2/foo.txt
|
||||
if path.startsWith(origRoot):
|
||||
return newRoot / path[origRoot.len .. -1]
|
||||
return newRoot / path[origRoot.len .. ^1]
|
||||
else:
|
||||
raise newException(ValueError,
|
||||
"Cannot change root of path: Path does not begin with original root.")
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ proc parseVersionRange*(s: string): VersionRange =
|
|||
new(result)
|
||||
if s[0] == '#':
|
||||
result.kind = verSpecial
|
||||
result.spe = s[1 .. -1].Special
|
||||
result.spe = s[1 .. ^1].Special
|
||||
return
|
||||
|
||||
var i = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue