~ chicken-core (chicken-5) ca1a42ae7b26aa9968ad336d11a508e62c6663fb
commit ca1a42ae7b26aa9968ad336d11a508e62c6663fb Author: felix <felix@call-with-current-continuation.org> AuthorDate: Fri Oct 21 11:24:56 2022 +0200 Commit: Peter Bex <peter@more-magic.net> CommitDate: Fri Oct 21 15:00:39 2022 +0200 Allow list-notation in -R option Fixes #1809 Signed-off-by: felix <felix@call-with-current-continuation.org> Signed-off-by: Peter Bex <peter@more-magic.net> diff --git a/NEWS b/NEWS index f71d75df..980ec9b0 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,9 @@ - Added "fp*+" (fused multiply-add) to "chicken.flonum" module (suggested by Christian Himpe). +- Tools + - The -R option for csi and csc now accepts list-notation like + e.g. (srfi 1). Fixes #1809, reported by Wolfgang Corcoran-Mathe. - Build system - Default "cc" on BSD systems for building CHICKEN to avoid ABI problems diff --git a/batch-driver.scm b/batch-driver.scm index bf10dd3f..dfed3aaa 100644 --- a/batch-driver.scm +++ b/batch-driver.scm @@ -47,7 +47,9 @@ chicken.pretty-print chicken.process-context chicken.string + chicken.port chicken.time + chicken.condition chicken.compiler.support chicken.compiler.compiler-syntax chicken.compiler.core @@ -282,6 +284,25 @@ (newline)) xs) ) ) + (define (string-trim str) + (let loop ((front 0) + (back (sub1 (string-length str)))) + (cond ((= front back) "") + ((char-whitespace? (string-ref str front)) + (loop (add1 front) back)) + ((char-whitespace? (string-ref str back)) + (loop front (sub1 back))) + (else (substring str front (add1 back)))))) + + (define (string->extension-name str) + (let ((str (string-trim str))) + (if (and (positive? (string-length str)) + (char=? #\( (string-ref str 0))) + (handle-exceptions ex + (##sys#error "invalid import specification" str) + (with-input-from-string str read)) + (string->symbol str)))) + (define (arg-val str) (let* ((len (string-length str)) (len1 (- len 1)) ) @@ -497,7 +518,7 @@ (set! import-forms (append import-forms - (map (lambda (r) `(import ,(string->symbol r))) + (map (lambda (r) `(import ,(string->extension-name r))) (collect-options 'require-extension)))) (when (memq 'compile-syntax options) diff --git a/csi.scm b/csi.scm index 9613319e..18498194 100644 --- a/csi.scm +++ b/csi.scm @@ -973,6 +973,24 @@ EOF (define-constant complex-options '("-D" "-feature" "-I" "-include-path" "-K" "-keyword-style" "-no-feature") ) +(define (string-trim str) + (let loop ((front 0) + (back (sub1 (string-length str)))) + (cond ((= front back) "") + ((char-whitespace? (string-ref str front)) + (loop (add1 front) back)) + ((char-whitespace? (string-ref str back)) + (loop front (sub1 back))) + (else (substring str front (add1 back)))))) + +(define (string->extension-name str) + (let ((str (string-trim str))) + (if (and (positive? (string-length str)) + (char=? #\( (string-ref str 0))) + (handle-exceptions ex + (##sys#error "invalid import specification" str) + (with-input-from-string str read)) + (string->symbol str)))) (define (run) (let* ([extraopts (parse-option-string (or (get-environment-variable "CSI_OPTIONS") ""))] @@ -1101,7 +1119,7 @@ EOF ((member arg complex-options) (set! args (cdr args)) ) ((or (string=? "-R" arg) (string=? "-require-extension" arg)) - (eval `(import ,(string->symbol (cadr args)))) + (eval `(import ,(string->extension-name (cadr args)))) (set! args (cdr args)) ) ((or (string=? "-e" arg) (string=? "-eval" arg)) (evalstring (cadr args)) diff --git a/manual/Acknowledgements b/manual/Acknowledgements index 73de8708..4a756150 100644 --- a/manual/Acknowledgements +++ b/manual/Acknowledgements @@ -11,9 +11,9 @@ Christopher Brannon, Terence Brannon, Roy Bryant, Adam Buchbinder, Hans Bulfone, "Category 5", Taylor Campbell, Naruto Canada, Mark Carter, Esteban U. Caamano Castro, Semih Cemiloglu, Alex Charlton, Franklin Chen, Joo ChurlSoo, Thomas Chust, Gian Paolo Ciceri, Fulvio Ciriaco, Paul Colby, Tobia -Conforto, John Cowan, Grzegorz Chrupala, James Crippen, John Croisant, Evan Hanson, -Adhi Hargo, Moritz Heidkamp, Tollef Fog Heen, Drew Hess, Alejandro -Forero Cuervo, Peter Danenberg, Linh Dang, Brian Denheyer, Sean +Conforto, Wolfgang Corcoran-Mathe, John Cowan, Grzegorz Chrupala, James Crippen, +John Croisant, Evan Hanson, Adhi Hargo, Moritz Heidkamp, Tollef Fog Heen, Drew Hess, +Alejandro Forero Cuervo, Peter Danenberg, Linh Dang, Brian Denheyer, Sean D'Epagnier, "dgym", "Don", Chris Double, "Brown Dragon", David Dreisigmeyer, Jarod Eells, Petter Egesund, Stephen Eilert, Steve Elkins, Daniel B. Faken, Erik Falor, Will Farr, Graham Fawcett, Marc diff --git a/manual/Using the compiler b/manual/Using the compiler index 9060bbaa..51cd9ffc 100644 --- a/manual/Using the compiler +++ b/manual/Using the compiler @@ -176,7 +176,7 @@ the source text should be read from standard input. ; -raw : Disables the generation of any implicit code that uses the Scheme libraries (that is all runtime system files besides {{runtime.c}} and {{chicken.h}}). Use this only when you know what you are doing. -; -require-extension NAME : Loads the extension {{NAME}} before the compilation process commences. This is identical to adding {{(require-extension NAME)}} at the start of the compiled program. If {{-uses NAME}} is also given on the command line, then any occurrences of {{-require-extension NAME}} are replaced with {{(declare (uses NAME))}}. Multiple names may be given and should be separated by commas. +; -require-extension NAME : Loads the extension {{NAME}} before the compilation process commences. This is identical to adding {{(import NAME)}} at the start of the compiled program. If {{-uses NAME}} is also given on the command line, then any occurrences of {{-require-extension NAME}} are replaced with {{(declare (uses NAME))}}. {{NAME}} may be given in list notation, e.g {{"(srfi 1)"}}. ; -setup-mode : When locating extension, search the current directory first. By default, extensions are located first in the ''extension repository'', where {{chicken-install}} stores compiled extensions and their associated metadata. diff --git a/manual/Using the interpreter b/manual/Using the interpreter index a74e6dec..8ae57d43 100644 --- a/manual/Using the interpreter +++ b/manual/Using the interpreter @@ -276,7 +276,7 @@ The options recognized by the interpreter are: ; -setup-mode : When locating extensions, search the current directory first. By default, extensions are located first in the ''extension repository'', where {{chicken-install}} stores compiled extensions and their associated metadata. -; -R -require-extension NAME : Equivalent to evaluating {{(require-extension NAME)}}. +; -R -require-extension NAME : Equivalent to evaluating {{(import NAME)}}. {{NAME}} may be given in list notation, e.g. {{"(srfi 1)"}}. ; -v -version : Write the banner with version information to standard output and exit. diff --git a/rules.make b/rules.make index ec714550..cbcf391e 100644 --- a/rules.make +++ b/rules.make @@ -537,6 +537,8 @@ batch-driver.c: batch-driver.scm mini-srfi-1.scm \ chicken.platform.import.scm \ chicken.pretty-print.import.scm \ chicken.process-context.import.scm \ + chicken.condition.import.scm \ + chicken.port.import.scm \ chicken.string.import.scm \ chicken.time.import.scm c-platform.c: c-platform.scm mini-srfi-1.scm \Trap