From 3f03f74f3651cd2ded9899f5aa2a928ca8e0d480 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Mon, 10 Jan 2000 15:41:34 +0000
Subject: [PATCH] Update int28out and out8out and _in_ functions to handle
 trailing zeros properly.

---
 src/backend/utils/adt/int.c          | 39 ++++++++++++++++++----------
 src/backend/utils/adt/oid.c          | 32 +++++++++++++++--------
 src/interfaces/ecpg/lib/Makefile.in  |  4 +--
 src/interfaces/ecpg/preproc/Makefile |  2 +-
 src/interfaces/libpgeasy/Makefile.in |  4 +--
 src/interfaces/libpgtcl/Makefile.in  |  4 +--
 src/interfaces/libpq++/Makefile.in   |  4 +--
 src/interfaces/libpq/Makefile.in     |  4 +--
 src/interfaces/odbc/Version.mk       |  4 +--
 src/tools/RELEASE_CHANGES            |  1 +
 10 files changed, 60 insertions(+), 38 deletions(-)

diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c
index e5cc5551638..6c3c64c993e 100644
--- a/src/backend/utils/adt/int.c
+++ b/src/backend/utils/adt/int.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.29 2000/01/10 05:23:47 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.30 2000/01/10 15:41:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -29,6 +29,7 @@
  * fix me when we figure out what we want to do about ANSIfication...
  */
 
+#include <ctype.h>
 #include "postgres.h"
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
@@ -90,10 +91,15 @@ int28in(char *intString)
 	{
 		if (sscanf(intString, "%hd", &result[slot]) != 1)
 			break;
-		do
+		while (*intString && isspace(*intString))
+			intString++;
+		while (*intString && !isspace(*intString))
 			intString++;
-		while (*intString && *intString != ' ')
 	}
+	while (*intString && isspace(*intString))
+		intString++;
+	if (*intString)
+		elog(ERROR,"int28 value has too many values");
 	while (slot < INDEX_MAX_KEYS)
 		result[slot++] = 0;
 
@@ -104,31 +110,36 @@ int28in(char *intString)
  *		int28out		- converts internal form to "num num ..."
  */
 char *
-int28out(int16 *shs)
+int28out(int16 *int2Array)
 {
-	int			num;
-	int16	   *sp;
+	int			num, maxnum;
 	char	   *rp;
 	char	   *result;
 
-	if (shs == NULL)
+	if (int2Array == NULL)
 	{
 		result = (char *) palloc(2);
 		result[0] = '-';
 		result[1] = '\0';
 		return result;
 	}
-	rp = result = (char *) palloc(INDEX_MAX_KEYS * 7);
-							/* assumes sign, 5 digits, ' ' */
-	sp = shs;
-	for (num = INDEX_MAX_KEYS; num != 0; num--)
+
+	/* find last non-zero value in vector */
+	for (maxnum = INDEX_MAX_KEYS-1; maxnum >= 0; maxnum--)
+		if (int2Array[maxnum] != 0)
+			break;
+
+	/* assumes sign, 5 digits, ' ' */
+	rp = result = (char *) palloc(maxnum * 7 + 1);
+	for (num = 0; num <= maxnum; num++)
 	{
-		itoa(*sp++, rp);
+		if (num != 0)
+			*rp++ = ' ';
+		ltoa(int2Array[num], rp);
 		while (*++rp != '\0')
 			;
-		*rp++ = ' ';
 	}
-	*--rp = '\0';
+	*rp = '\0';
 	return result;
 }
 
diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c
index 4ffd0202810..989f4a602d9 100644
--- a/src/backend/utils/adt/oid.c
+++ b/src/backend/utils/adt/oid.c
@@ -7,12 +7,13 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.30 2000/01/10 05:23:47 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.31 2000/01/10 15:41:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 
+#include <ctype.h>
 #include "postgres.h"
 #include "utils/builtins.h"
 
@@ -41,10 +42,15 @@ oid8in(char *oidString)
 	{
 		if (sscanf(oidString, "%u", &result[slot]) != 1)
 			break;
-		do
+		while (*oidString && isspace(*oidString))
+			oidString++;
+		while (*oidString && !isspace(*oidString))
 			oidString++;
-		while (*oidString && *oidString != ' ')
 	}
+	while (*oidString && isspace(*oidString))
+		oidString++;
+	if (*oidString)
+		elog(ERROR,"oid8 value has too many values");
 	while (slot < INDEX_MAX_KEYS)
 		result[slot++] = 0;
 
@@ -57,8 +63,7 @@ oid8in(char *oidString)
 char *
 oid8out(Oid *oidArray)
 {
-	int			num;
-	Oid		   *sp;
+	int			num, maxnum;
 	char	   *rp;
 	char	   *result;
 
@@ -70,17 +75,22 @@ oid8out(Oid *oidArray)
 		return result;
 	}
 
+	/* find last non-zero value in vector */
+	for (maxnum = INDEX_MAX_KEYS-1; maxnum >= 0; maxnum--)
+		if (oidArray[maxnum] != 0)
+			break;
+
 	/* assumes sign, 10 digits, ' ' */
-	rp = result = (char *) palloc(INDEX_MAX_KEYS * 12);
-	sp = oidArray;
-	for (num = INDEX_MAX_KEYS; num != 0; num--)
+	rp = result = (char *) palloc(maxnum * 12 + 1);
+	for (num = 0; num <= maxnum; num++)
 	{
-		ltoa(*sp++, rp);
+		if (num != 0)
+			*rp++ = ' ';
+		ltoa(oidArray[num], rp);
 		while (*++rp != '\0')
 			;
-		*rp++ = ' ';
 	}
-	*--rp = '\0';
+	*rp = '\0';
 	return result;
 }
 
diff --git a/src/interfaces/ecpg/lib/Makefile.in b/src/interfaces/ecpg/lib/Makefile.in
index 2c74b31b04a..49f019659d3 100644
--- a/src/interfaces/ecpg/lib/Makefile.in
+++ b/src/interfaces/ecpg/lib/Makefile.in
@@ -6,13 +6,13 @@
 # Copyright (c) 1994, Regents of the University of California
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.54 1999/12/16 06:53:10 meskes Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.55 2000/01/10 15:41:27 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
 NAME= ecpg
 SO_MAJOR_VERSION= 3
-SO_MINOR_VERSION= 0.9
+SO_MINOR_VERSION= 1.0
 
 SRCDIR= @top_srcdir@
 include $(SRCDIR)/Makefile.global
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 4c07c576558..7d70b0f8cd7 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -2,7 +2,7 @@ SRCDIR= ../../..
 include $(SRCDIR)/Makefile.global
 
 MAJOR_VERSION=2
-MINOR_VERSION=6
+MINOR_VERSION=7
 PATCHLEVEL=14
 
 CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
diff --git a/src/interfaces/libpgeasy/Makefile.in b/src/interfaces/libpgeasy/Makefile.in
index 0988e3eb73d..46adbd683de 100644
--- a/src/interfaces/libpgeasy/Makefile.in
+++ b/src/interfaces/libpgeasy/Makefile.in
@@ -4,13 +4,13 @@
 #    Makefile for pgeasy library
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/libpgeasy/Attic/Makefile.in,v 1.4 1999/12/16 01:25:16 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/libpgeasy/Attic/Makefile.in,v 1.5 2000/01/10 15:41:28 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
 NAME= pgeasy
 SO_MAJOR_VERSION= 2
-SO_MINOR_VERSION= 0
+SO_MINOR_VERSION= 1
 
 SRCDIR= @top_srcdir@
 include $(SRCDIR)/Makefile.global
diff --git a/src/interfaces/libpgtcl/Makefile.in b/src/interfaces/libpgtcl/Makefile.in
index 5516f9dc17d..3b5f15b85a1 100644
--- a/src/interfaces/libpgtcl/Makefile.in
+++ b/src/interfaces/libpgtcl/Makefile.in
@@ -6,13 +6,13 @@
 # Copyright (c) 1994, Regents of the University of California
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/Makefile.in,v 1.37 1999/12/16 01:25:17 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/Makefile.in,v 1.38 2000/01/10 15:41:29 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
 NAME= pgtcl
 SO_MAJOR_VERSION= 2
-SO_MINOR_VERSION= 0
+SO_MINOR_VERSION= 1
 
 SRCDIR= @top_srcdir@
 include $(SRCDIR)/Makefile.global
diff --git a/src/interfaces/libpq++/Makefile.in b/src/interfaces/libpq++/Makefile.in
index e9d3aa5d1f5..b6f57dc8cf3 100644
--- a/src/interfaces/libpq++/Makefile.in
+++ b/src/interfaces/libpq++/Makefile.in
@@ -6,13 +6,13 @@
 # Copyright (c) 1994, Regents of the University of California
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/Makefile.in,v 1.19 1999/12/16 01:25:20 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/Makefile.in,v 1.20 2000/01/10 15:41:31 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
 NAME= pq++
 SO_MAJOR_VERSION= 3
-SO_MINOR_VERSION= 0
+SO_MINOR_VERSION= 1
 
 SRCDIR= @top_srcdir@
 include $(SRCDIR)/Makefile.global
diff --git a/src/interfaces/libpq/Makefile.in b/src/interfaces/libpq/Makefile.in
index 1d94ab826fd..1276f550a22 100644
--- a/src/interfaces/libpq/Makefile.in
+++ b/src/interfaces/libpq/Makefile.in
@@ -6,13 +6,13 @@
 # Copyright (c) 1994, Regents of the University of California
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.50 1999/12/16 01:25:19 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.51 2000/01/10 15:41:30 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
 NAME= pq
 SO_MAJOR_VERSION= 2
-SO_MINOR_VERSION= 0
+SO_MINOR_VERSION= 1
 
 SRCDIR= @top_srcdir@
 include $(SRCDIR)/Makefile.global
diff --git a/src/interfaces/odbc/Version.mk b/src/interfaces/odbc/Version.mk
index c927772c0bb..02f41ab98c3 100644
--- a/src/interfaces/odbc/Version.mk
+++ b/src/interfaces/odbc/Version.mk
@@ -1,5 +1,5 @@
-VERSION = 0.25
+VERSION = 0.26
 EXTVER  = .0
 
 SO_MAJOR_VERSION = 0
-SO_MINOR_VERSION = 25
+SO_MINOR_VERSION = 26
diff --git a/src/tools/RELEASE_CHANGES b/src/tools/RELEASE_CHANGES
index ce97b005e21..27e67c0fc7e 100644
--- a/src/tools/RELEASE_CHANGES
+++ b/src/tools/RELEASE_CHANGES
@@ -17,3 +17,4 @@ update documentation
 	psql help in psqlHelp.c
 	man pages
 	sgml docs
+update VERSION numbers of interfaces
-- 
GitLab