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