[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: errno --> errno name ?
From: |
Sam Steingold |
Subject: |
Re: errno --> errno name ? |
Date: |
Mon, 06 Jun 2011 18:38:00 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Hi Bruno,
> * Bruno Haible <address@hidden> [2011-06-06 22:52:14 +0200]:
>> I think it would be a useful addition to the errno/strerror/whatever
>> modules to be able to convert from the numeric errno to the symbolic
>> one.
>> e.g.,
>>
>> char * errno_name () {
>> switch (errno) {
>> #ifdef ENOENT
>> case ENOENT : return "ENOENT";
>> #endif
>> default: return NULL;
>> }
>> }
>>
>> the idea is that the error "explanation" (returned by strerror) is
>> different on different platforms (and especially if i18n is involved)
>> and is hard to search for on the web and in docs, while strings like
>> ENOENT et al are quite canonical and tell the expert everything they
>> need to know.
>
> Good point. The code for doing this is already present in
> clisp/src/errunix.d and strace/**/errnoent.h.
moreover, most of it can be easily generated from the list of all
possible errno values:
-----------------
char * errno_name () {
switch (errno) {
#include "errno_cases.h"
default: return NULL;
}
}
----------------
and a simple awk command which would convert a file:
---------
ENOENT
ENOTDIR
...
---------
into "errno_cases.h"
note that the windows version would have to operate on the values of
GetLastError() instead of errno.
> Question to Sam: Are you willing to contribute such a module to gnulib
> (and maintain it)?
Absolutely not. The whole point of my request is that I will be
maintaining _less_ code, not more.
--
Sam Steingold (http://sds.podval.org/) on CentOS release 5.6 (Final) X
11.0.60900031
http://pmw.org.il http://palestinefacts.org http://openvotingconsortium.org
http://www.memritv.org http://iris.org.il http://thereligionofpeace.com
Just because you're paranoid doesn't mean they AREN'T after you.