* use version/utils instead of a private copy of the same code

* removed planet/private/test.ss which was testing that code
* changed angle brackets used in syntax renderings (got lumped in this
  commit by mistake)

svn: r10759
This commit is contained in:
Eli Barzilay 2008-07-14 09:19:29 +00:00
parent e4d9cfb557
commit 91eb4687da
4 changed files with 19 additions and 85 deletions

View File

@ -9,6 +9,7 @@ Various common pieces of code that both the client and server need to access
scheme/path scheme/path
scheme/port scheme/port
scheme/list scheme/list
version/utils
"../config.ss" "../config.ss"
"data.ss") "data.ss")
@ -254,49 +255,11 @@ Various common pieces of code that both the client and server need to access
;; Converts a string into mz-version. We need to account ;; Converts a string into mz-version. We need to account
;; for the change in numbering style from the 372 era to the 4.0 era. ;; for the change in numbering style from the 372 era to the 4.0 era.
(define (string->mz-version str) (define (string->mz-version str)
(define (minor+maint-chunks->minor chunks) (cond [(version->integer str)
(+ (* (string->number (car chunks)) 1000) => (lambda (v)
(if (> (length chunks) 1) (let-values ([(q r) (quotient/remainder v 1000000)])
(string->number (cadr chunks)) (make-mz-version q r)))]
0))) [else #f]))
(cond
;; Old style numbering with three digits in front. The first digit
;; goes up to three.
[(regexp-match #rx"^([0-3][0-9][0-9])\\.?([.0-9]*)$" str)
=>
(lambda (ver)
(let ([major (string->number (list-ref ver 1))])
(cond
[(= (string-length (list-ref ver 2)) 0)
(make-mz-version major 0)]
[else
(let* ([minor+maint (regexp-split #rx"\\." (list-ref ver 2))]
[minor (minor+maint-chunks->minor minor+maint)])
(make-mz-version major minor))])))]
;; New style numbering
[(regexp-match #rx"^([0-9]+)(\\.([.0-9]+))?$" str)
=>
(lambda (ver)
(cond [(list-ref ver 3)
(let* ([chunks (regexp-split #rx"\\." (list-ref ver 3))])
(and (andmap (λ (x) (not (equal? x ""))) chunks)
(make-mz-version (+ (* (string->number (list-ref ver 1))
100)
(if (> (length chunks) 0)
(begin
(string->number (car chunks)))
0))
(if (> (length (cdr chunks)) 0)
(minor+maint-chunks->minor (cdr chunks))
0))))]
[else
(make-mz-version (* (string->number (list-ref ver 1))
100)
0)]))]
[else #f]))
;; version<= : mz-version mz-version -> boolean ;; version<= : mz-version mz-version -> boolean
;; determines if a is the version string of an earlier mzscheme release than b ;; determines if a is the version string of an earlier mzscheme release than b

View File

@ -1,38 +0,0 @@
#lang scheme
(require "planet-shared.ss")
(define-syntax (test stx)
(syntax-case stx ()
[(_ a b)
(with-syntax ([line (syntax-line stx)]
[file (let ([s (syntax-source stx)])
(if (string? s)
s
"<<unknown file>>"))])
#`(test/proc file line a b))]))
(define (test/proc file line got expected)
(unless (equal? got expected)
(error 'test.ss "FAILED ~a: ~s\n got ~s\nexpected ~s" file line got expected)))
(test (string->mz-version "372")
(make-mz-version 372 0))
(test (string->mz-version "372.2")
(make-mz-version 372 2000))
(test (string->mz-version "4.0")
(make-mz-version 400 0))
(test (string->mz-version "4.1")
(make-mz-version 401 0))
(test (string->mz-version "4.0.1")
(make-mz-version 400 1000))
(test (string->mz-version "4..1")
#f)
(printf "tests passed\n")

View File

@ -22,6 +22,8 @@
setup/getinfo setup/getinfo
setup/unpack setup/unpack
version/utils
(prefix-in srfi1: srfi/1) (prefix-in srfi1: srfi/1)
(for-syntax scheme/base)) (for-syntax scheme/base))
@ -664,8 +666,7 @@
;; core-version : string -> boolean ;; core-version : string -> boolean
;; determines if the given string is something that (version) could've produced ;; determines if the given string is something that (version) could've produced
(define (core-version? s) (define (core-version? s)
(and (string? s) (and (version->integer s) #t))
(string->mz-version s)))
;; checkinfo: syntax ;; checkinfo: syntax
;; given an info.ss function, a failure function, and a bunch of fields to check, ;; given an info.ss function, a failure function, and a bunch of fields to check,

View File

@ -1011,8 +1011,16 @@
`(span ([class "mywbr"]) " ")) `(span ([class "mywbr"]) " "))
(render-other (substring i (cdar m)) part ri)) (render-other (substring i (cdar m)) part ri))
(ascii-ize i)))] (ascii-ize i)))]
[(eq? i 'mdash) `(" " ndash " ")] [(symbol? i)
[(symbol? i) (list i)] (case i
[(mdash) '(" " ndash " ")]
;; use "single left/right-pointing angle quotation mark"
;; -- it's not a correct choice, but works best for now
;; (see the "Fonts with proper angle brackets"
;; discussion on the mailing list from June 2008)
[(lang) '(8249)]
[(rang) '(8250)]
[else (list i)])]
[else (list (format "~s" i))])) [else (list (format "~s" i))]))
(define/private (ascii-ize s) (define/private (ascii-ize s)