Fixed environ. The procedure environ takes no arguments and returns

an association list where both keys and values and strings found in
the posix environment.
This commit is contained in:
Abdulaziz Ghuloum
2009-04-06 09:59:07 +03:00
parent 7b60ec46a9
commit b97cbf1688
4 changed files with 25 additions and 21 deletions
+9 -6
View File
@@ -972,21 +972,24 @@ ikrt_unsetenv(ikptr key){
ikptr
ikrt_environ(ikpcb* pcb){
fprintf(stderr, "environ busted!\n");
exit(-1);
char** es = environ;
int i; char* e;
ikptr ac = null_object;
pcb->root0 = ∾
for(i=0; (e=es[i]); i++){
long int n = strlen(e);
ikptr s = ik_unsafe_alloc(pcb, align(n+disp_string_data+1)) + string_tag;
ref(s, -string_tag) = fix(n);
memcpy((char*)(long)(s+off_string_data), e, n+1);
ikptr p = ik_unsafe_alloc(pcb, pair_size) + pair_tag;
ikptr s = ik_safe_alloc(pcb, align(n+disp_bytevector_data+1))
+ bytevector_tag;
ref(s, -bytevector_tag) = fix(n);
memcpy((char*)(long)(s+off_bytevector_data), e, n+1);
pcb->root1 = &s;
ikptr p = ik_safe_alloc(pcb, pair_size) + pair_tag;
pcb->root1 = 0;
ref(p, off_cdr) = ac;
ref(p, off_car) = s;
ac = p;
}
pcb->root0 = 0;
return ac;
}