negative values for borderwith, moveamount, snapdist and gap are

configuration errors, so warn and load defaults.
This commit is contained in:
okan 2013-05-06 19:09:19 +00:00
parent 52cbef8a12
commit fb30b6ad26

View File

@ -1,4 +1,4 @@
/* $OpenBSD: parse.y,v 1.40 2013/04/17 13:30:38 okan Exp $ */
/* $OpenBSD: parse.y,v 1.41 2013/05/06 19:09:19 okan Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -117,12 +117,24 @@ main : FONTNAME STRING {
conf->flags |= CONF_STICKY_GROUPS;
}
| BORDERWIDTH NUMBER {
if ($2 < 0) {
yyerror("invalid borderwidth: %d", $2);
YYERROR;
}
conf->bwidth = $2;
}
| MOVEAMOUNT NUMBER {
if ($2 < 0) {
yyerror("invalid movemount: %d", $2);
YYERROR;
}
conf->mamount = $2;
}
| SNAPDIST NUMBER {
if ($2 < 0) {
yyerror("invalid snapdist: %d", $2);
YYERROR;
}
conf->snapdist = $2;
}
| COMMAND STRING string {
@ -133,10 +145,9 @@ main : FONTNAME STRING {
| AUTOGROUP NUMBER STRING {
if ($2 < 0 || $2 > 9) {
free($3);
yyerror("autogroup number out of range: %d", $2);
yyerror("invalid autogroup: %d", $2);
YYERROR;
}
conf_autogroup(conf, $2, $3);
free($3);
}
@ -150,6 +161,11 @@ main : FONTNAME STRING {
free($3);
}
| GAP NUMBER NUMBER NUMBER NUMBER {
if ($2 < 0 || $3 < 0 || $4 < 0 || $5 < 0) {
yyerror("invalid gap: %d %d %d %d",
$2, $3, $4, $5);
YYERROR;
}
conf->gap.top = $2;
conf->gap.bottom = $3;
conf->gap.left = $4;