From 1b87c2be2a9cdf5b0d3cb883da53f391c5db0461 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 8 Mar 2008 10:26:19 +0100 Subject: [PATCH] Verify user input for tag values (mwfact, nmaster and ncol) Signed-off-by: Julien Danjou --- tag.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tag.c b/tag.c index c53621fa9..29946bca7 100644 --- a/tag.c +++ b/tag.c @@ -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; }