Simplify pointer->delimited-string-list
This commit is contained in:
parent
c6a70d3c39
commit
fbf8ffce43
11
xattr.scm
11
xattr.scm
|
@ -16,7 +16,7 @@
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(module xattr
|
(module xattr
|
||||||
(get-xattr set-xattr remove-xattr list-xattr split-list)
|
(get-xattr set-xattr remove-xattr list-xattr)
|
||||||
|
|
||||||
(import (chicken base) (chicken memory) srfi-1 scheme (chicken foreign) srfi-12)
|
(import (chicken base) (chicken memory) srfi-1 scheme (chicken foreign) srfi-12)
|
||||||
|
|
||||||
|
@ -159,13 +159,12 @@
|
||||||
;; one-dimensional array with given length and strings separated by a given delimeter.
|
;; one-dimensional array with given length and strings separated by a given delimeter.
|
||||||
;; This takes that sort of pointer and gives you a nice list of strings.
|
;; This takes that sort of pointer and gives you a nice list of strings.
|
||||||
(define (pointer->delimited-string-list pointer length delimiter)
|
(define (pointer->delimited-string-list pointer length delimiter)
|
||||||
(let ([is-zero (lambda (num) (eq? num 0))]
|
(let* ([is-zero (lambda (num) (eq? num 0))]
|
||||||
[map-to-char (lambda (a) (map integer->char a))])
|
[map-to-char (lambda (a) (map integer->char a))]
|
||||||
|
[byte-list (drop-right (pointer->integers pointer length) 1)])
|
||||||
(map list->string
|
(map list->string
|
||||||
(map map-to-char
|
(map map-to-char
|
||||||
(split-list is-zero
|
(split-list is-zero byte-list)))))
|
||||||
(drop-right
|
|
||||||
(pointer->integers pointer length) 1))))))
|
|
||||||
|
|
||||||
|
|
||||||
;; Takes a pointer and returns a list of bytes of a given length
|
;; Takes a pointer and returns a list of bytes of a given length
|
||||||
|
|
Ŝarĝante…
Reference in New Issue