]> git.ipfire.org Git - people/ms/dma.git/commitdiff
aliases: log errors to syslog and abort
authorSimon Schubert <2@0x2c.org>
Sat, 6 Jul 2013 19:00:05 +0000 (21:00 +0200)
committerSimon Schubert <2@0x2c.org>
Sat, 6 Jul 2013 19:00:05 +0000 (21:00 +0200)
aliases_parse.y

index dd8b88a8104239e957abaed6958fe9cd8e6c5f73..a5a9e7b32f071aa0ca3026938296dea8f8847ef8 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <err.h>
 #include <string.h>
+#include <syslog.h>
 #include "dma.h"
 
 extern int yylineno;
@@ -12,7 +13,12 @@ int yylex(void);
 static void
 yyerror(const char *msg)
 {
-       warnx("aliases line %d: %s", yylineno, msg);
+       /**
+        * Because we do error '\n' below, we need to report the error
+        * one line above of what yylineno points to.
+        */
+       syslog(LOG_CRIT, "aliases line %d: %s", yylineno - 1, msg);
+       fprintf(stderr, "aliases line %d: %s\n", yylineno - 1, msg);
 }
 
 int
@@ -72,8 +78,7 @@ alias : T_IDENT ':' dests '\n'
                }
        | error '\n'
                {
-                       yyerrok;
-                       $$ = NULL;
+                       YYABORT;
                }
        ;