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