* Writing strings to fasl files now uses 4-byte words for each

character.
This commit is contained in:
Abdulaziz Ghuloum 2007-05-19 13:54:13 -04:00
parent 1c4d3c4b40
commit 267da9e77c
6 changed files with 30 additions and 5 deletions

Binary file not shown.

View File

@ -98,7 +98,11 @@
#define off_string_data (disp_string_data - string_tag) #define off_string_data (disp_string_data - string_tag)
#define string_data(x) ((char*)((x) + off_string_data)) #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 vector_tag 5
#define disp_vector_length 0 #define disp_vector_length 0

View File

@ -270,8 +270,8 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){
} }
return sym; return sym;
} }
else if(c == 'S'){ else if(c == 's'){
/* string */ /* ascii string */
int len; int len;
fasl_read_buf(p, &len, sizeof(int)); fasl_read_buf(p, &len, sizeof(int));
int size = align(len + disp_string_data + 1); int size = align(len + disp_string_data + 1);
@ -284,6 +284,26 @@ static ikp do_read(ikpcb* pcb, fasl_port* p){
} }
return str; 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'){ else if(c == 'V'){
int len; int len;
fasl_read_buf(p, &len, sizeof(int)); fasl_read_buf(p, &len, sizeof(int));

Binary file not shown.

View File

@ -18,7 +18,8 @@
;;; "P" + object1 + object2 : a pair ;;; "P" + object1 + object2 : a pair
;;; "V" + 4-bytes(n) + object ... : a vector of length n followed by n objects ;;; "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 ;;; "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 ;;; "M" + symbol-name : a symbol
;;; "G" + pretty-name + unique-name : a gensym ;;; "G" + pretty-name + unique-name : a gensym
;;; "R" + rtd-name + rtd-symbol + field-count + field-names ;;; "R" + rtd-name + rtd-symbol + field-count + field-names

View File

@ -63,7 +63,7 @@
(cond (cond
[(fx= i n) m] [(fx= i n) m]
[else [else
(write-char (string-ref x i) p) (write-int (char->integer (string-ref x i)) p)
(f x (fxadd1 i) n)]))] (f x (fxadd1 i) n)]))]
[(gensym? x) [(gensym? x)
(write-char #\G p) (write-char #\G p)