Browse Source

FIX: building without gnu's strerror_r

root 5 years ago
parent
commit
8652af728d
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/Utils.cpp

+ 7 - 1
src/Utils.cpp

@@ -418,10 +418,16 @@ string Utils::errnotostrerror(int errnum)
 {
   char buf[2048]="";
   char *strerr;
-//  if(strerror_r(errnum,strerr,1024)!=-1)
   #ifndef WIN32
+  #ifdef __GLIBC__
   strerr=strerror_r(errnum,buf,2048);
   #else
+  int retval = strerror_r(errnum, buf, sizeof buf);
+  strerr = buf;
+  if(retval != 0)
+    strcpy(buf, "error fetching error description");
+  #endif
+  #else
   strerr="Error ";
   #endif //WIN32
   return string(strerr)+" ("+inttostr(errnum)+")";