From 46d58fba3309d435bca93b1706603d1bab5a0512 Mon Sep 17 00:00:00 2001
From: Bryan Henderson <bryanh@giraffe.netgate.net>
Date: Tue, 26 Nov 1996 03:20:35 +0000
Subject: [PATCH] Make it compile on Ultrix.  Thanks Erik Bertelson.

---
 src/backend/parser/analyze.c           | 4 +++-
 src/backend/parser/catalog_utils.c     | 4 +++-
 src/backend/port/Makefile              | 7 ++++++-
 src/backend/port/inet_aton.c           | 1 +
 src/backend/port/ultrix4/dl.h          | 3 ++-
 src/backend/port/ultrix4/dynloader.c   | 3 ++-
 src/backend/port/ultrix4/port-protos.h | 8 ++++----
 src/backend/port/ultrix4/strdup.c      | 8 ++++++--
 src/backend/utils/mmgr/palloc.c        | 5 ++++-
 src/bin/pg4_dump/Makefile              | 2 +-
 src/bin/pg4_dump/common.c              | 1 +
 src/bin/pg4_dump/pg4_dump.c            | 1 +
 src/bin/pg_dump/Makefile               | 4 +++-
 src/bin/pg_dump/common.c               | 3 ++-
 src/bin/pg_dump/pg_dump.c              | 3 ++-
 src/bin/pg_dump/pg_dump.h              | 3 +--
 src/bin/psql/Makefile                  | 5 +++--
 src/bin/psql/psql.c                    | 4 ++--
 src/bin/psql/stringutils.c             | 5 ++++-
 src/bin/psql/stringutils.h             | 7 +------
 src/include/regex/utils.h              | 2 ++
 src/include/utils/dynamic_loader.h     | 4 +++-
 src/include/utils/palloc.h             | 4 +++-
 src/interfaces/libpq/Makefile          | 6 +++---
 src/interfaces/libpq/fe-connect.c      | 5 +++--
 25 files changed, 66 insertions(+), 36 deletions(-)

diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 874023c1872..9704b94965e 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.15 1996/11/13 20:48:55 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.16 1996/11/26 03:17:45 bryanh Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -37,6 +37,8 @@
 #include "optimizer/clauses.h"
 #include "access/heapam.h"
 
+#include "port-protos.h"        /* strdup() */
+
 /* convert the parse tree into a query tree */
 static Query *transformStmt(ParseState *pstate, Node *stmt);
 
diff --git a/src/backend/parser/catalog_utils.c b/src/backend/parser/catalog_utils.c
index 20206e01341..91a744beb77 100644
--- a/src/backend/parser/catalog_utils.c
+++ b/src/backend/parser/catalog_utils.c
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.10 1996/11/13 20:48:58 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.11 1996/11/26 03:17:47 bryanh Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -48,6 +48,8 @@
 #include "utils/lsyscache.h"
 #include "storage/lmgr.h"
 
+#include "port-protos.h"              /* strdup() */
+
 struct {
     char *field;
     int code;
diff --git a/src/backend/port/Makefile b/src/backend/port/Makefile
index 54c4482c432..8969d82c1c2 100644
--- a/src/backend/port/Makefile
+++ b/src/backend/port/Makefile
@@ -19,7 +19,7 @@
 # be converted to Method 2.  
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.4 1996/11/10 03:13:27 bryanh Exp $
+#    $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.5 1996/11/26 03:18:38 bryanh Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -36,6 +36,11 @@ ifeq ($(PORTNAME), sparc_solaris)
 OBJS += inet_aton.o
 endif
 
+ifeq ($(PORTNAME), ultrix4)
+# Other ports get the inet_aton() function from their standard C libraries.
+OBJS += inet_aton.o
+endif
+
 all: submake SUBSYS.o
 
 SUBSYS.o: $(OBJS)
diff --git a/src/backend/port/inet_aton.c b/src/backend/port/inet_aton.c
index 1b08e7eaa7b..37c11b621b7 100644
--- a/src/backend/port/inet_aton.c
+++ b/src/backend/port/inet_aton.c
@@ -42,6 +42,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.  */
 
+#include <sys/types.h>
 #include <netinet/in.h>
 #include <ctype.h>
 #include "inet_aton.h"
diff --git a/src/backend/port/ultrix4/dl.h b/src/backend/port/ultrix4/dl.h
index 883a6833248..7855db38f30 100644
--- a/src/backend/port/ultrix4/dl.h
+++ b/src/backend/port/ultrix4/dl.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: dl.h,v 1.2 1996/11/14 20:08:57 scrappy Exp $
+ * $Id: dl.h,v 1.3 1996/11/26 03:18:46 bryanh Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -34,6 +34,7 @@
 #ifndef _DL_HEADER_
 #define _DL_HEADER_
 
+#include <stdio.h> /* needed to declare FILE for ldfcn.h */
 #include <filehdr.h>
 #include <syms.h>
 #include <ldfcn.h>
diff --git a/src/backend/port/ultrix4/dynloader.c b/src/backend/port/ultrix4/dynloader.c
index dc526885caa..1acc54260a1 100644
--- a/src/backend/port/ultrix4/dynloader.c
+++ b/src/backend/port/ultrix4/dynloader.c
@@ -9,13 +9,14 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/dynloader.c,v 1.2 1996/11/14 20:08:58 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/dynloader.c,v 1.3 1996/11/26 03:18:50 bryanh Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include <stdio.h>
 #include <postgres.h>
 #include "dl.h"
+#include <utils/dynamic_loader.h>
 #include "c.h"
 #include "fmgr.h"
 #include "port-protos.h"
diff --git a/src/backend/port/ultrix4/port-protos.h b/src/backend/port/ultrix4/port-protos.h
index ed055dd19c0..ea313040d96 100644
--- a/src/backend/port/ultrix4/port-protos.h
+++ b/src/backend/port/ultrix4/port-protos.h
@@ -6,16 +6,13 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: port-protos.h,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $
+ * $Id: port-protos.h,v 1.2 1996/11/26 03:18:58 bryanh Exp $
  *
  *-------------------------------------------------------------------------
  */
 #ifndef PORT_PORTOS_H
 #define PORT_PORTOS_H
 
-#include "utils/dynamic_loader.h"
-#include "dl.h"
-
 /* dynloader.c */
 /*
  * New dynamic loader.
@@ -33,4 +30,7 @@
 
 extern void init_address_fixup(void);
 
+/* strdup.c: strdup() is not part of libc on Ultrix */
+extern char* strdup(char const*);
+
 #endif 	/* PORT_PORTOS_H */
diff --git a/src/backend/port/ultrix4/strdup.c b/src/backend/port/ultrix4/strdup.c
index f140711226e..882f0047e63 100644
--- a/src/backend/port/ultrix4/strdup.c
+++ b/src/backend/port/ultrix4/strdup.c
@@ -7,14 +7,18 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/strdup.c,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/strdup.c,v 1.2 1996/11/26 03:19:04 bryanh Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include <string.h>
 
+#include <utils/palloc.h>
+
+#include "port-protos.h"
+
 char *
-strdup(char *string)
+strdup(char const *string)
 {
     char *nstr;
 
diff --git a/src/backend/utils/mmgr/palloc.c b/src/backend/utils/mmgr/palloc.c
index c3b9ec77ccc..8830a21f40a 100644
--- a/src/backend/utils/mmgr/palloc.c
+++ b/src/backend/utils/mmgr/palloc.c
@@ -7,10 +7,13 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.2 1996/11/24 04:44:17 bryanh Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.3 1996/11/26 03:19:12 bryanh Exp $
  *
  *-------------------------------------------------------------------------
  */
+
+#include <string.h>
+
 #include "c.h"
 
 #include "utils/mcxt.h"
diff --git a/src/bin/pg4_dump/Makefile b/src/bin/pg4_dump/Makefile
index 286f96ea299..74136f2de7f 100644
--- a/src/bin/pg4_dump/Makefile
+++ b/src/bin/pg4_dump/Makefile
@@ -4,7 +4,7 @@
 
 .include <postgres.global.mk>
 
-CFLAGS+= -I${.CURDIR}/../../backend/tmp
+CFLAGS+= -I${.CURDIR}/../../backend/tmp -I${.CURDIR}/../../backend/port/${PORTNAME}
 
 PROG= pg4_dump
 
diff --git a/src/bin/pg4_dump/common.c b/src/bin/pg4_dump/common.c
index caa941b5718..408a4a7fe62 100644
--- a/src/bin/pg4_dump/common.c
+++ b/src/bin/pg4_dump/common.c
@@ -23,6 +23,7 @@
 #include "postgres.h"
 #include "libpq-fe.h"
 #include "libpq/auth.h"
+#include <port-protos.h> /* for strdup () *(
 
 #include "pg_dump.h"
 
diff --git a/src/bin/pg4_dump/pg4_dump.c b/src/bin/pg4_dump/pg4_dump.c
index 6f484d48c64..dad51dc9d66 100644
--- a/src/bin/pg4_dump/pg4_dump.c
+++ b/src/bin/pg4_dump/pg4_dump.c
@@ -36,6 +36,7 @@
 #include "tmp/postgres.h"
 #include "tmp/libpq-fe.h"
 #include "libpq/auth.h"
+#include <port-protos.h> /* for strdup () */
 
 #include "pg_dump.h"
 
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index 9028cd4fb48..8faf2235c78 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/Makefile
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.8 1996/11/12 06:10:37 bryanh Exp $
+#    $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.9 1996/11/26 03:19:36 bryanh Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -15,6 +15,8 @@ SRCDIR= ../..
 include ../Makefile.global
 include ../../Makefile.global
 
+CFLAGS+= -I../../backend/port/${PORTNAME}
+
 OBJS= pg_dump.o common.o
 
 all: submake pg_dump
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index ac03f9e2e17..c5c750f0d7b 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.7 1996/11/04 03:59:53 momjian Exp $
+ *    $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.8 1996/11/26 03:19:40 bryanh Exp $
  *
  * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
  *
@@ -29,6 +29,7 @@
 
 #include "postgres.h"
 #include "libpq-fe.h"
+#include <port-protos.h> /* for strdup() */
 
 #include "pg_dump.h"
 
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 1a52c41457d..28eba535809 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -20,7 +20,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.16 1996/11/20 22:32:55 momjian Exp $
+ *    $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.17 1996/11/26 03:19:45 bryanh Exp $
  *
  * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
  *
@@ -54,6 +54,7 @@
 #include "postgres.h"
 #include "access/htup.h"
 #include "libpq-fe.h"
+#include <port-protos.h> /* for strdup() */
 
 #include "pg_dump.h"
 
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 2db57cb7f64..d6d5c301eb4 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -5,7 +5,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_dump.h,v 1.7 1996/10/07 03:30:40 scrappy Exp $
+ * $Id: pg_dump.h,v 1.8 1996/11/26 03:19:49 bryanh Exp $
  *
  * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
  *
@@ -158,7 +158,6 @@ extern void flagInhAttrs(TableInfo* tbinfo, int numTables,
 			   InhInfo* inhinfo, int numInherits);
 
 extern void check_conn_and_db(void);
-extern char* dupstr(const char *s);
 extern int strInArray(const char* pattern, char** arr, int arr_size);
 extern void parseArgTypes(char **argtypes, const char* str);
 extern int isArchiveName(const char*);
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index c0a8ff9afc0..30c3b229bc8 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/psql/Makefile,v 1.13 1996/11/13 10:35:26 bryanh Exp $
+#    $Header: /cvsroot/pgsql/src/bin/psql/Makefile,v 1.14 1996/11/26 03:19:54 bryanh Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -16,7 +16,8 @@ include ../../Makefile.global
 
 INCLUDE_OPT:= \
                -I$(LIBPQDIR) \
-               -I../../include
+               -I../../include \
+               -I../../backend/port/$(PORTNAME)
 
 CFLAGS+= $(INCLUDE_OPT)
 #
diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c
index 5d0ce15fe37..8202d6db7b4 100644
--- a/src/bin/psql/psql.c
+++ b/src/bin/psql/psql.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.33 1996/11/24 04:44:24 bryanh Exp $
+ *    $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.34 1996/11/26 03:19:58 bryanh Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -23,8 +23,8 @@
 #include "postgres.h"
 #include "libpq-fe.h"
 #include "stringutils.h"
-
 #include "psqlHelp.h"
+#include <port-protos.h> /* for strdup() */
 
 #ifdef NOREADLINE
 #include "rlstubs.h"
diff --git a/src/bin/psql/stringutils.c b/src/bin/psql/stringutils.c
index 870bfdefe05..5d209ec859a 100644
--- a/src/bin/psql/stringutils.c
+++ b/src/bin/psql/stringutils.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.5 1996/11/14 16:08:05 momjian Exp $
+ *    $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.6 1996/11/26 03:20:06 bryanh Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -15,6 +15,9 @@
 #include <string.h>
 #include <ctype.h>
 #include <stdlib.h>
+
+#include <port-protos.h> /* for strdup() */
+
 #include "stringutils.h"
 
 /* all routines assume null-terminated strings! */
diff --git a/src/bin/psql/stringutils.h b/src/bin/psql/stringutils.h
index f5140469d68..11da94449ea 100644
--- a/src/bin/psql/stringutils.h
+++ b/src/bin/psql/stringutils.h
@@ -5,7 +5,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: stringutils.h,v 1.2 1996/07/28 07:08:15 scrappy Exp $
+ * $Id: stringutils.h,v 1.3 1996/11/26 03:20:08 bryanh Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -31,11 +31,6 @@ extern char *leftTrim(char *s);
 extern char *rightTrim(char *s);
 extern char *doubleTrim(char *s);
 
-/* dupstr : copies a string, while making room for it */
-/* the CALLER is responsible for freeing the space */
-/* returns NULL if the argument is NULL */
-extern char *dupstr(char *s);
-
 #ifdef STRINGUTILS_TEST
 extern void testStringUtils();
 #endif
diff --git a/src/include/regex/utils.h b/src/include/regex/utils.h
index e2d8b6cda36..98857d0977c 100644
--- a/src/include/regex/utils.h
+++ b/src/include/regex/utils.h
@@ -37,6 +37,8 @@
  *	@(#)utils.h	8.3 (Berkeley) 3/20/94
  */
 
+#include "config.h"  /* HAVE_MEMMOVE */
+
 /* utility definitions */
 #define	DUPMAX		100000000	/* xxx is this right? */
 #define	INFINITY	(DUPMAX + 1)
diff --git a/src/include/utils/dynamic_loader.h b/src/include/utils/dynamic_loader.h
index f79c732eb40..f4f9c7163b9 100644
--- a/src/include/utils/dynamic_loader.h
+++ b/src/include/utils/dynamic_loader.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: dynamic_loader.h,v 1.2 1996/11/04 08:14:05 scrappy Exp $
+ * $Id: dynamic_loader.h,v 1.3 1996/11/26 03:20:17 bryanh Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -15,6 +15,8 @@
 
 #include <sys/types.h>
 
+#include <postgres.h>
+
 #ifdef MIN
 #undef MIN
 #undef MAX
diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h
index 03767ce8a8e..02c7b9ab257 100644
--- a/src/include/utils/palloc.h
+++ b/src/include/utils/palloc.h
@@ -6,13 +6,15 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: palloc.h,v 1.2 1996/10/31 09:51:28 scrappy Exp $
+ * $Id: palloc.h,v 1.3 1996/11/26 03:20:23 bryanh Exp $
  *
  *-------------------------------------------------------------------------
  */
 #ifndef	PALLOC_H
 #define PALLOC_H
 
+#include <c.h>
+
 extern void*   palloc(Size size);
 extern void    pfree(void *pointer); 
 extern void *repalloc(void *pointer, Size size);
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index af39505743e..52f9a058d60 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.18 1996/11/17 19:27:38 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.19 1996/11/26 03:20:33 bryanh Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -15,7 +15,7 @@ SRCDIR= ..
 include ../Makefile.global
 
 # We need the backend directory here for its fmgr.h
-INCLUDE_OPT= -I../include -I../backend
+INCLUDE_OPT= -I../include -I../backend -I../backend/port/$(PORTNAME)
 
 CFLAGS+= $(INCLUDE_OPT) 
 
@@ -73,7 +73,7 @@ postgres.h: ../include/postgres.h
 	echo "#define NAMEDATALEN $(NAMEDATALEN)" >> postgres.h
 	echo "#define OIDNAMELEN $(OIDNAMELEN)" >> postgres.h
 	cat ../include/postgres.h >> postgres.h
-	
+
 c.h: ../include/c.h
 	rm -f c.h
 	echo "#undef PORTNAME" >  c.h
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 88e2c294ad8..696065a3ff9 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.19 1996/11/14 10:25:50 bryanh Exp $
+ *    $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.20 1996/11/26 03:20:35 bryanh Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -30,11 +30,12 @@
 #include "fe-auth.h"
 #include "libpq-fe.h"
 
+#include <port-protos.h>  /* for strdup() */
+
 #if defined(ultrix4) || defined(next)
   /* ultrix is lame and doesn't have strdup in libc for some reason */
  /* [TRH] So doesn't NEXTSTEP.  But whaddaya expect for a non-ANSI  
 standard function? (My, my. Touchy today, are we?) */
-static
 char *
 strdup(const char *string)
 {
-- 
GitLab