Skip to content

Commit

Permalink
make VersionInfo(::String) a valid constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebolewski committed Aug 12, 2014
1 parent 71f6d99 commit f7d0ebf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base/pkg/reqs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ immutable Requirement <: Line
package = shift!(fields)
all(field->ismatch(Base.VERSION_REGEX, field), fields) ||
error("invalid requires entry for $package: $content")
versions = [ convert(VersionNumber, field) for field in fields ]
versions = [VersionNumber(field) for field in fields]
issorted(versions) || error("invalid requires entry for $package: $content")
new(content, package, VersionSet(versions), system)
end
Expand Down
6 changes: 4 additions & 2 deletions base/version.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function split_idents(s::String)
end
end

function convert(::Type{VersionNumber}, v::String)
VersionNumber(v::String) = begin
m = match(VERSION_REGEX, v)
if m == nothing error("invalid version string: $v") end
major, minor, patch, minus, prerl, plus, build = m.captures
Expand All @@ -94,7 +94,9 @@ function convert(::Type{VersionNumber}, v::String)
VersionNumber(major, minor, patch, prerl, build)
end

macro v_str(v); convert(VersionNumber, v); end
convert(::Type{VersionNumber}, v::String) = VersionNumber(v)

macro v_str(v); VersionNumber(v); end

typemin(::Type{VersionNumber}) = v"0-"
typemax(::Type{VersionNumber}) = VersionNumber(typemax(Int),typemax(Int),typemax(Int),(),("",))
Expand Down

0 comments on commit f7d0ebf

Please sign in to comment.