X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=lib%2Futils.c;h=2e40ef5889f8c6890ed3eaed5b45483ebc8c4ba3;hp=6b3dd237ed32616be75310581ef74790749487ac;hb=b0825f36b7b5dade1693fdbddfec7eef3f5ed86f;hpb=f08fc359a0b7f638e73a8f866119b016b7dff8de diff --git a/lib/utils.c b/lib/utils.c index 6b3dd237..2e40ef58 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -80,15 +80,22 @@ void cp_trace() } #endif -#ifdef HAVE_MINGW +#if defined(HAVE_MINGW) || defined(HAVE_CYGWIN) +#ifdef HAVE_CYGWIN +#include +#endif + char *winerror(int err) { - static char buf[1024]; + static char buf[1024], *newline; if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, sizeof(buf), NULL)) { strncpy(buf, _("(unable to format errormessage)"), sizeof(buf)); }; + if((newline = strchr(buf, '\r'))) + *newline = '\0'; + return buf; } #endif