diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-23 09:41:03 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-23 09:41:03 +0000 |
commit | 35fcd59ab7d5e77c7a61c3e76b92fa873b6047f9 (patch) | |
tree | 9058fde0befc5e90b420d27491e4f44d13370dff /usr.bin/chpass | |
parent | 7703926cf5551d884de61af6a6d2eb4da45bf423 (diff) |
for errors, tell which line #
Diffstat (limited to 'usr.bin/chpass')
-rw-r--r-- | usr.bin/chpass/edit.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/chpass/edit.c b/usr.bin/chpass/edit.c index 39d416f3c73..ab4afd125a3 100644 --- a/usr.bin/chpass/edit.c +++ b/usr.bin/chpass/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.10 1996/09/01 13:06:51 deraadt Exp $ */ +/* $OpenBSD: edit.c,v 1.11 1996/09/23 09:41:02 deraadt Exp $ */ /* $NetBSD: edit.c,v 1.6 1996/05/15 21:50:45 jtc Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)edit.c 8.3 (Berkeley) 4/2/94"; #else -static char rcsid[] = "$OpenBSD: edit.c,v 1.10 1996/09/01 13:06:51 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: edit.c,v 1.11 1996/09/23 09:41:02 deraadt Exp $"; #endif #endif /* not lint */ @@ -148,7 +148,7 @@ verify(tempname, pw) char *p; struct stat sb; FILE *fp; - int len, alen; + int len, alen, line; static char buf[LINE_MAX]; if (!(fp = fopen(tempname, "r"))) @@ -159,17 +159,19 @@ verify(tempname, pw) warnx("corrupted temporary file"); goto bad; } + line = 0; while (fgets(buf, sizeof(buf), fp)) { + line++; if (!buf[0] || buf[0] == '#') continue; if (!(p = strchr(buf, '\n'))) { - warnx("line too long"); + warnx("line %d too long", line); goto bad; } *p = '\0'; for (ep = list;; ++ep) { if (!ep->prompt) { - warnx("unrecognized field"); + warnx("unrecognized field on line %d", line); goto bad; } if (!strncasecmp(buf, ep->prompt, ep->len)) { @@ -180,7 +182,7 @@ verify(tempname, pw) goto bad; } if (!(p = strchr(buf, ':'))) { - warnx("line corrupted"); + warnx("line %d corrupted", line); goto bad; } while (isspace(*++p)); |