mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Add a check for strerr, and add in D'Arcy's strerror() code in case not
found
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
# be converted to Method 2.
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/backend/port/Attic/Makefile.in,v 1.2 1997/02/28 10:57:47 momjian Exp $
|
||||
# $Header: /cvsroot/pgsql/src/backend/port/Attic/Makefile.in,v 1.3 1997/03/19 02:33:29 scrappy Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -31,7 +31,7 @@ ifndef PORTNAME
|
||||
@false
|
||||
else
|
||||
|
||||
OBJS = $(PORTNAME)/SUBSYS.o @INET_ATON@
|
||||
OBJS = $(PORTNAME)/SUBSYS.o @INET_ATON@ @STRERROR@
|
||||
|
||||
all: submake SUBSYS.o
|
||||
|
||||
|
||||
30
src/backend/port/strerror.c
Normal file
30
src/backend/port/strerror.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* strerror - map error number to descriptive string
|
||||
*
|
||||
* This version is obviously somewhat Unix-specific.
|
||||
*
|
||||
* based on code by Henry Spencer
|
||||
* modified for ANSI by D'Arcy J.M. Cain
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
extern const char * const sys_errlist[];
|
||||
extern int sys_nerr;
|
||||
|
||||
const char *
|
||||
strerror(int errnum)
|
||||
{
|
||||
static char buf[24];
|
||||
|
||||
if (errnum < 0 || errnum > sys_nerr)
|
||||
{
|
||||
sprintf(buf, "unknown error %d", errnum);
|
||||
return(buf);
|
||||
}
|
||||
|
||||
return(sys_errlist[errnum]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user