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: [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? Cheers, Peter signature.asc Description: PGP signature
[PATCH] slight improvement in option quoting for csc
See #1302. felix From aca0348f06de8e61a93cf4203543d2465118d07e 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 | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/csc.scm b/csc.scm index 921c7841..be02a8b4 100644 --- a/csc.scm +++ b/csc.scm @@ -1057,6 +1057,7 @@ EOF ;;; Helper procedures: (define-constant +hairy-chars+ '(#\\ #\#)) +(define-constant +icky-chars+ '(#\( #\))) (define (cleanup s) (let* ((q #f) @@ -1067,7 +1068,9 @@ EOF (let ([c (car s)]) (cond ((memq c +hairy-chars+) (cons* #\\ c (fold (cdr s (else - (when (char-whitespace? c) (set! q #t)) + (when (or (char-whitespace? c) + (memq c +icky-chars+)) + (set! q #t)) (cons c (fold (cdr s))) ) ) ) ) ) ) ) ) (if q (string-append "\"" (string-translate* s '(("\"" . "\\\""))) "\"") @@ -1086,7 +1089,9 @@ EOF (define (quote-option x) (cond ((string-any (cut char=? #\" <>) x) x) ((string-any (lambda (c) - (or (char-whitespace? c) (memq c +hairy-chars+)) ) + (or (char-whitespace? c) + (memq c +icky-chars+) + (memq c +hairy-chars+)) ) x) (cleanup x)) (else x) )) -- 2.28.0