From 7d32551a81adcda190e1754fefed05acdbf49101 Mon Sep 17 00:00:00 2001
From: Michael Meskes <meskes@postgresql.org>
Date: Thu, 17 Jul 2003 07:54:29 +0000
Subject: [PATCH] Fixed some bugs in Informix compat functions.

---
 src/interfaces/ecpg/compatlib/informix.c  | 14 ++++++++++++--
 src/interfaces/ecpg/ecpglib/misc.c        |  4 ++--
 src/interfaces/ecpg/pgtypeslib/datetime.c |  6 +++---
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c
index d60019f68f9..807349fd835 100644
--- a/src/interfaces/ecpg/compatlib/informix.c
+++ b/src/interfaces/ecpg/compatlib/informix.c
@@ -443,7 +443,12 @@ rtoday (Date *d)
 int
 rjulmdy (Date d, short mdy[3])
 {
-	PGTYPESdate_julmdy(d, (int *)mdy);
+	int mdy_int[3];
+	
+	PGTYPESdate_julmdy(d, mdy_int);
+	mdy[0] = (short)mdy_int[0];
+	mdy[1] = (short)mdy_int[1];
+	mdy[2] = (short)mdy_int[2];
 	return 0;
 }
 
@@ -482,7 +487,12 @@ rfmtdate (Date d, char *fmt, char *str)
 int
 rmdyjul (short mdy[3], Date *d)
 {
-	PGTYPESdate_mdyjul((int *)mdy, d);
+	int mdy_int[3];
+
+	mdy_int[0] = mdy[0];
+	mdy_int[1] = mdy[1];
+	mdy_int[2] = mdy[2];
+	PGTYPESdate_mdyjul(mdy_int, d);
 	return 0;
 }
 
diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c
index 6c9bd208c7b..b9e0c35d0ca 100644
--- a/src/interfaces/ecpg/ecpglib/misc.c
+++ b/src/interfaces/ecpg/ecpglib/misc.c
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.9 2003/07/01 12:40:51 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.10 2003/07/17 07:54:29 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -308,7 +308,7 @@ ECPGset_informix_null(enum ECPGttype type, void *ptr)
 
 static bool _check(unsigned char *ptr, int length)
 {
-	for (;ptr[length] == 0xff && length >= 0; length --);
+	for (;ptr[--length] == 0xff && length >= 0; length --);
 	if (length < 0) return true;
 	return false;
 }
diff --git a/src/interfaces/ecpg/pgtypeslib/datetime.c b/src/interfaces/ecpg/pgtypeslib/datetime.c
index d9ca8708734..9e8becbda79 100644
--- a/src/interfaces/ecpg/pgtypeslib/datetime.c
+++ b/src/interfaces/ecpg/pgtypeslib/datetime.c
@@ -101,9 +101,9 @@ PGTYPESdate_julmdy(Date jd, int* mdy)
 	int y, m, d;
 	
 	j2date((int) jd, &y, &m, &d);
-	mdy[0] = (short int) m;
-	mdy[1] = (short int) d;
-	mdy[2] = (short int) y;
+	mdy[0] = m;
+	mdy[1] = d;
+	mdy[2] = y;
 }
 
 void
-- 
GitLab