Skip to content

Commit

Permalink
genconfig: fix bug with /set out-of-range values
Browse files Browse the repository at this point in the history
  • Loading branch information
ec429 committed Jun 11, 2011
1 parent 03fc9a4 commit 5eea39e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions config_set.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
} }
else else
width=80; width=80;
if(width<30)
width=30;
if(!quiet) if(!quiet)
{ {
char smsg[37]; char smsg[37];
Expand All @@ -30,6 +32,8 @@
} }
else else
height=24; height=24;
if(height<5)
height=5;
if(!quiet) if(!quiet)
{ {
char smsg[38]; char smsg[38];
Expand All @@ -51,6 +55,8 @@
} }
else else
mirc_colour_compat=1; mirc_colour_compat=1;
if(mirc_colour_compat>2)
mirc_colour_compat=2;
if(!quiet) if(!quiet)
{ {
if(mirc_colour_compat) if(mirc_colour_compat)
Expand Down Expand Up @@ -86,6 +92,8 @@
} }
else else
force_redraw=0; force_redraw=0;
if(force_redraw>3)
force_redraw=3;
if(!quiet) if(!quiet)
{ {
if(force_redraw) if(force_redraw)
Expand Down Expand Up @@ -121,6 +129,8 @@
} }
else else
buflines=256; buflines=256;
if(buflines<32)
buflines=32;
if(!quiet) if(!quiet)
{ {
char smsg[36]; char smsg[36];
Expand All @@ -142,6 +152,8 @@
} }
else else
maxnlen=16; maxnlen=16;
if(maxnlen<4)
maxnlen=4;
if(!quiet) if(!quiet)
{ {
char smsg[39]; char smsg[39];
Expand Down Expand Up @@ -301,6 +313,8 @@
} }
else else
tping=30; tping=30;
if(tping<15)
tping=15;
if(!quiet) if(!quiet)
{ {
char smsg[42]; char smsg[42];
Expand All @@ -322,6 +336,8 @@
} }
else else
ts=1; ts=1;
if(ts>4)
ts=4;
if(!quiet) if(!quiet)
{ {
if(ts) if(ts)
Expand Down
10 changes: 10 additions & 0 deletions genconfig.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -490,6 +490,16 @@ Generated by <small>genconfig</small></h5>\n\
printf("\t\t\t\t\t}\n"); printf("\t\t\t\t\t}\n");
printf("\t\t\t\t\telse\n"); printf("\t\t\t\t\telse\n");
printf("\t\t\t\t\t\t%s=%d;\n", ents[i].cname, ents[i].value); printf("\t\t\t\t\t\t%s=%d;\n", ents[i].cname, ents[i].value);
if(ents[i].min>0)
{
printf("\t\t\t\t\tif(%s<%d)\n", ents[i].cname, ents[i].min);
printf("\t\t\t\t\t\t%s=%d;\n", ents[i].cname, ents[i].min);
}
if(ents[i].max>=0)
{
printf("\t\t\t\t\tif(%s>%d)\n", ents[i].cname, ents[i].max);
printf("\t\t\t\t\t\t%s=%d;\n", ents[i].cname, ents[i].max);
}
} }
printf("\t\t\t\t\tif(!quiet)\n"); printf("\t\t\t\t\tif(!quiet)\n");
printf("\t\t\t\t\t{\n"); printf("\t\t\t\t\t{\n");
Expand Down

0 comments on commit 5eea39e

Please sign in to comment.