ref: b35c60cd64b6f630621163226d31f1e2fdc6c90d
parent: e28a69a81ebef87d000b2ab7bb5f920868784e61
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Apr 3 16:18:59 EDT 2025
fix #byte → #utf8 (use symbol's name directly)
--- a/src/print.c
+++ b/src/print.c
@@ -662,7 +662,7 @@
// printing in a context where a type is already implied, e.g. inside
// an array.
static void
-cvalue_printdata(sl_ios *f, void *data, usize len, sl_v type, int weak)
+cvalue_printdata(sl_ios *f, void *data, usize len, sl_v type, bool weak)
{
int n;
if(type == sl_utf8sym){
@@ -670,7 +670,10 @@
if(sl.print_princ)
outc(f, ch);
else{
- n = ios_printf(f, weak ? "0x%hhx" : "#byte(0x%hhx)", ch);
+ if(weak)
+ n = ios_printf(f, "0x%hhx", ch);
+ else
+ n = ios_printf(f, "#%s(0x%hhx)", sym_name_(sl_utf8sym), ch);
if(n < 1)
goto err;
sl.hpos += n;
@@ -834,7 +837,7 @@
for(i = 0; i < cnt; i++){
if(i > 0)
outc(f, ' ');
- cvalue_printdata(f, data, elsize, eltype, 1);
+ cvalue_printdata(f, data, elsize, eltype, true);
data = (char*)data + elsize;
}
outc(f, ')');
@@ -867,7 +870,7 @@
}else{
sl_v type = cv_type(cv);
usize len = iscprim(v) ? cv_class(cv)->size : cv_len(cv);
- cvalue_printdata(f, data, len, type, 0);
+ cvalue_printdata(f, data, len, type, false);
}
}
--- a/src/sl.h
+++ b/src/sl.h
@@ -153,6 +153,7 @@
#define isconst(s) ((s)->flags & FLAG_CONST)
#define iskeyword(s) ((s)->flags & FLAG_KEYWORD)
#define sym_value(s) (((sl_sym*)ptr(s))->binding)
+#define sym_name_(s) (((sl_sym*)ptr(s))->name)
#define sym_to_numtype(s) (((sl_sym*)ptr(s))->numtype)
#define ismanaged(v) ((((u8int*)ptr(v)) >= slg.fromspace) && (((u8int*)ptr(v)) < slg.fromspace+slg.heapsize))
#define isgensym(x) (issym(x) && ismanaged(x))
--
⑨