diff --git a/foreign/c.sld b/foreign/c.sld index 4b2ff57..0dbe8b4 100644 --- a/foreign/c.sld +++ b/foreign/c.sld @@ -12,7 +12,7 @@ (foreign c chicken-primitives))) ;(cyclone (import (foreign c cyclone-primitives))) ;(gambit (import (foreign c gambit-primitives))) - (gauche (import (foreign c gauche-primitives))) + ;(gauche (import (foreign c gauche-primitives))) (guile (import (foreign c guile-primitives))) ;(kawa (import (foreign c kawa-primitives))) ;(mit-scheme (import (foreign c mit-scheme-primitives))) diff --git a/foreign/c/stklos-primitives.scm b/foreign/c/stklos-primitives.scm index a64b762..2e7f97f 100644 --- a/foreign/c/stklos-primitives.scm +++ b/foreign/c/stklos-primitives.scm @@ -1,3 +1,20 @@ +(define foreign-c:string-split + (lambda (str mark) + (let* ((str-l (string->list str)) + (res (list)) + (last-index 0) + (index 0) + (splitter (lambda (c) + (cond ((char=? c mark) + (begin + (set! res (append res (list (string-copy str last-index index)))) + (set! last-index (+ index 1)))) + ((equal? (length str-l) (+ index 1)) + (set! res (append res (list (string-copy str last-index (+ index 1))))))) + (set! index (+ index 1))))) + (for-each splitter str-l) + res))) + (define type->native-type (lambda (type) (cond ((equal? type 'int8) :char)