Commit e9c936ff authored by Tom Lane's avatar Tom Lane

Remove rangechecks on errno; just call strerror unconditionally. This

eliminates a raft of portability issues, including whether sys_nerr
exists, whether the platform has any valid negative errnos, etc.  The
downside is minimal: errno shouldn't ever contain an invalid value anyway,
and if it does, reasonably modern versions of strerror will not choke.
This rangecheck idea seemed good at the time, but it's clearly a net loss,
and I apologize to all concerned for having ever put it in.
parent 60b282fd
# Macros that test various C library quirks
# $Header: /cvsroot/pgsql/config/c-library.m4,v 1.7 2001/01/10 17:07:18 petere Exp $
# $Header: /cvsroot/pgsql/config/c-library.m4,v 1.8 2001/01/22 23:28:50 tgl Exp $
# PGAC_VAR_INT_TIMEZONE
......@@ -124,19 +124,3 @@ if test x"$pgac_cv_header_strings_both" = x"yes"; then
AC_DEFINE([STRING_H_WITH_STRINGS_H], 1,
[Define if string.h and strings.h may both be included])
fi])
# PGAC_VAR_SYS_NERR
# -----------------
# Check if the global variable 'sys_nerr' exists. If so, define
# HAVE_SYS_NERR.
AC_DEFUN([PGAC_VAR_SYS_NERR],
[AC_CACHE_CHECK([for sys_nerr], pgac_cv_var_sys_nerr,
[AC_TRY_LINK([extern int sys_nerr;
int x;],
[x = sys_nerr;],
[pgac_cv_var_sys_nerr=yes],
[pgac_cv_var_sys_nerr=no])])
if test x"$pgac_cv_var_sys_nerr" = xyes ; then
AC_DEFINE(HAVE_SYS_NERR,, [Set to 1 if you have the global variable sys_nerr])
fi])# PGAC_VAR_SYS_NERR
This diff is collapsed.
......@@ -944,8 +944,6 @@ if test x"$pgac_cv_var_int_optreset" = x"yes"; then
AC_DEFINE(HAVE_INT_OPTRESET, 1)
fi
PGAC_VAR_SYS_NERR
dnl Check to see if we have a working 64-bit integer type.
dnl This breaks down into two steps:
dnl (1) figure out if the compiler has a 64-bit int type with working
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.78 2001/01/21 00:59:26 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.79 2001/01/22 23:28:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -43,10 +43,6 @@
extern int errno;
#ifdef HAVE_SYS_NERR
extern int sys_nerr;
#endif
extern CommandDest whereToSendOutput;
#ifdef ENABLE_SYSLOG
......@@ -139,14 +135,7 @@ elog(int lev, const char *fmt, ...)
return; /* ignore debug msgs if noplace to send */
/* Save error str before calling any function that might change errno */
if (errno >= 0
#ifdef HAVE_SYS_NERR
&& errno <= sys_nerr
#endif
)
errorstr = strerror(errno);
else
errorstr = NULL;
/*
* Some strerror()s return an empty string for out-of-range errno.
* This is ANSI C spec compliant, but not exactly useful.
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.34 2001/01/21 00:59:26 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.35 2001/01/22 23:28:52 tgl Exp $
*
* NOTE
* XXX this code needs improvement--check for state violations and
......@@ -26,10 +26,6 @@
extern int errno;
#ifdef HAVE_SYS_NERR
extern int sys_nerr;
#endif
static void ExcUnCaught(Exception *excP, ExcDetail detail, ExcData data,
ExcMessage message);
......@@ -115,14 +111,7 @@ ExcPrint(Exception *excP,
#endif
/* Save error str before calling any function that might change errno */
if (errno >= 0
#ifdef HAVE_SYS_NERR
&& errno <= sys_nerr
#endif
)
errorstr = strerror(errno);
else
errorstr = NULL;
/*
* Some strerror()s return an empty string for out-of-range errno.
* This is ANSI C spec compliant, but not exactly useful.
......
......@@ -8,7 +8,7 @@
* or in config.h afterwards. Of course, if you edit config.h, then your
* changes will be overwritten the next time you run configure.
*
* $Id: config.h.in,v 1.156 2001/01/19 23:43:35 petere Exp $
* $Id: config.h.in,v 1.157 2001/01/22 23:28:52 tgl Exp $
*/
#ifndef CONFIG_H
......@@ -617,9 +617,6 @@ extern void srandom(unsigned int seed);
/* Define if you have the optreset variable */
#undef HAVE_INT_OPTRESET
/* Define if you have the sys_nerr global variable */
#undef HAVE_SYS_NERR
/* Define if you have strtoll() */
#undef HAVE_STRTOLL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment