perror: call strerror_r directly
[gnulib.git] / lib / strerror.c
index 6137552..9d1f165 100644 (file)
 /* Specification.  */
 #include <string.h>
 
-#if REPLACE_STRERROR
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
 
-# include <errno.h>
-# include <stdio.h>
-# include <stdlib.h>
-
-# include "intprops.h"
-# include "verify.h"
+#include "intprops.h"
+#include "verify.h"
 
 /* Use the system functions, not the gnulib overrides in this file.  */
-# undef sprintf
-
-char *
-strerror (int n)
-{
-  static char buf[256];
-
-  int ret = strerror_r (n, buf, sizeof (buf));
-
-  if (ret == 0)
-    return buf;
-
-  if (ret == ERANGE)
-    /* If this happens, increase the size of buf.  */
-    abort ();
-
-  {
-    static char const fmt[] = "Unknown error (%d)";
-    verify (sizeof (buf) >= sizeof (fmt) + INT_STRLEN_BOUND (n));
-    sprintf (buf, fmt, n);
-    return buf;
-  }
-}
+#undef sprintf
 
-#endif
+#include "strerror-impl.h"