Applied patch that fixes bug: dirent->d_namlen not available on

linux.  Thanks Derick Eddington.
This commit is contained in:
Abdulaziz Ghuloum 2009-04-09 23:55:44 +03:00
parent d63a9c1f51
commit a44a00b405
3 changed files with 8 additions and 4 deletions

View File

@ -2610,7 +2610,10 @@
(let ([rv (foreign-call "ikrt_readdir" (let ([rv (foreign-call "ikrt_readdir"
(directory-stream-pointer x))]) (directory-stream-pointer x))])
(cond (cond
[(eqv? rv 0) #f] [(fixnum? rv)
(close-directory-stream x #f)
(io-error who (directory-stream-filename x) rv)]
[(not rv) #f]
[else (utf8->string rv)]))) [else (utf8->string rv)])))
(define close-directory-stream (define close-directory-stream

View File

@ -1 +1 @@
1762 1763

View File

@ -391,11 +391,12 @@ ikrt_opendir(ikptr dirname, ikpcb* pcb){
ikptr ikptr
ikrt_readdir(ikptr ptr, ikpcb* pcb){ ikrt_readdir(ikptr ptr, ikpcb* pcb){
DIR* d = (DIR*) ref(ptr, off_pointer_data); DIR* d = (DIR*) ref(ptr, off_pointer_data);
errno = 0;
struct dirent* ent = readdir(d); struct dirent* ent = readdir(d);
if (ent == NULL){ if (ent == NULL){
return 0; return (errno ? ik_errno_to_code() : false_object);
} }
int len = ent->d_namlen; int len = strlen(ent->d_name);
ikptr bv = ik_safe_alloc(pcb, align(disp_bytevector_data+len+1)) ikptr bv = ik_safe_alloc(pcb, align(disp_bytevector_data+len+1))
+ bytevector_tag; + bytevector_tag;
ref(bv, -bytevector_tag) = fix(len); ref(bv, -bytevector_tag) = fix(len);