aboutsummaryrefslogtreecommitdiff
path: root/lex.l
diff options
context:
space:
mode:
Diffstat (limited to 'lex.l')
-rw-r--r--lex.l47
1 files changed, 15 insertions, 32 deletions
diff --git a/lex.l b/lex.l
index 48f943a..ba48a9c 100644
--- a/lex.l
+++ b/lex.l
@@ -1,6 +1,6 @@
%{
/* ckaliases - verify syntax of sendmail-style alias files
- Copyright (C) 2005 Sergey Poznyakoff
+ Copyright (C) 2005, 2007 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -15,16 +15,6 @@
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <string.h>
-#define obstack_chunk_alloc malloc
-#define obstack_chunk_free free
-#include <obstack.h>
#include "ckaliases.h"
#include "gram.h"
@@ -87,11 +77,9 @@ SPEC [:@\\]
\n{WS}+/[^ \t\n] { line_num++; return CONT; }
\n { line_num++; return EOL; }
, return yytext[0];
-. { char *p;
- asprintf(&p,
+. { error_at_line (0, 0, file_name, line_num,
"Stray character %03o in alias file", yytext[0]);
- yyerror(p);
- free (p); }
+ error_count++; }
%%
int
@@ -147,11 +135,8 @@ void
openaliases (char *name)
{
yyin = fopen (name, "r");
- if (!yyin) {
- fprintf(stderr, "cannot open file `%s': %s\n",
- name, strerror(errno));
- exit(1);
- }
+ if (!yyin)
+ error (1, errno, "cannot open file `%s'", name);
file_name = name;
line_num = 0;
}
@@ -162,13 +147,11 @@ openaliases_prefix(char *prefix, char *name)
char *fullname = NULL;
struct stat st;
- if (stat(prefix, &st)) {
- fprintf(stderr, "cannot stat `%s': %s\n",
- prefix, strerror(errno));
- exit(1);
- }
+ if (stat (prefix, &st))
+ error (1, errno, "cannot stat `%s'", prefix);
- if (!S_ISDIR(st.st_mode)) {
+ if (!S_ISDIR (st.st_mode))
+ {
char *p = strrchr (prefix, '/');
if (p)
*p = 0;
@@ -200,17 +183,17 @@ read_include(SLIST **plist, char *name)
char buffer[256];
FILE *fp = fopen (name, "r");
- if (!fp) {
- char *p;
- asprintf(&p,
+ if (!fp)
+ {
+ error_at_line (0, 0, file_name, line_num,
"cannot open include file `%s': %s",
name, strerror (errno));
- yyerror(p);
- free(p);
+ error_count++;
return;
}
- while (p = fgets(buffer, sizeof buffer, fp)) {
+ while (p = fgets (buffer, sizeof buffer, fp))
+ {
char *q;
while (*p && isspace (*p))

Return to:

Send suggestions and report system problems to the System administrator.