Re: [PATCH] slight improvement in option quoting for csc
On Sun, Oct 23, 2022 at 12:36:20PM +0200, felix.winkelm...@bevuta.com wrote: > > On Fri, Oct 21, 2022 at 04:36:58PM +0200, felix.winkelm...@bevuta.com wrote: > > > See #1302. > > > > Why do we even attempt to detect whether to quote? That looks a bit > > brittle to me. It should be simpler to just always quote (e.g. using "qs"), > > like we do in other places, for example in chicken-install, or is there > > some reason we can't do that here? > > > > Ok, that is of course a much simpler approach, please find attached a new > patch. Thanks, pushed! Cheers, Peter signature.asc Description: PGP signature
Re: [PATCH] slight improvement in option quoting for csc
> On Fri, Oct 21, 2022 at 04:36:58PM +0200, felix.winkelm...@bevuta.com wrote: > > See #1302. > > Why do we even attempt to detect whether to quote? That looks a bit > brittle to me. It should be simpler to just always quote (e.g. using "qs"), > like we do in other places, for example in chicken-install, or is there > some reason we can't do that here? > Ok, that is of course a much simpler approach, please find attached a new patch. felix From 0f868e28a2705ecdfee4e48998f20426e4c2e344 Mon Sep 17 00:00:00 2001 From: felix Date: Fri, 21 Oct 2022 16:36:07 +0200 Subject: [PATCH] try to improve automated quoting/escaping in csc See also #1302 Signed-off-by: felix --- csc.scm | 25 + 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/csc.scm b/csc.scm index 921c7841..11e17941 100644 --- a/csc.scm +++ b/csc.scm @@ -1056,23 +1056,6 @@ EOF ;;; Helper procedures: -(define-constant +hairy-chars+ '(#\\ #\#)) - -(define (cleanup s) - (let* ((q #f) -(s (list->string -(let fold ([s (string->list s)]) - (if (null? s) - '() - (let ([c (car s)]) -(cond ((memq c +hairy-chars+) (cons* #\\ c (fold (cdr s - (else - (when (char-whitespace? c) (set! q #t)) - (cons c (fold (cdr s))) ) ) ) ) ) ) ) ) -(if q - (string-append "\"" (string-translate* s '(("\"" . "\\\""))) "\"") - s) ) ) - ;; Simpler replacement for SRFI-13's string-any (define (string-any criteria s) (let ((end (string-length s))) @@ -1083,13 +1066,7 @@ EOF (or (criteria c) (lp i1))) -(define (quote-option x) - (cond ((string-any (cut char=? #\" <>) x) x) - ((string-any (lambda (c) - (or (char-whitespace? c) (memq c +hairy-chars+)) ) -x) -(cleanup x)) - (else x) )) +(define quote-option qs) (define last-exit-code #f) -- 2.28.0
Re: absolute pathname a.k.a. realpath
On 2022-08-18 10:23, Sandra Snan wrote: > Would you please add something like this to the pathname module? > > (define (absolute-pathname name) > (normalize-pathname >(if (absolute-pathname? name) name >(make-absolute-pathname (current-directory) name > > Whatever you wanna call it, I'm not married to the name. FWIW this appears in almost all the programs I write, too, so I'd also like to see it added. I think rather than adding something new to core, the ideal would be for the existing `make-absolute-pathname` procedure to do this when the first argument is #f. That one is kind of squatting on the optimal name and seems like the right place for this. But, that's backwards-incompatible, so isn't really possible in the 5.x release series. Maybe `make-absolute-pathname` could accept one, two or three arguments. When there's one, it's `file`, we get this behaviour you want. When two or more, it's `dirs` and `file` and the behaviour stays the same. Curious to know what others think. Evan