diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2017-09-13 13:41:17 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2017-09-13 13:41:17 -0300 |
| commit | 26eba4bcfdb3de662c16f359f66e4240fc9283d4 (patch) | |
| tree | 248f44e2d29037da9cdd1739476687449de49695 | |
| parent | f1473f71235bb89555dea7041b536144d32bac8c (diff) | |
| download | luarocks-26eba4bcfdb3de662c16f359f66e4240fc9283d4.tar.gz luarocks-26eba4bcfdb3de662c16f359f66e4240fc9283d4.tar.bz2 luarocks-26eba4bcfdb3de662c16f359f66e4240fc9283d4.zip | |
Fix version cache
| -rw-r--r-- | src/luarocks/core/vers.lua | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/luarocks/core/vers.lua b/src/luarocks/core/vers.lua index 2a765b9b..6b6e822e 100644 --- a/src/luarocks/core/vers.lua +++ b/src/luarocks/core/vers.lua | |||
| @@ -91,30 +91,30 @@ function vers.parse_version(vstring) | |||
| 91 | end | 91 | end |
| 92 | 92 | ||
| 93 | -- trim leading and trailing spaces | 93 | -- trim leading and trailing spaces |
| 94 | vstring = vstring:match("^%s*(.*)%s*$") | 94 | local v = vstring:match("^%s*(.*)%s*$") |
| 95 | version.string = vstring | 95 | version.string = v |
| 96 | -- store revision separately if any | 96 | -- store revision separately if any |
| 97 | local main, revision = vstring:match("(.*)%-(%d+)$") | 97 | local main, revision = v:match("(.*)%-(%d+)$") |
| 98 | if revision then | 98 | if revision then |
| 99 | vstring = main | 99 | v = main |
| 100 | version.revision = tonumber(revision) | 100 | version.revision = tonumber(revision) |
| 101 | end | 101 | end |
| 102 | while #vstring > 0 do | 102 | while #v > 0 do |
| 103 | -- extract a number | 103 | -- extract a number |
| 104 | local token, rest = vstring:match("^(%d+)[%.%-%_]*(.*)") | 104 | local token, rest = v:match("^(%d+)[%.%-%_]*(.*)") |
| 105 | if token then | 105 | if token then |
| 106 | add_token(tonumber(token)) | 106 | add_token(tonumber(token)) |
| 107 | else | 107 | else |
| 108 | -- extract a word | 108 | -- extract a word |
| 109 | token, rest = vstring:match("^(%a+)[%.%-%_]*(.*)") | 109 | token, rest = v:match("^(%a+)[%.%-%_]*(.*)") |
| 110 | if not token then | 110 | if not token then |
| 111 | util.printerr("Warning: version number '"..vstring.."' could not be parsed.") | 111 | util.printerr("Warning: version number '"..v.."' could not be parsed.") |
| 112 | version[i] = 0 | 112 | version[i] = 0 |
| 113 | break | 113 | break |
| 114 | end | 114 | end |
| 115 | version[i] = deltas[token] or (token:byte() / 1000) | 115 | version[i] = deltas[token] or (token:byte() / 1000) |
| 116 | end | 116 | end |
| 117 | vstring = rest | 117 | v = rest |
| 118 | end | 118 | end |
| 119 | setmetatable(version, version_mt) | 119 | setmetatable(version, version_mt) |
| 120 | version_cache[vstring] = version | 120 | version_cache[vstring] = version |
