* date-string now uses bytevectors instead of strings during ffi.
This commit is contained in:
parent
85944a2cff
commit
498084a6e8
BIN
bin/ikarus
BIN
bin/ikarus
Binary file not shown.
|
@ -753,26 +753,6 @@ ikrt_set_code_reloc_vector(ikp code, ikp vec, ikpcb* pcb){
|
||||||
return void_object;
|
return void_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
ikp
|
|
||||||
ikrt_strftime(ikp outstr, ikp fmtstr){
|
|
||||||
time_t t;
|
|
||||||
struct tm* tmp;
|
|
||||||
t = time(NULL);
|
|
||||||
tmp = localtime(&t);
|
|
||||||
if(tmp == NULL){
|
|
||||||
fprintf(stderr, "Error in time: %s\n", strerror(errno));
|
|
||||||
}
|
|
||||||
int rv =
|
|
||||||
strftime((char*)outstr+off_string_data,
|
|
||||||
unfix(ref(outstr, off_string_length)) + 1,
|
|
||||||
(char*)fmtstr+off_string_data,
|
|
||||||
tmp);
|
|
||||||
if(rv == 0){
|
|
||||||
fprintf(stderr, "Error in strftime: %s\n", strerror(errno));
|
|
||||||
}
|
|
||||||
return fix(rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
ikp
|
ikp
|
||||||
ikrt_bvftime(ikp outbv, ikp fmtbv){
|
ikrt_bvftime(ikp outbv, ikp fmtbv){
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
BIN
src/ikarus.boot
BIN
src/ikarus.boot
Binary file not shown.
|
@ -4,6 +4,7 @@
|
||||||
(import (except (ikarus) date-string))
|
(import (except (ikarus) date-string))
|
||||||
(define date-string
|
(define date-string
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let ([s (make-string 10)])
|
(let ([s (make-bytevector 10)])
|
||||||
(foreign-call "ikrt_strftime" s "%F")
|
(foreign-call "ikrt_bvftime" s
|
||||||
s))))
|
(string->utf8-bytevector "%F"))
|
||||||
|
(utf8-bytevector->string s)))))
|
||||||
|
|
|
@ -201,7 +201,7 @@
|
||||||
[(eq? mode 'replace)
|
[(eq? mode 'replace)
|
||||||
($string-set! str n ($fixnum->char #xFFFD))
|
($string-set! str n ($fixnum->char #xFFFD))
|
||||||
(f str x ($fxadd1 i) j ($fxadd1 n) mode)]
|
(f str x ($fxadd1 i) j ($fxadd1 n) mode)]
|
||||||
[else (error who "BUG: incomplete char sequence")])]
|
[else (error who "BUG")])]
|
||||||
[($fx= ($fxsra b0 3) #b11110)
|
[($fx= ($fxsra b0 3) #b11110)
|
||||||
(cond
|
(cond
|
||||||
[($fx< ($fx+ i 3) j)
|
[($fx< ($fx+ i 3) j)
|
||||||
|
@ -236,7 +236,7 @@
|
||||||
(define (convert bv mode)
|
(define (convert bv mode)
|
||||||
(fill ($make-string (count bv mode)) bv mode))
|
(fill ($make-string (count bv mode)) bv mode))
|
||||||
(case-lambda
|
(case-lambda
|
||||||
[(bv) (convert bv 'error)]
|
[(bv) (convert bv 'raise)]
|
||||||
[(bv handling-mode)
|
[(bv handling-mode)
|
||||||
(unless (memq handling-mode '(ignore replace raise))
|
(unless (memq handling-mode '(ignore replace raise))
|
||||||
(error 'utf8-bytevector->string
|
(error 'utf8-bytevector->string
|
||||||
|
@ -245,7 +245,3 @@
|
||||||
(convert bv handling-mode)])))
|
(convert bv handling-mode)])))
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
#!eof
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue