%}
-NUMBER [0-9]+
+NUMBER -?[0-9]+
VALUE \".*\"
MALSTRING \"[^\"\n]*\n
WHITE [\t ]*
%%
-{NUMBER} { yylval.i = atoi(yytext); return TYPE_NUMBER; }
+{NUMBER} {
+ unsigned int x;
+ errno = 0;
+
+ if (atoi(yytext) < 0)
+ {
+ fprintf(stderr,"%s:%d: negative value not accepted! Fix it now!\n",
+ config, line);
+ graceful_exit(1);
+ }
+
+ x = strtoul(yytext, NULL, 10);
+
+ if (errno == ERANGE)
+ {
+ fprintf(stderr, "%s:%d: %s is too big! Fix it now!\n",
+ config, line, yytext);
+ graceful_exit(1);
+ }
+
+ yylval.i = x;
+ return TYPE_NUMBER;
+}
+
{VALUE} {
yytext[yyleng - 1] = '\0'; /* Kill the trailing quote */
yylval.s = strdup(yytext + 1); /* kill leading quote */