From a0dfe647cda9c8e96375366e0e07f2cbc0678aac Mon Sep 17 00:00:00 2001 From: Brian Caine Date: Tue, 8 Aug 2017 01:11:24 -0400 Subject: [PATCH] Just went with the existing string-split --- tools/chibi-ffi | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/tools/chibi-ffi b/tools/chibi-ffi index b04b0628..e11706ed 100755 --- a/tools/chibi-ffi +++ b/tools/chibi-ffi @@ -319,13 +319,17 @@ (else (lp from (+ i 1) res)))))) (define (string-split str c . o) - (let ((start (if (pair? o) (car o) 0)) + (let ((test? + (if (procedure? c) + c + (lambda (char) (eqv? char c)))) + (start (if (pair? o) (car o) 0)) (end (string-length str))) (let lp ((from start) (i start) (res '())) (define (collect) (if (= i from) res (cons (substring str from i) res))) (cond ((>= i end) (reverse (collect))) - ((eqv? c (string-ref str i)) (lp (+ i 1) (+ i 1) (collect))) + ((test? (string-ref str i)) (lp (+ i 1) (+ i 1) (collect))) (else (lp from (+ i 1) res)))))) (define (string-scan c str . o) @@ -416,21 +420,14 @@ (set! *clibs* (cons lib *clibs*))) (define (c-flags-from-script cmd) - (eval '(import (chibi process) - ; lest I clobber the existing string-split: - (prefix (chibi string) imported:) - (chibi char-set full)) ; for char-set:whitespace - (current-environment)) - (let ((string-null? (eval 'imported:string-null? (current-environment))) - (string-split (eval 'imported:string-split (current-environment))) - (process->string (eval 'process->string (current-environment))) - (char-set:whitespace - (eval 'char-set:whitespace (current-environment)))) + (eval '(import (chibi process)) (current-environment)) + (let ((string-null? (lambda (str) (equal? str ""))) + (process->string (eval 'process->string (current-environment)))) (set! *cflags* (append *cflags* (filter (lambda (x) (not (string-null? x))) - (string-split (process->string cmd) char-set:whitespace)))))) + (string-split (process->string cmd) char-whitespace?)))))) (define (c-declare . args) (apply cat args)