From dc2a5030fc5e2ffad4fc3637a3f3010698cda414 Mon Sep 17 00:00:00 2001 From: christos Date: Tue, 21 Aug 2007 14:09:53 +0000 Subject: [PATCH] provide more detailed messages with -l. From Anon Ymous --- usr.bin/cmp/extern.h | 3 ++- usr.bin/cmp/misc.c | 14 ++++++++++++-- usr.bin/cmp/special.c | 11 ++++++----- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/usr.bin/cmp/extern.h b/usr.bin/cmp/extern.h index 150bb19e25ec..e84502bf09b7 100644 --- a/usr.bin/cmp/extern.h +++ b/usr.bin/cmp/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.6 2006/06/03 18:55:02 christos Exp $ */ +/* $NetBSD: extern.h,v 1.7 2007/08/21 14:09:53 christos Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -39,5 +39,6 @@ void c_regular(int, char *, off_t, off_t, int, char *, off_t, off_t); void c_special(int, char *, off_t, int, char *, off_t); void diffmsg(char *, char *, off_t, off_t); void eofmsg(char *, off_t, off_t); +void errmsg(char *, off_t, off_t); extern int lflag, sflag; diff --git a/usr.bin/cmp/misc.c b/usr.bin/cmp/misc.c index fd333c53c7f9..750a5cc325c3 100644 --- a/usr.bin/cmp/misc.c +++ b/usr.bin/cmp/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.9 2006/06/03 18:55:02 christos Exp $ */ +/* $NetBSD: misc.c,v 1.10 2007/08/21 14:09:54 christos Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: misc.c,v 1.9 2006/06/03 18:55:02 christos Exp $"); +__RCSID("$NetBSD: misc.c,v 1.10 2007/08/21 14:09:54 christos Exp $"); #endif #endif /* not lint */ @@ -46,6 +46,16 @@ __RCSID("$NetBSD: misc.c,v 1.9 2006/06/03 18:55:02 christos Exp $"); #include "extern.h" +void +errmsg(char *file, off_t byte, off_t line) +{ + if (lflag) + err(ERR_EXIT, "%s: char %llu, line %llu", file, + (unsigned long long)byte, (unsigned long long)line); + else + err(ERR_EXIT, "%s", file); +} + void eofmsg(char *file, off_t byte, off_t line) { diff --git a/usr.bin/cmp/special.c b/usr.bin/cmp/special.c index 0bb4840d5ee3..e7f1b11d5f61 100644 --- a/usr.bin/cmp/special.c +++ b/usr.bin/cmp/special.c @@ -1,4 +1,4 @@ -/* $NetBSD: special.c,v 1.11 2006/06/03 18:55:02 christos Exp $ */ +/* $NetBSD: special.c,v 1.12 2007/08/21 14:09:54 christos Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)special.c 8.3 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: special.c,v 1.11 2006/06/03 18:55:02 christos Exp $"); +__RCSID("$NetBSD: special.c,v 1.12 2007/08/21 14:09:54 christos Exp $"); #endif #endif /* not lint */ @@ -94,10 +94,11 @@ c_special(int fd1, char *file1, off_t skip1, int fd2, char *file2, off_t skip2) ++line; } -eof: if (ferror(fp1)) - err(ERR_EXIT, "%s", file1); + eof: + if (ferror(fp1)) + errmsg(file1, byte, line); if (ferror(fp2)) - err(ERR_EXIT, "%s", file2); + errmsg(file2, byte, line); if (feof(fp1)) { if (!feof(fp2)) eofmsg(file1, byte, line);