Change parsing of old versions:

NNNpN -> N.NN.N
  NNN.N -> N.NN.0.N
This is better than mapping NNN.N to N.NN.N, because it follows the
fact that NNN.N were not release versions, so they're mapped to
numbers that are not release versions now.

svn: r11398
This commit is contained in:
Eli Barzilay 2008-08-23 07:06:33 +00:00
parent b5fb8569cc
commit c3985c706c
2 changed files with 16 additions and 8 deletions

View File

@ -20,9 +20,9 @@
'(;; legacy version scheme
["372" 372000000]
["372.0" #f] ; should be just "372"
["372.1" 372001000]
["372.12" 372012000]
["123.4" 123004000]
["372.1" 372000001]
["372.12" 372000012]
["123.4" 123000004]
["49" 49000000] ; oldest legacy-version supported
["103" 103000000]
["103p1" 103001000] ; pN used as sub-sub-version

View File

@ -52,12 +52,20 @@
[(< n 49) ver]
;; old versions (earliest useful is 49, changed at 3.99)
[(<= 49 n 379)
(let-values ([(q r) (quotient/remainder n 100)])
;; put numbers and a possible .N leftover (done for pN too)
(format "~a.~a~a" q r
(regexp-replace #rx"^p" (substring ver (cdar m)) ".")))]
(let*-values
([(q r) (quotient/remainder n 100)]
[(sfx) (substring ver (cdar m))]
[(sfx) (cond [(equal? sfx "") ""]
;; NNNpN -> N.NN.N
[(regexp-match? #rx"^p[0-9]" sfx)
(string-append "." (substring sfx 1))]
;; NNN.N -> N.NN.0.N (not a release version)
[(regexp-match? #rx"^[.]" sfx)
(string-append ".0" sfx)]
[else #f])])
(and sfx (format "~a.~a~a" q r sfx)))]
;; bad strings
[else #f]))
(and (valid-version? v)
(and v (valid-version? v)
(foldl (lambda (ver mul acc) (+ ver (* mul acc))) 0
(version->list v) '(0 100 1000 1000))))