From 54452833efced6473ec96ecce3848708d26335be Mon Sep 17 00:00:00 2001
From: Michael Meskes <meskes@postgresql.org>
Date: Mon, 7 Jan 2002 16:25:45 +0000
Subject: [PATCH] Fixed parser to accept initializing expressions starting with
 "(".

---
 src/interfaces/ecpg/ChangeLog          | 4 ++++
 src/interfaces/ecpg/preproc/preproc.y  | 8 ++++++++
 src/interfaces/ecpg/test/test1.pgc     | 3 +--
 src/interfaces/ecpg/test/test_init.pgc | 9 +++++----
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index 2c31f33000..976618ea92 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -1184,5 +1184,9 @@ Sun Dec 23 13:08:36 CET 2001
 
 	- Fixed several bugs concerning arrays of structs including a memory
 	  allocation bug.
+
+Mon Jan  7 12:18:01 CET 2002
+
+	- Fixed parser to accept initializing expressions starting with "(".
 	- Set ecpg version to 2.9.0.
         - Set library version to 3.3.0.
diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y
index d1d0f8db81..0da2234990 100644
--- a/src/interfaces/ecpg/preproc/preproc.y
+++ b/src/interfaces/ecpg/preproc/preproc.y
@@ -5389,6 +5389,14 @@ c_stuff: c_anything 	{ $$ = $1; }
 			{
 				$$ = cat_str(3, $1, make_str("("), make_str(")"));
 			}
+	| '(' c_stuff ')'
+			{
+				$$ = cat_str(3, make_str("("), $2, make_str(")"));
+			}
+	| '(' c_stuff ')' c_stuff
+			{
+				$$ = cat_str(4, make_str("("), $2, make_str(")"), $4);
+			}
 	;
 
 c_list: c_term			{ $$ = $1; }
diff --git a/src/interfaces/ecpg/test/test1.pgc b/src/interfaces/ecpg/test/test1.pgc
index c0b55b24b0..b5e745da8e 100644
--- a/src/interfaces/ecpg/test/test1.pgc
+++ b/src/interfaces/ecpg/test/test1.pgc
@@ -1,9 +1,8 @@
-
 #include <string.h>
 
 exec sql include sqlca;
 
-exec sql whenever sqlerror do PrintAndStop(msg);
+/* just a test comment */ exec sql whenever sqlerror do PrintAndStop(msg);
 exec sql whenever sqlwarning do warn();
 
 static void PrintAndStop(char *msg)
diff --git a/src/interfaces/ecpg/test/test_init.pgc b/src/interfaces/ecpg/test/test_init.pgc
index b8e16a9b2c..d5c7e74966 100644
--- a/src/interfaces/ecpg/test/test_init.pgc
+++ b/src/interfaces/ecpg/test/test_init.pgc
@@ -12,7 +12,8 @@ void sqlmeldung(char *meldung, short trans)
 {
 }
 
-#define NO 0
+exec sql define NONO 0;
+
 #define YES 1
 
 #ifdef _cplusplus
@@ -24,8 +25,9 @@ namespace N
 int main()
 { struct sa x,*y;
 exec sql begin declare section;
-int a=2;
+int a=(int)2;
 int b=2+2;
+int b2=(14*7);
 int d=x.member;
 int g=fb(2);
 int i=3^1;
@@ -38,7 +40,6 @@ long iay /* = 1L */ ;
 long long iax /* = 40000000000LL */ ;
 exec sql end declare section;
 
-/* not working */
 int f=fa();
 
 #ifdef _cplusplus
@@ -57,7 +58,7 @@ exec sql whenever sqlerror do fd("50",1);
 exec sql select now();
 exec sql whenever sqlerror do fe(ENUM0);
 exec sql select now();
-/* ex ec sql whenever sqlerror do sqlmeldung(NULL,NO); */
+exec sql whenever sqlerror do sqlmeldung(NULL, NONO); 
 exec sql select now();
 return 0;
 }
-- 
2.40.0