%}
-NUMBER -?[0-9]+
+NEGNUMBER -[0-9]+
+NUMBER [^-][0-9]+
VALUE \".*\"
MALSTRING \"[^\"\n]*\n
WHITE [\t ]*
%%
-{NUMBER} {
- unsigned int x;
- errno = 0;
-
- if (atoi(yytext) < 0)
- {
- fprintf(stderr,"%s:%d: negative value not accepted! Fix it now!\n",
+{NEGNUMBER} {
+ 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;
+ graceful_exit(1);
+}
+
+{NUMBER} {
+ yylval.i = strtoul(yytext, NULL, 10);
return TYPE_NUMBER;
}
}
{MALSTRING} {
+ yytext[yyleng - 1] = '\0'; /* remove trailing newline */
/* yytext already contains a newline, no need for one here */
fprintf(stderr, "%s:%d:%d: unterminated string constant: %s\n", config, line, col - yyleng + 1, yytext);
+ return TYPE_MALSTRING;
}
{WHITE} { }
\n { line++; col = 0; }
. {
- fprintf(stderr, "%s: unrecognized token \"%s\" at line %d, column %d\n", config, yytext, line, col);
+ fprintf(stderr, "%s:%d:%d unrecognized token \"%s\"\n", config, line, col, yytext);
}
%%
%token TYPE_SUSER TYPE_SGROUP TYPE_SGID TYPE_SUID TYPE_MAX
%token TYPE_PATH_NETHACK TYPE_PATH_DGLDIR TYPE_PATH_SPOOL
%token TYPE_PATH_BANNER TYPE_PATH_CANNED TYPE_PATH_CHROOT
-%token TYPE_PATH_PASSWD TYPE_PATH_LOCKFILE
+%token TYPE_PATH_PASSWD TYPE_PATH_LOCKFILE TYPE_MALSTRING
%token <s> TYPE_VALUE
%token <i> TYPE_NUMBER
%type <kt> KeyType
free($3);
}
+ | KeyType '=' TYPE_MALSTRING {}
| KeyType '=' TYPE_NUMBER {
if (!myconfig)
{
void yyerror(char const* s)
{
if (!silent)
- fprintf(stderr, "%s: couldn't parse \"%s\" at line %d, column %d: %s\n", config, yytext, line, col, s);
+ fprintf(stderr, "%s:%d:%d: couldn't parse \"%s\": %s\n", config, line, col, yytext, s);
}