Verify user input for tag values (mwfact, nmaster and ncol)

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-03-08 10:26:19 +01:00
parent af04238204
commit 1b87c2be2a
1 changed files with 9 additions and 2 deletions

11
tag.c
View File

@ -39,9 +39,16 @@ tag_new(const char *name, Layout *layout, double mwfact, int nmaster, int ncol)
tag = p_new(Tag, 1);
tag->name = a_strdup(name);
tag->layout = layout;
tag->mwfact = mwfact;
tag->nmaster = nmaster;
tag->ncol = ncol;
if(tag->mwfact <= 0 || tag->mwfact >= 1)
tag->mwfact = 0.5;
if((tag->nmaster = nmaster) < 0)
tag->nmaster = 1;
if((tag->ncol = ncol) < 1)
tag->ncol = 1;
return tag;
}