aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/preproc/variable.c
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2003-06-11 06:39:13 +0000
committerMichael Meskes <meskes@postgresql.org>2003-06-11 06:39:13 +0000
commit1ca0b6d047a96a69800a0e00f3e61f148beed1db (patch)
tree54877902e8684e283cee258e2991336e2d5aae24 /src/interfaces/ecpg/preproc/variable.c
parent8de72414ea78cf765ccca89c11c4a0fc57e3a6a8 (diff)
downloadpostgresql-1ca0b6d047a96a69800a0e00f3e61f148beed1db.tar.gz
postgresql-1ca0b6d047a96a69800a0e00f3e61f148beed1db.zip
Make sure a variable is no longer referenced when it is removed.
Fixed counting bug in parsing "->" operator. Removed that silly debugging function I accidently committed last night.
Diffstat (limited to 'src/interfaces/ecpg/preproc/variable.c')
-rw-r--r--src/interfaces/ecpg/preproc/variable.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/interfaces/ecpg/preproc/variable.c b/src/interfaces/ecpg/preproc/variable.c
index 83b56ac9dc3..be96e18c0c5 100644
--- a/src/interfaces/ecpg/preproc/variable.c
+++ b/src/interfaces/ecpg/preproc/variable.c
@@ -137,7 +137,7 @@ find_struct(char *name, char *next, char *end)
/* restore the name, we will need it later */
*next = c;
- return find_struct_member(name, end, p->type->u.element->u.members, p->brace_level);
+ return find_struct_member(name, ++end, p->type->u.element->u.members, p->brace_level);
}
else
{
@@ -260,6 +260,37 @@ remove_variables(int brace_level)
{
if (p->brace_level >= brace_level)
{
+ /* is it still referenced by a cursor? */
+ struct cursor *ptr;
+
+ for (ptr = cur; ptr != NULL; ptr = ptr->next)
+ {
+ struct arguments *varptr, *prevvar;
+
+ for (varptr = prevvar = ptr->argsinsert; varptr != NULL; varptr = varptr->next)
+ {
+ if (p == varptr->variable)
+ {
+ /* remove from list */
+ if (varptr == ptr->argsinsert)
+ ptr->argsinsert = varptr->next;
+ else
+ prevvar->next = varptr->next;
+ }
+ }
+ for (varptr = ptr->argsresult; varptr != NULL; varptr = varptr->next)
+ {
+ if (p == varptr->variable)
+ {
+ /* remove from list */
+ if (varptr == ptr->argsresult)
+ ptr->argsresult = varptr->next;
+ else
+ prevvar->next = varptr->next;
+ }
+ }
+ }
+
/* remove it */
if (p == allvariables)
prev = allvariables = p->next;