> From: l...@gnu.org (Ludovic Courtès) > Cc: m...@netris.org, guile-user@gnu.org > Date: Sun, 16 Jun 2013 17:04:15 +0200 > > Eli Zaretskii <e...@gnu.org> skribis: > > > The changes below work around the lack of h_error on Windows: > > > > --- libguile/net_db.c~0 2013-03-25 23:44:46.000000000 +0200 > > +++ libguile/net_db.c 2013-06-13 13:30:20.448923200 +0300 > > @@ -55,6 +55,47 @@ > > #include "libguile/net_db.h" > > #include "libguile/socket.h" > > > > +#ifdef __MINGW32__ > > +# define h_errno WSAGetLastError() > > +# define HAVE_H_ERRNO 1 > > +# define HAVE_HSTRERROR 1 > > +# ifdef HAVE_DECL_HSTRERROR > > +# undef HAVE_DECL_HSTRERROR > > +# endif > > +# define HAVE_DECL_HSTRERROR 1 > > +# define HOST_NOT_FOUND WSAHOST_NOT_FOUND > > +# define TRY_AGAIN WSATRY_AGAIN > > +# define NO_RECOVERY WSANO_RECOVERY > > +# define NO_DATA WSANO_DATA > > + > > +char *hstrerror (int); > > + > > +char * > > +hstrerror (int error_no) > > +{ > > + static char buf[500]; > > Rather allocate it dynamically, with ‘scm_gc_malloc_pointerless’. > > > + DWORD ret; > > + > > + if (error_no == 0) > > + error_no = WSAGetLastError (); > > + > > + ret = FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | > > + FORMAT_MESSAGE_IGNORE_INSERTS, > > + NULL, > > + error_no, > > + 0, /* choose most suitable language */ > > + buf, sizeof (buf), NULL); > > + > > + while (ret > 0 && (buf[ret - 1] == '\n' || > > + buf[ret - 1] == '\r' )) > > + --ret; > > + buf[ret] = '\0'; > > + if (!ret) > > + sprintf (buf, "Winsock error %u", error_no); > > + > > + return buf; > > +} > > +#endif /* __MINGW32__ */ > > This looks good, but I feel that this ought to be in a Gnulib module, > no? Would you like to propose such a module on bug-gnulib@?
I will try. Thanks.