From ba34215269934c2a772548af2e3a59dc15daa88c Mon Sep 17 00:00:00 2001
From: Michael Meskes <meskes@postgresql.org>
Date: Wed, 26 Nov 2008 15:35:30 +0000
Subject: [PATCH] Removed strchrnul

---
 src/interfaces/ecpg/preproc/type.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c
index bea5a88e79c..5599d214c83 100644
--- a/src/interfaces/ecpg/preproc/type.c
+++ b/src/interfaces/ecpg/preproc/type.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.80 2008/11/26 13:18:22 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.81 2008/11/26 15:35:30 meskes Exp $ */
 
 #include "postgres_fe.h"
 
@@ -329,7 +329,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
 	{
 		char *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
 		char *offset = (char *) mm_alloc(strlen(name) + strlen("sizeof(struct varchar_)") + 1 + strlen(varcharsize) + sizeof(int) * CHAR_BIT * 10 / 3);
-		char *var_name; 
+		char *var_name, *ptr; 
 
 		switch (type)
 		{
@@ -352,8 +352,9 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
 					sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
 
 				/* remove trailing [] is name is array element */
-				var_name = strdup(name);
-				*(strchrnul(var_name, '[')) = '\0';
+				var_name = mm_strdup(name);
+				ptr = strchr(var_name, '[');
+				if (ptr) *ptr = '\0';
 				if (lineno)
 					sprintf(offset, "sizeof(struct varchar_%s_%d)", var_name, lineno);
 				else
-- 
GitLab