all widget creators interpret NULL options as zeroes #627

pull/1008/head
nick black 4 years ago
parent a801f975a6
commit 8bf71f4bce
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -126,6 +126,10 @@ ncfdplane_create_internal(ncplane* n, const ncfdplane_options* opts, int fd,
ncfdplane* ncfdplane_create(ncplane* n, const ncfdplane_options* opts, int fd,
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn){
ncfdplane_options zeroed = {};
if(!opts){
opts = &zeroed;
}
if(fd < 0 || !cbfxn || !donecbfxn){
return NULL;
}
@ -290,6 +294,10 @@ ncsubproc_launch(ncplane* n, ncsubproc* ret, const ncsubproc_options* opts, int
ncsubproc* ncsubproc_createv(ncplane* n, const ncsubproc_options* opts,
const char* bin, char* const arg[],
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn){
ncsubproc_options zeroed = {};
if(!opts){
opts = &zeroed;
}
if(!cbfxn || !donecbfxn){
return NULL;
}
@ -321,6 +329,10 @@ ncsubproc* ncsubproc_createv(ncplane* n, const ncsubproc_options* opts,
ncsubproc* ncsubproc_createvp(ncplane* n, const ncsubproc_options* opts,
const char* bin, char* const arg[],
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn){
ncsubproc_options zeroed = {};
if(!opts){
opts = &zeroed;
}
if(!cbfxn || !donecbfxn){
return NULL;
}
@ -352,6 +364,10 @@ ncsubproc* ncsubproc_createvp(ncplane* n, const ncsubproc_options* opts,
ncsubproc* ncsubproc_createvpe(ncplane* n, const ncsubproc_options* opts,
const char* bin, char* const arg[], char* const env[],
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn){
ncsubproc_options zeroed = {};
if(!opts){
opts = &zeroed;
}
if(!cbfxn || !donecbfxn){
return NULL;
}

@ -287,6 +287,10 @@ write_header(ncmenu* ncm){ ncm->ncp->channels = ncm->headerchannels;
}
ncmenu* ncmenu_create(ncplane* n, const ncmenu_options* opts){
ncmenu_options zeroed = {};
if(!opts){
opts = &zeroed;
}
if(opts->sectioncount <= 0 || !opts->sections){
return NULL;
}

@ -16,6 +16,10 @@ class ncppplot {
// ought admit nullptr opts FIXME
// reenable logging once #703 is done
static bool create(ncppplot<T>* ncpp, ncplane* n, const ncplot_options* opts, T miny, T maxy) {
ncplot_options zeroed = {};
if(!opts){
opts = &zeroed;
}
if(opts->flags > NCPLOT_OPTION_DETECTMAXONLY){
logwarn(n->nc, "Provided unsupported flags %016lx\n", opts->flags);
}

@ -1,6 +1,10 @@
#include "internal.h"
ncreader* ncreader_create(ncplane* n, int y, int x, const ncreader_options* opts){
ncreader_options zeroed = {};
if(!opts){
opts = &zeroed;
}
if(opts->physrows <= 0 || opts->physcols <= 0){
logerror(n->nc, "Provided illegal geometry %dx%d\n", opts->physcols, opts->physrows);
return NULL;

@ -719,8 +719,11 @@ ncplane* ncreel_plane(ncreel* nr){
}
ncreel* ncreel_create(ncplane* n, const ncreel_options* ropts){
ncreel_options zeroed = {};
ncreel* nr;
if(!ropts){
ropts = &zeroed;
}
if(!validate_ncreel_opts(n, ropts)){
return NULL;
}

@ -217,6 +217,10 @@ ncselector_dim_yx(notcurses* nc, const ncselector* n, int* ncdimy, int* ncdimx){
}
ncselector* ncselector_create(ncplane* n, int y, int x, const ncselector_options* opts){
ncselector_options zeroed = {};
if(!opts){
opts = &zeroed;
}
unsigned itemcount = 0;
if(opts->flags > 0){
logwarn(n->nc, "Provided unsupported flags %016lx\n", opts->flags);
@ -799,6 +803,10 @@ ncmultiselector_dim_yx(notcurses* nc, const ncmultiselector* n, int* ncdimy, int
ncmultiselector* ncmultiselector_create(ncplane* n, int y, int x,
const ncmultiselector_options* opts){
ncmultiselector_options zeroed = {};
if(!opts){
opts = &zeroed;
}
if(opts->flags > 0){
logwarn(n->nc, "Provided unsupported flags %016lx\n", opts->flags);
}

Loading…
Cancel
Save