From: Chris Hanson Date: Sat, 4 Nov 2017 04:11:36 +0000 (-0700) Subject: Simplify previous fix to string-trimmer. X-Git-Tag: mit-scheme-pucked-9.2.12~14^2~8 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=700f99039a2cc441b9690f8c5259af2496e0b034;p=mit-scheme.git Simplify previous fix to string-trimmer. --- diff --git a/src/runtime/ustring.scm b/src/runtime/ustring.scm index dd7394479..3df63120c 100644 --- a/src/runtime/ustring.scm +++ b/src/runtime/ustring.scm @@ -1963,22 +1963,24 @@ USA. (get-trimmed (if copy? substring string-slice))) (lambda (string) (let* ((end (string-length string)) - (start (if (eq? where 'trailing) - 0 - (let loop ((index 0)) - (if (and (fix:< index end) - (predicate (string-ref string index))) - (loop (fix:+ index 1)) - index)))) - (end (if (eq? where 'leading) - end - (let loop ((index end)) - (if (and (fix:> index 0) - (predicate - (string-ref string (fix:- index 1)))) - (loop (fix:- index 1)) - index))))) - (get-trimmed string (min start end) end)))))) + (start + (if (eq? where 'trailing) + 0 + (let loop ((index 0)) + (if (and (fix:< index end) + (predicate (string-ref string index))) + (loop (fix:+ index 1)) + index))))) + (get-trimmed string + start + (if (eq? where 'leading) + end + (let loop ((index end)) + (if (and (fix:> index start) + (predicate + (string-ref string (fix:- index 1)))) + (loop (fix:- index 1)) + index))))))))) (define-deferred string-trimmer-options (keyword-option-parser