*** src/backend/utils/error/elog.c.orig Sun Oct 8 08:00:18 2000 --- src/backend/utils/error/elog.c Wed Oct 25 16:55:50 2000 *************** *** 37,49 **** #include "tcop/tcopprot.h" #include "commands/copy.h" - extern int errno; - - #ifdef __CYGWIN__ - # define sys_nerr _sys_nerr - #endif - extern int sys_nerr; - extern CommandDest whereToSendOutput; #ifdef ENABLE_SYSLOG --- 37,42 ---- *************** *** 130,152 **** int len; /* size of the prefix needed for timestamp and pid, if enabled */ size_t timestamp_size; if (lev <= DEBUG && Debugfile < 0) return; /* ignore debug msgs if noplace to send */ ! /* BeOS doesn't have sys_nerr and should be able to use strerror()... */ ! #ifndef __BEOS__ ! /* save errno string for %m */ ! if (errno < sys_nerr && errno >= 0) ! errorstr = strerror(errno); ! else { ! sprintf(errorstr_buf, "error %d", errno); errorstr = errorstr_buf; } - #else - errorstr = strerror(errno); - #endif /* __BEOS__ */ if (lev == ERROR || lev == FATAL) { --- 123,151 ---- int len; /* size of the prefix needed for timestamp and pid, if enabled */ size_t timestamp_size; + int errno_copy = errno; if (lev <= DEBUG && Debugfile < 0) return; /* ignore debug msgs if noplace to send */ ! /* ! * save errno string for %m ! * Standard UNIX (XPG4v2/UNIX95 and later) says that errno will be set ! * (to EINVAL) if the argument to strerror() is out of range. ! * IRIX and Solaris actually return NULL without setting errno. ! * Others such as AIX, Cygwin and Linux return a string for all values. ! * This string contains a number for out of range values. ! * HPUX and QNX return the same string for all out of range values. ! * Those will not be well served by this code. However it is highly ! * unlikely that this code will be called with an out of range errno. ! */ ! errno = 0; ! errorstr = strerror(errno_copy); ! if (errno != 0 || errorstr == NULL) { ! sprintf(errorstr_buf, "error %d", errno_copy); errorstr = errorstr_buf; } if (lev == ERROR || lev == FATAL) { *** src/backend/utils/error/exc.c.orig Tue Oct 3 08:00:18 2000 --- src/backend/utils/error/exc.c Wed Oct 25 16:37:39 2000 *************** *** 94,106 **** ExceptionHandlingEnabled = on; } - - extern int errno; - #ifdef __CYGWIN__ - # define sys_nerr _sys_nerr - #endif - extern int sys_nerr; - static void ExcPrint(Exception *excP, ExcDetail detail, --- 94,99 ---- *************** *** 107,112 **** --- 100,108 ---- ExcData data, ExcMessage message) { + int errno_copy = errno; + const char *errorstr; + #ifdef lint data = data; #endif *************** *** 131,144 **** fprintf(stderr, " (%ld)", detail); ! #ifndef __BEOS__ ! if (errno > 0 && errno < sys_nerr) ! #else ! if (errno > 0) ! #endif ! fprintf(stderr, " [%s]", strerror(errno)); ! else if (errno != 0) ! fprintf(stderr, " [Error %d]", errno); fprintf(stderr, "\n"); --- 127,140 ---- fprintf(stderr, " (%ld)", detail); ! if (errno_copy != 0) { ! errno = 0; ! errorstr = strerror(errno_copy); ! if (errno == 0 && errorstr != NULL) ! fprintf(stderr, " [Error %d: %s]", errno_copy, errorstr); ! else if (errno_copy != 0) ! fprintf(stderr, " [Error %d]", errno_copy); ! } fprintf(stderr, "\n");