From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 386819f3 for ; Fri, 11 Jan 2019 12:05:14 -0500 (EST) Date: Fri, 11 Jan 2019 12:05:14 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: Improve error reporting when a file given on the command line X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: Log Message: ----------- Improve error reporting when a file given on the command line cannot be opened: * Mention the filename. * Report the errno for the file itself, not the one with .gz appended. Modified Files: -------------- mandoc: main.c read.c Revision Data ------------- Index: read.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/read.c,v retrieving revision 1.210 retrieving revision 1.211 diff -Lread.c -Lread.c -u -p -r1.210 -r1.211 --- read.c +++ read.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010-2018 Ingo Schwarze + * Copyright (c) 2010-2019 Ingo Schwarze * Copyright (c) 2010, 2012 Joerg Sonnenberger * * Permission to use, copy, modify, and distribute this software for any @@ -607,7 +607,7 @@ int mparse_open(struct mparse *curp, const char *file) { char *cp; - int fd; + int fd, save_errno; cp = strrchr(file, '.'); curp->gzip = (cp != NULL && ! strcmp(cp + 1, "gz")); @@ -623,9 +623,11 @@ mparse_open(struct mparse *curp, const c */ if ( ! curp->gzip) { + save_errno = errno; mandoc_asprintf(&cp, "%s.gz", file); fd = open(cp, O_RDONLY); free(cp); + errno = save_errno; if (fd != -1) { curp->gzip = 1; return fd; Index: main.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/main.c,v retrieving revision 1.317 retrieving revision 1.318 diff -Lmain.c -Lmain.c -u -p -r1.317 -r1.318 --- main.c +++ main.c @@ -561,7 +561,7 @@ main(int argc, char *argv[]) } } else mandoc_msg(MANDOCERR_FILE, 0, 0, - "%s", strerror(errno)); + "%s: %s", thisarg, strerror(errno)); if (curp.wstop && mandoc_msg_getrc() != MANDOCLEVEL_OK) break; -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv