diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-07-15 11:46:17 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-07-15 11:46:17 -0400 |
commit | 1b66a6cb98115366fde7aafb6a390cb520c3e0e9 (patch) | |
tree | f94a139ee3a332338b5a75c30885c54dd6e34b73 | |
parent | 8d760d357061d7111455195fcd8de11f8f38c21b (diff) |
use C99 designated initializers
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | strerror.h | 166 |
2 files changed, 87 insertions, 84 deletions
@@ -3,6 +3,7 @@ strerror: strerror.c strerror.h strerror.h: errlist Makefile printf '#ifndef STRERROR_H\n#define STRERROR_H 1\n\n' > $@ - printf 'struct { int number; char *name; } errlist[] = {\n' >> $@ - awk '{printf("#ifdef %s\n\t{ %s,\t\"%s\" },\n#endif\n", $$0, $$0, $$0);}' errlist >> $@ + printf '#include <errno.h>\n\n' >> $@ + printf 'const char *errlist[] = {\n' >> $@ + awk '{printf("#ifdef %s\n\t[%s] = \"%s\",\n#endif\n", $$0, $$0, $$0);}' errlist >> $@ printf '};\n\n#endif\n' >> $@ @@ -1,249 +1,251 @@ #ifndef STRERROR_H #define STRERROR_H 1 -struct { int number; char *name; } errlist[] = { +#include <errno.h> + +const char *errlist[] = { #ifdef E2BIG - { E2BIG, "E2BIG" }, + [E2BIG] = "E2BIG", #endif #ifdef EACCESS - { EACCESS, "EACCESS" }, + [EACCESS] = "EACCESS", #endif #ifdef EADDRINUSE - { EADDRINUSE, "EADDRINUSE" }, + [EADDRINUSE] = "EADDRINUSE", #endif #ifdef EADDRNOTAVAIL - { EADDRNOTAVAIL, "EADDRNOTAVAIL" }, + [EADDRNOTAVAIL] = "EADDRNOTAVAIL", #endif #ifdef EAFNOSUPPORT - { EAFNOSUPPORT, "EAFNOSUPPORT" }, + [EAFNOSUPPORT] = "EAFNOSUPPORT", #endif #ifdef EAGAIN - { EAGAIN, "EAGAIN" }, + [EAGAIN] = "EAGAIN", #endif #ifdef EALREADY - { EALREADY, "EALREADY" }, + [EALREADY] = "EALREADY", #endif #ifdef EBADF - { EBADF, "EBADF" }, + [EBADF] = "EBADF", #endif #ifdef EBADMSG - { EBADMSG, "EBADMSG" }, + [EBADMSG] = "EBADMSG", #endif #ifdef EBUSY - { EBUSY, "EBUSY" }, + [EBUSY] = "EBUSY", #endif #ifdef ECANCELED - { ECANCELED, "ECANCELED" }, + [ECANCELED] = "ECANCELED", #endif #ifdef ECHILD - { ECHILD, "ECHILD" }, + [ECHILD] = "ECHILD", #endif #ifdef ECONNABORTED - { ECONNABORTED, "ECONNABORTED" }, + [ECONNABORTED] = "ECONNABORTED", #endif #ifdef ECONNREFUSED - { ECONNREFUSED, "ECONNREFUSED" }, + [ECONNREFUSED] = "ECONNREFUSED", #endif #ifdef ECONNRESET - { ECONNRESET, "ECONNRESET" }, + [ECONNRESET] = "ECONNRESET", #endif #ifdef EDEADLK - { EDEADLK, "EDEADLK" }, + [EDEADLK] = "EDEADLK", #endif #ifdef EDESTADDRREQ - { EDESTADDRREQ, "EDESTADDRREQ" }, + [EDESTADDRREQ] = "EDESTADDRREQ", #endif #ifdef EDOM - { EDOM, "EDOM" }, + [EDOM] = "EDOM", #endif #ifdef EDQUOT - { EDQUOT, "EDQUOT" }, + [EDQUOT] = "EDQUOT", #endif #ifdef EEXIST - { EEXIST, "EEXIST" }, + [EEXIST] = "EEXIST", #endif #ifdef EFAULT - { EFAULT, "EFAULT" }, + [EFAULT] = "EFAULT", #endif #ifdef EFBIG - { EFBIG, "EFBIG" }, + [EFBIG] = "EFBIG", #endif #ifdef EHOSTUNREACH - { EHOSTUNREACH, "EHOSTUNREACH" }, + [EHOSTUNREACH] = "EHOSTUNREACH", #endif #ifdef EIDRM - { EIDRM, "EIDRM" }, + [EIDRM] = "EIDRM", #endif #ifdef EILSEQ - { EILSEQ, "EILSEQ" }, + [EILSEQ] = "EILSEQ", #endif #ifdef EINPROGRESS - { EINPROGRESS, "EINPROGRESS" }, + [EINPROGRESS] = "EINPROGRESS", #endif #ifdef EINTR - { EINTR, "EINTR" }, + [EINTR] = "EINTR", #endif #ifdef EINVAL - { EINVAL, "EINVAL" }, + [EINVAL] = "EINVAL", #endif #ifdef EIO - { EIO, "EIO" }, + [EIO] = "EIO", #endif #ifdef EISCONN - { EISCONN, "EISCONN" }, + [EISCONN] = "EISCONN", #endif #ifdef EISDIR - { EISDIR, "EISDIR" }, + [EISDIR] = "EISDIR", #endif #ifdef ELOOP - { ELOOP, "ELOOP" }, + [ELOOP] = "ELOOP", #endif #ifdef EMFILE - { EMFILE, "EMFILE" }, + [EMFILE] = "EMFILE", #endif #ifdef EMLINK - { EMLINK, "EMLINK" }, + [EMLINK] = "EMLINK", #endif #ifdef EMSGSIZE - { EMSGSIZE, "EMSGSIZE" }, + [EMSGSIZE] = "EMSGSIZE", #endif #ifdef EMULTIHOP - { EMULTIHOP, "EMULTIHOP" }, + [EMULTIHOP] = "EMULTIHOP", #endif #ifdef ENAMETOOLONG - { ENAMETOOLONG, "ENAMETOOLONG" }, + [ENAMETOOLONG] = "ENAMETOOLONG", #endif #ifdef ENETDOWN - { ENETDOWN, "ENETDOWN" }, + [ENETDOWN] = "ENETDOWN", #endif #ifdef ENETRESET - { ENETRESET, "ENETRESET" }, + [ENETRESET] = "ENETRESET", #endif #ifdef ENETUNREACH - { ENETUNREACH, "ENETUNREACH" }, + [ENETUNREACH] = "ENETUNREACH", #endif #ifdef ENFILE - { ENFILE, "ENFILE" }, + [ENFILE] = "ENFILE", #endif #ifdef ENOBUFS - { ENOBUFS, "ENOBUFS" }, + [ENOBUFS] = "ENOBUFS", #endif #ifdef ENODATA - { ENODATA, "ENODATA" }, + [ENODATA] = "ENODATA", #endif #ifdef ENODEV - { ENODEV, "ENODEV" }, + [ENODEV] = "ENODEV", #endif #ifdef ENOENT - { ENOENT, "ENOENT" }, + [ENOENT] = "ENOENT", #endif #ifdef ENOEXEC - { ENOEXEC, "ENOEXEC" }, + [ENOEXEC] = "ENOEXEC", #endif #ifdef ENOLCK - { ENOLCK, "ENOLCK" }, + [ENOLCK] = "ENOLCK", #endif #ifdef ENOLINK - { ENOLINK, "ENOLINK" }, + [ENOLINK] = "ENOLINK", #endif #ifdef ENOMEM - { ENOMEM, "ENOMEM" }, + [ENOMEM] = "ENOMEM", #endif #ifdef ENOMSG - { ENOMSG, "ENOMSG" }, + [ENOMSG] = "ENOMSG", #endif #ifdef ENOPROTOOPT - { ENOPROTOOPT, "ENOPROTOOPT" }, + [ENOPROTOOPT] = "ENOPROTOOPT", #endif #ifdef ENOSPC - { ENOSPC, "ENOSPC" }, + [ENOSPC] = "ENOSPC", #endif #ifdef ENOSR - { ENOSR, "ENOSR" }, + [ENOSR] = "ENOSR", #endif #ifdef ENOSTR - { ENOSTR, "ENOSTR" }, + [ENOSTR] = "ENOSTR", #endif #ifdef ENOSYS - { ENOSYS, "ENOSYS" }, + [ENOSYS] = "ENOSYS", #endif #ifdef ENOTCONN - { ENOTCONN, "ENOTCONN" }, + [ENOTCONN] = "ENOTCONN", #endif #ifdef ENOTDIR - { ENOTDIR, "ENOTDIR" }, + [ENOTDIR] = "ENOTDIR", #endif #ifdef ENOTEMPTY - { ENOTEMPTY, "ENOTEMPTY" }, + [ENOTEMPTY] = "ENOTEMPTY", #endif #ifdef ENOTRECOVERABLE - { ENOTRECOVERABLE, "ENOTRECOVERABLE" }, + [ENOTRECOVERABLE] = "ENOTRECOVERABLE", #endif #ifdef ENOTSOCK - { ENOTSOCK, "ENOTSOCK" }, + [ENOTSOCK] = "ENOTSOCK", #endif #ifdef ENOTSUP - { ENOTSUP, "ENOTSUP" }, + [ENOTSUP] = "ENOTSUP", #endif #ifdef ENOTTY - { ENOTTY, "ENOTTY" }, + [ENOTTY] = "ENOTTY", #endif #ifdef ENXIO - { ENXIO, "ENXIO" }, + [ENXIO] = "ENXIO", #endif #ifdef EOPNOTSUPP - { EOPNOTSUPP, "EOPNOTSUPP" }, + [EOPNOTSUPP] = "EOPNOTSUPP", #endif #ifdef EOVERFLOW - { EOVERFLOW, "EOVERFLOW" }, + [EOVERFLOW] = "EOVERFLOW", #endif #ifdef EOWNERDEAD - { EOWNERDEAD, "EOWNERDEAD" }, + [EOWNERDEAD] = "EOWNERDEAD", #endif #ifdef EPERM - { EPERM, "EPERM" }, + [EPERM] = "EPERM", #endif #ifdef EPIPE - { EPIPE, "EPIPE" }, + [EPIPE] = "EPIPE", #endif #ifdef EPROTO - { EPROTO, "EPROTO" }, + [EPROTO] = "EPROTO", #endif #ifdef EPROTONOSUPPORT - { EPROTONOSUPPORT, "EPROTONOSUPPORT" }, + [EPROTONOSUPPORT] = "EPROTONOSUPPORT", #endif #ifdef EPROTOTYPE - { EPROTOTYPE, "EPROTOTYPE" }, + [EPROTOTYPE] = "EPROTOTYPE", #endif #ifdef ERANGE - { ERANGE, "ERANGE" }, + [ERANGE] = "ERANGE", #endif #ifdef EROFS - { EROFS, "EROFS" }, + [EROFS] = "EROFS", #endif #ifdef ESPIPE - { ESPIPE, "ESPIPE" }, + [ESPIPE] = "ESPIPE", #endif #ifdef ESRCH - { ESRCH, "ESRCH" }, + [ESRCH] = "ESRCH", #endif #ifdef ESTALE - { ESTALE, "ESTALE" }, + [ESTALE] = "ESTALE", #endif #ifdef ETIME - { ETIME, "ETIME" }, + [ETIME] = "ETIME", #endif #ifdef ETIMEDOUT - { ETIMEDOUT, "ETIMEDOUT" }, + [ETIMEDOUT] = "ETIMEDOUT", #endif #ifdef ETXTBUSY - { ETXTBUSY, "ETXTBUSY" }, + [ETXTBUSY] = "ETXTBUSY", #endif #ifdef EWOULDBLOCK - { EWOULDBLOCK, "EWOULDBLOCK" }, + [EWOULDBLOCK] = "EWOULDBLOCK", #endif #ifdef EXDEV - { EXDEV, "EXDEV" }, + [EXDEV] = "EXDEV", #endif }; |