ncplane_content: add diagnostics #520

pull/723/head
nick black 4 years ago
parent a46dcc5fe4
commit 1f9855b243
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -760,7 +760,9 @@ calc_gradient_channels(uint64_t* channels, uint64_t ul, uint64_t ur,
void nclog(const char* fmt, ...);
// logging
#define logerror(nc, fmt, ...) do{ if(nc->loglevel >= NCLOGLEVEL_ERROR){ nclog(__FILE__ ":%d:" fmt, __LINE__, ##__VA_ARGS__); } }while(0);
#define logerror(nc, fmt, ...) do{ \
if((nc)->loglevel >= NCLOGLEVEL_ERROR){ \
nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } }while(0);
#ifdef __cplusplus
}

@ -2095,9 +2095,12 @@ uint32_t* ncplane_rgba(const ncplane* nc, ncblitter_e blit,
char* ncplane_contents(const ncplane* nc, int begy, int begx, int leny, int lenx){
if(begy < 0 || begx < 0){
logerror(nc->nc, "Beginning coordinates (%d/%d) below 0\n", begy, begx);
return NULL;
}
if(begx >= nc->lenx || begy >= nc->leny){
logerror(nc->nc, "Beginning coordinates (%d/%d) exceeded lengths (%d/%d)\n",
begy, begx, nc->leny, nc->lenx);
return NULL;
}
if(lenx == -1){ // -1 means "to the end"; use all space available
@ -2107,9 +2110,12 @@ char* ncplane_contents(const ncplane* nc, int begy, int begx, int leny, int lenx
leny = nc->leny - begy;
}
if(lenx < 0 || leny < 0){ // no need to draw zero-size object, exit
logerror(nc->nc, "Lengths (%d/%d) below 0\n", leny, lenx);
return NULL;
}
if(begx + lenx > nc->lenx || begy + leny > nc->leny){
logerror(nc->nc, "Ending coordinates (%d/%d) exceeded lengths (%d/%d)\n",
begy + leny, begx + lenx, nc->leny, nc->lenx);
return NULL;
}
size_t retlen = 1;

Loading…
Cancel
Save