From mboxrd@z Thu Jan 1 00:00:00 1970 From: lm@mcvoy.com (Larry McVoy) Date: Tue, 19 Sep 2017 07:42:06 -0700 Subject: [TUHS] Happy birthday, Dennis Ritchie! [ really sun vs dec/apollo --> X and NeWS ] In-Reply-To: References: <1505782328.3172479.1110519744.63D53ACC@webmail.messagingengine.com> <20170919025031.GA25650@mcvoy.com> Message-ID: <20170919144206.GP25650@mcvoy.com> On Tue, Sep 19, 2017 at 10:32:20AM -0400, Clem Cole wrote: > On Mon, Sep 18, 2017 at 10:50 PM, Larry McVoy wrote: > > > So in the BitKeeper source, perror is redifined to my_perror which is > > this: > > > > void > > my_perror(char *file, int line, char *msg) > > { > > char *p = 0; > > int save = errno; > > > > if (p = getenv("_BK_VERSION")) { > > if (strneq(p, "bk-", 3)) p += 3; > > fprintf(stderr, "%s:%d (%s): ", file, line, p); > > } else { > > fprintf(stderr, "%s:%d: ", file, line); > > } > > if (p = strerror(errno)) { > > fprintf(stderr, "%s: %s\n", msg, p); > > } else { > > fprintf(stderr, "%s: errno=%d\n", msg, errno); > > } > > errno = save; > > } > > > > libc should do that. > > > ???+1, indeed!??? - knowing where the the error came from (file and line) is > huge. Yeah it means putting it in the preprocessor, which has some issues; > but it comes back to a previous comment I have made -- I really believe a > serious production language needs a preprocessor that is carefully used > because there are places (like this one) that just makes the right things > happen. Yep. And the _BK_VERSION stuff is obviously BK specific, but if there was a way to generalize that so you could have _APPLICATION_VERSION or something and that got printed with the error then you get stuff like slib.c:1653 (bk-7.3): open failed: permission denied which is way way way more useful than just permission denied.