diff --git a/src/README.md b/src/README.md index 49065e16..b86f1334 100644 --- a/src/README.md +++ b/src/README.md @@ -325,7 +325,7 @@ A fancier message can be created with `thrF(message, …)` with printf-like (but %s decimal usz %f f64 %p pointer -%c char +%c unicode character (u32) %S char* C-string consisting of ASCII %U char* of UTF-8 data %R a B object of a number or string (string is printed without quotes or escaping) diff --git a/src/core/stuff.c b/src/core/stuff.c index 50c404fd..f01d4b54 100644 --- a/src/core/stuff.c +++ b/src/core/stuff.c @@ -304,8 +304,8 @@ NOINLINE B do_fmt(B s, char* p, va_list a) { break; } case 'c': { - buf[0] = va_arg(a, int); buf[1] = 0; - A8(buf); + u32 p = va_arg(a, u32); + ACHR(p); break; } case '%': { diff --git a/src/ffi.c b/src/ffi.c index f6091ba6..48ef0d57 100644 --- a/src/ffi.c +++ b/src/ffi.c @@ -429,11 +429,11 @@ BQNFFIEnt ffi_parseTypeStr(u32** src, bool inPtr, bool top) { // parse actual ty c++; u8 t = *c++; u32 n = readUInt(&c); - if (t=='i' | t=='c') if (n!=8 & n!=16 & n!=32) { badW: thrF("Bad width in :%c%i", t, n); } + if (t=='i' | t=='c') if (n!=8 & n!=16 & n!=32) { badW: thrF("Bad width in :%c%i", (u32)t, n); } if (t=='u') if (n!=1 & n!=8 & n!=16 & n!=32) goto badW; if (t=='f') if (n!=64) goto badW; - if (isC32(ro) && n > myWidth*8) thrF("FFI: Representation wider than the value for \"%S:%c%i\"", sty_names[o2cG(ro)], t, n); + if (isC32(ro) && n > myWidth*8) thrF("FFI: Representation wider than the value for \"%S:%c%i\"", sty_names[o2cG(ro)], (u32)t, n); // TODO figure out what to do with i32:i32 etc B roP = ro; @@ -588,7 +588,7 @@ void genObj(B o, B c, bool anyMut, void* ptr) { if (isC32(o2)) { // scalar:any u8 et = o2cG(o2); u8 etw = sty_w[et]*8; - if (!isArr(c)) thrF("FFI: Expected array corresponding to \"%S:%c%i\"", sty_names[et], reT, 1<>reW) thrM("FFI: Bad input array length"); B cG = toW(reT, reW, inc(c)); memcpy(ptr, tyany_ptr(cG), 8); // may over-read, ¯\_(ツ)_/¯