diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/raco/setup.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/raco/setup.scrbl index 61748e6213..877d48ccee 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/raco/setup.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/raco/setup.scrbl @@ -11,6 +11,7 @@ setup/dirs setup/getinfo setup/main-collects + setup/collection-name setup/path-to-relative setup/xref scribble/xref ;; info -- no bindings from this are used @@ -1406,6 +1407,32 @@ compatibility.} function). } +@; ------------------------------------------------------------------------ + +@section[#:tag "collection-names"]{API for Collection Names} + +@defmodule[setup/collection-name] + +@defproc[(collection-name? [v any/c]) boolean?]{ + +Returns @racket[#t] if @racket[v] is a string that is syntactically +valid as a collection name, which means that it is one or more +@litchar{/}-separated strings for which +@racket[collection-name-element?] returns true.} + + +@defproc[(collection-name-element? [v any/c]) boolean?]{ + +Returns @racket[#t] if @racket[v] is a string that is syntactically +valid as a top-level collection name or as a part of a collection +name, which means that it is non-empty and contains only ASCII +letters, ASCII digits, @litchar{-}, @litchar{+}, @litchar{_}, and +@litchar{%}, where a @litchar{%} is allowed only when followed by two +lowercase hexadecimal digits, and the digits must form a number that +is not the ASCII value of a letter, digit, @litchar{-}, @litchar{+}, +or @litchar{_}.} + + @; ------------------------------------------------------------------------ @section[#:tag "xref"]{API for Cross-References for Installed Manuals} diff --git a/pkgs/racket-pkgs/racket-test/tests/racket/collection-name.rkt b/pkgs/racket-pkgs/racket-test/tests/racket/collection-name.rkt new file mode 100644 index 0000000000..f9d9c5a412 --- /dev/null +++ b/pkgs/racket-pkgs/racket-test/tests/racket/collection-name.rkt @@ -0,0 +1,17 @@ +#lang racket/base +(require rackunit + setup/collection-name) + +(check-equal? #t (collection-name-element? "racket")) +(check-equal? #t (collection-name-element? "racket%21")) +(check-equal? #f (collection-name-element? "racket.rkt")) +(check-equal? #f (collection-name-element? "racket!")) +(check-equal? #f (collection-name-element? "rac/ket")) + +(check-equal? #t (collection-name? "racket")) +(check-equal? #t (collection-name? "rac/ket")) +(check-equal? #t (collection-name? "racket/%21")) +(check-equal? #f (collection-name? "racket.rkt")) +(check-equal? #f (collection-name? "racket!")) +(check-equal? #f (collection-name? "racket/")) +(check-equal? #f (collection-name? "/racket")) diff --git a/racket/collects/pkg/lib.rkt b/racket/collects/pkg/lib.rkt index ae0521245e..822dba8273 100644 --- a/racket/collects/pkg/lib.rkt +++ b/racket/collects/pkg/lib.rkt @@ -10,6 +10,7 @@ setup/pack setup/unpack setup/dirs + setup/collection-name racket/port racket/list racket/function @@ -1604,16 +1605,17 @@ (if (not i) pkg-name (let ([s (i 'collection (lambda () 'use-pkg-name))]) - (unless (or (string? s) + (unless (or (collection-name-element? s) (eq? s 'multi) (eq? s 'use-pkg-name)) - (log-error (format (~a "bad `collection' definition in \"info.rkt\n" + (log-error (format (~a "bad `collection' definition in \"info.rkt\";\n" + " definition will be ignored\n" " path: ~a\n" " found: ~e\n" - " expected: (or/c string? 'multi 'use-pkg-name)") + " expected: (or/c collection-name-element? 'multi 'use-pkg-name)") (build-path dir "info.rkt") s))) - (or (and (string? s) + (or (and (collection-name-element? s) s) (and (eq? s 'use-pkg-name) pkg-name))))) diff --git a/racket/collects/racket/HISTORY.txt b/racket/collects/racket/HISTORY.txt index 952edc2c67..316bd17e33 100644 --- a/racket/collects/racket/HISTORY.txt +++ b/racket/collects/racket/HISTORY.txt @@ -1,6 +1,7 @@ Version 5.90.0.9 Allow hash table chaperones and impersonators to Support efficient hash-clear and hash-clear! +setup/collection-name: added Version 5.90.0.6 Added path