bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hstrerror for MinGW (was: guile 2.0.9 build on mingw)


From: Eli Zaretskii
Subject: Re: hstrerror for MinGW (was: guile 2.0.9 build on mingw)
Date: Tue, 18 Feb 2014 20:12:26 +0200

Ping!  (more than half a year passed)

> Date: Sun, 16 Jun 2013 18:54:18 +0300
> From: Eli Zaretskii <address@hidden>
> Cc: address@hidden
> 
> > From: address@hidden (Ludovic Courtès)
> > Cc: address@hidden,  address@hidden
> > Date: Sun, 16 Jun 2013 17:04:15 +0200
> > 
> > Eli Zaretskii <address@hidden> 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 address@hidden
> 
> This came up on guile-users while discussing the MinGW build of Guile,
> see
> 
>   http://lists.gnu.org/archive/html/guile-user/2013-06/msg00028.html
>   http://lists.gnu.org/archive/html/guile-user/2013-06/msg00039.html
> 
> Will gnulib maintainers consider this for inclusion, please?
> 
> TIA
> 
> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]