laughable implementation of ncplane_vprintf #9

This commit is contained in:
nick black 2019-11-24 16:19:24 -05:00
parent ca5c37fab9
commit 8ff52f5ebc
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -763,8 +763,19 @@ int ncplane_printf(ncplane* n, const char* format, ...){
return ret;
}
// i hate the big allocation and two copies here, but eh what you gonna do?
// well, for one, we don't need the huge allocation FIXME
int ncplane_vprintf(ncplane* n, const char* format, va_list ap){
// FIXME
vfprintf(stderr, format, ap);
return 0;
// FIXME technically insufficient to cover area due to EGCs, lol
const size_t size = n->leny * n->lenx + 1;
char* buf = malloc(size);
if(buf == NULL){
return -1;
}
int ret = vsnprintf(buf, size, format, ap);
if(ncplane_putstr(n, buf)){ // FIXME handle short writes also!
ret = -1;
}
free(buf);
return ret;
}