* Writing strings to fasl files now uses 4-byte words for each
character.
This commit is contained in:
parent
1c4d3c4b40
commit
267da9e77c
BIN
bin/ikarus
BIN
bin/ikarus
Binary file not shown.
|
@ -98,7 +98,11 @@
|
|||
#define off_string_data (disp_string_data - string_tag)
|
||||
|
||||
#define string_data(x) ((char*)((x) + off_string_data))
|
||||
|
||||
#define string_set(x,i,c) \
|
||||
((((unsigned char*)(x)) + off_string_data + (int)(i))[0] = \
|
||||
(((int)(c)) >> IK_CHAR_SHIFT))
|
||||
#define integer_to_char(x) ((ikp)((((int)(x)) << IK_CHAR_SHIFT) + IK_CHAR_TAG))
|
||||
#define string_char_size 1
|
||||
|
||||
#define vector_tag 5
|
||||
#define disp_vector_length 0
|
||||
|
|
|
@ -270,8 +270,8 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){
|
|||
}
|
||||
return sym;
|
||||
}
|
||||
else if(c == 'S'){
|
||||
/* string */
|
||||
else if(c == 's'){
|
||||
/* ascii string */
|
||||
int len;
|
||||
fasl_read_buf(p, &len, sizeof(int));
|
||||
int size = align(len + disp_string_data + 1);
|
||||
|
@ -284,6 +284,26 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){
|
|||
}
|
||||
return str;
|
||||
}
|
||||
else if(c == 'S'){
|
||||
/* string */
|
||||
int len;
|
||||
fasl_read_buf(p, &len, sizeof(int));
|
||||
int size = align(len*string_char_size + disp_string_data + 1);
|
||||
ikp str = ik_alloc(pcb, size) + string_tag;
|
||||
ref(str, off_string_length) = fix(len);
|
||||
int i;
|
||||
for(i=0; i<len; i++){
|
||||
int c;
|
||||
fasl_read_buf(p, &c, sizeof(int));
|
||||
string_set(str, i, integer_to_char(c));
|
||||
}
|
||||
str[off_string_data+len*string_char_size] = 0;
|
||||
if(put_mark_index){
|
||||
p->marks[put_mark_index] = str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
else if(c == 'V'){
|
||||
int len;
|
||||
fasl_read_buf(p, &len, sizeof(int));
|
||||
|
|
BIN
src/ikarus.boot
BIN
src/ikarus.boot
Binary file not shown.
|
@ -18,7 +18,8 @@
|
|||
;;; "P" + object1 + object2 : a pair
|
||||
;;; "V" + 4-bytes(n) + object ... : a vector of length n followed by n objects
|
||||
;;; "v" + 4-byte(n) + octet ... : a bytevector of length n followed by n octets
|
||||
;;; "S" + 4-bytes(n) + char ... : a string
|
||||
;;; "s" + 4-bytes(n) + octet ... : an ascii string
|
||||
;;; "S" + 4-bytes(n) + int ... : a unicode string
|
||||
;;; "M" + symbol-name : a symbol
|
||||
;;; "G" + pretty-name + unique-name : a gensym
|
||||
;;; "R" + rtd-name + rtd-symbol + field-count + field-names
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
(cond
|
||||
[(fx= i n) m]
|
||||
[else
|
||||
(write-char (string-ref x i) p)
|
||||
(write-int (char->integer (string-ref x i)) p)
|
||||
(f x (fxadd1 i) n)]))]
|
||||
[(gensym? x)
|
||||
(write-char #\G p)
|
||||
|
|
Loading…
Reference in New Issue