shithub: femtolisp

Download patch

ref: 07d6d11600b118e5737400f4190706bb196aa40b
parent: 7f24708ec6677e1de14ff4b892ff9482d253bda5
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Oct 31 15:50:23 EDT 2024

cvalue_printdata: print rune arrays correctly, reenable the fallback logic instead of asserting

--- a/print.c
+++ b/print.c
@@ -519,7 +519,6 @@
 	uint8_t c;
 	static char hexdig[] = "0123456789abcdef";
 
-	outc('"', f);
 	if(!u8_isvalid(str, sz)){
 		// alternate print algorithm that preserves data if it's not UTF-8
 		for(i = 0; i < sz; i++){
@@ -542,7 +541,6 @@
 			outsn(buf, f, n-1);
 		}
 	}
-	outc('"', f);
 }
 
 static int
@@ -741,6 +739,7 @@
 		}
 	}else if(iscons(type)){
 		if(car_(type) == arraysym){
+			size_t i;
 			value_t eltype = car(cdr_(type));
 			size_t cnt, elsize;
 			if(iscons(cdr_(cdr_(type)))){
@@ -763,17 +762,26 @@
 						HPOS += u8_strwidth(data);
 					*/
 				}else{
+					outc('"', f);
 					print_string(f, (char*)data, len);
+					outc('"', f);
 				}
 				return;
 			}else if(eltype == runesym){
 				char buf[UTFmax];
-				print_string(f, buf, runetochar(buf, (Rune*)data));
-			}else{
-				/* FIXME */
-				assert(0 == 1);
+				if(!print_princ)
+					outc('"', f);
+				for(i = 0; i < cnt; i++, data = (char*)data + elsize){
+					int n = runetochar(buf, (Rune*)data);
+					if(print_princ)
+						ios_write(f, buf, n);
+					else
+						print_string(f, buf, n);
+				}
+				if(!print_princ)
+					outc('"', f);
+				return;
 			}
-			size_t i;
 			if(!weak){
 				if(eltype == uint8sym){
 					outsn("#vu8(", f, 5);