From 3b0c11e22b0ae7a9b8db25a64f4ca3d4079f3c16 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sun, 10 Jun 2012 13:50:15 -0500 Subject: [PATCH] shrink the dependencies from racket/runtime-path (remove mzscheme and pull out the one things from mzlib/etc that it uses into a separate, private file) original commit: b0607f04a90713d88e314d0a534ac28440bc77b7 --- collects/mzlib/etc.rkt | 45 +-------------------------------- collects/mzlib/runtime-path.rkt | 6 ++--- 2 files changed, 4 insertions(+), 47 deletions(-) diff --git a/collects/mzlib/etc.rkt b/collects/mzlib/etc.rkt index 37c04f6..aedc709 100644 --- a/collects/mzlib/etc.rkt +++ b/collects/mzlib/etc.rkt @@ -10,6 +10,7 @@ build-list build-vector compose) + "private/this-expression-source-directory.rkt" (rename racket/base base-else else)) (require-for-syntax syntax/name @@ -240,50 +241,6 @@ (not (eq? (namespace-variable-value n #t (lambda () ns-undefined)) ns-undefined))) -(define (extract-module-directory stx) - (let ([srcmod (let ([mpi (syntax-source-module stx)]) - (if (module-path-index? mpi) - (module-path-index-resolve mpi) - mpi))]) - (let* ([name (resolved-module-path-name srcmod)] - [name (if (pair? name) (car name) name)]) - (and (path? name) - (let-values ([(base name dir?) (split-path name)]) - (and (path? base) - base)))))) - -(define-syntax (this-expression-source-directory stx) - (syntax-case stx () - [(_ sub) - (let ([stx (syntax sub)]) - (let ([source-path - (let* ([source (syntax-source stx)] - [source (and (path? source) source)] - [local (or (current-load-relative-directory) (current-directory))] - [dir (path->main-collects-relative - (or (and source (file-exists? source) - (let-values ([(base file dir?) - (split-path source)]) - (and (path? base) - (path->complete-path base local)))) - local))]) - (if (and (pair? dir) (eq? 'collects (car dir))) - (with-syntax ([d dir]) - (syntax/loc stx (main-collects-relative->path 'd))) - (with-syntax ([d (if (bytes? dir) dir (path->bytes dir))]) - (syntax/loc stx (bytes->path d)))))]) - (let ([mpi (syntax-source-module stx)]) - (if mpi - (quasisyntax/loc stx - (or (extract-module-directory (quote-syntax #,(datum->syntax-object - stx - 'context - stx - stx))) - #,source-path)) - source-path))))] - [(_) #`(this-expression-source-directory #,stx)])) - (define-syntax (this-expression-file-name stx) (syntax-case stx () [(_ sub) diff --git a/collects/mzlib/runtime-path.rkt b/collects/mzlib/runtime-path.rkt index 92bf101..735b46c 100644 --- a/collects/mzlib/runtime-path.rkt +++ b/collects/mzlib/runtime-path.rkt @@ -1,7 +1,7 @@ (module runtime-path racket/base - (require mzlib/etc - setup/dirs + (require "private/this-expression-source-directory.rkt" racket/list + setup/dirs (only-in "private/runtime-path-table.rkt" table) (for-syntax racket/base)) @@ -72,7 +72,7 @@ ((length p) . > . 1) (eq? 'lib (car p)) (andmap string? (cdr p))) - (let* ([strs (regexp-split #rx"/" + (let* ([strs (regexp-split #rx"/" (let ([s (cadr p)]) (if (regexp-match? #rx"[./]" s) s