* date-string now uses bytevectors instead of strings during ffi.

This commit is contained in:
Abdulaziz Ghuloum 2007-05-18 20:59:10 -04:00
parent 85944a2cff
commit 498084a6e8
5 changed files with 6 additions and 29 deletions

Binary file not shown.

View File

@ -753,26 +753,6 @@ ikrt_set_code_reloc_vector(ikp code, ikp vec, ikpcb* pcb){
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
ikrt_bvftime(ikp outbv, ikp fmtbv){
time_t t;

Binary file not shown.

View File

@ -4,6 +4,7 @@
(import (except (ikarus) date-string))
(define date-string
(lambda ()
(let ([s (make-string 10)])
(foreign-call "ikrt_strftime" s "%F")
s))))
(let ([s (make-bytevector 10)])
(foreign-call "ikrt_bvftime" s
(string->utf8-bytevector "%F"))
(utf8-bytevector->string s)))))

View File

@ -201,7 +201,7 @@
[(eq? mode 'replace)
($string-set! str n ($fixnum->char #xFFFD))
(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)
(cond
[($fx< ($fx+ i 3) j)
@ -236,7 +236,7 @@
(define (convert bv mode)
(fill ($make-string (count bv mode)) bv mode))
(case-lambda
[(bv) (convert bv 'error)]
[(bv) (convert bv 'raise)]
[(bv handling-mode)
(unless (memq handling-mode '(ignore replace raise))
(error 'utf8-bytevector->string
@ -245,7 +245,3 @@
(convert bv handling-mode)])))
)
#!eof