- Only use typedefs inside their scope.
- Variables that are out of scope, were not removed all the time. - Make a varchar NULL set everything to 0 when not using indicators.
This commit is contained in:
parent
46f2ee852b
commit
a3c695d0c2
@ -1,4 +1,4 @@
|
|||||||
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.16.2.1 2003/11/24 13:11:27 petere Exp $ */
|
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.16.2.2 2004/06/27 12:32:45 meskes Exp $ */
|
||||||
|
|
||||||
#define POSTGRES_ECPG_INTERNAL
|
#define POSTGRES_ECPG_INTERNAL
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
@ -296,6 +296,7 @@ ECPGset_informix_null(enum ECPGttype type, void *ptr)
|
|||||||
break;
|
break;
|
||||||
case ECPGt_varchar:
|
case ECPGt_varchar:
|
||||||
*(((struct ECPGgeneric_varchar *) ptr)->arr) = 0x00;
|
*(((struct ECPGgeneric_varchar *) ptr)->arr) = 0x00;
|
||||||
|
((struct ECPGgeneric_varchar *) ptr)->len = 0;
|
||||||
break;
|
break;
|
||||||
case ECPGt_decimal:
|
case ECPGt_decimal:
|
||||||
memset((char *) ptr, 0, sizeof(decimal));
|
memset((char *) ptr, 0, sizeof(decimal));
|
||||||
|
@ -82,6 +82,7 @@ extern struct typedefs *get_typedef(char *);
|
|||||||
extern void adjust_array(enum ECPGttype, char **, char **, char *, char *, int, bool);
|
extern void adjust_array(enum ECPGttype, char **, char **, char *, char *, int, bool);
|
||||||
extern void reset_variables(void);
|
extern void reset_variables(void);
|
||||||
extern void check_indicator(struct ECPGtype *);
|
extern void check_indicator(struct ECPGtype *);
|
||||||
|
extern void remove_typedefs(int);
|
||||||
extern void remove_variables(int);
|
extern void remove_variables(int);
|
||||||
extern struct variable *new_variable(const char *, struct ECPGtype *, int);
|
extern struct variable *new_variable(const char *, struct ECPGtype *, int);
|
||||||
extern ScanKeyword *ScanKeywordLookup(char *text);
|
extern ScanKeyword *ScanKeywordLookup(char *text);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.263.2.16 2004/06/17 11:52:59 meskes Exp $ */
|
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.263.2.17 2004/06/27 12:32:47 meskes Exp $ */
|
||||||
|
|
||||||
/* Copyright comment */
|
/* Copyright comment */
|
||||||
%{
|
%{
|
||||||
@ -575,7 +575,7 @@ statement: ecpgstart opt_at stmt ';' { connection = NULL; }
|
|||||||
| c_thing { fprintf(yyout, "%s", $1); free($1); }
|
| c_thing { fprintf(yyout, "%s", $1); free($1); }
|
||||||
| CPP_LINE { fprintf(yyout, "%s", $1); free($1); }
|
| CPP_LINE { fprintf(yyout, "%s", $1); free($1); }
|
||||||
| '{' { braces_open++; fputs("{", yyout); }
|
| '{' { braces_open++; fputs("{", yyout); }
|
||||||
| '}' { remove_variables(braces_open--); fputs("}", yyout); }
|
| '}' { remove_typedefs(braces_open); remove_variables(braces_open--); fputs("}", yyout); }
|
||||||
;
|
;
|
||||||
|
|
||||||
opt_at: AT connection_target
|
opt_at: AT connection_target
|
||||||
@ -4656,6 +4656,7 @@ type_declaration: S_TYPEDEF
|
|||||||
/* initial definition */
|
/* initial definition */
|
||||||
this->next = types;
|
this->next = types;
|
||||||
this->name = $5;
|
this->name = $5;
|
||||||
|
this->brace_level = braces_open;
|
||||||
this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
|
this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
|
||||||
this->type->type_enum = $3.type_enum;
|
this->type->type_enum = $3.type_enum;
|
||||||
this->type->type_str = mm_strdup($5);
|
this->type->type_str = mm_strdup($5);
|
||||||
@ -4974,6 +4975,7 @@ struct_union_type_with_symbol: s_struct_union_symbol
|
|||||||
/* initial definition */
|
/* initial definition */
|
||||||
this->next = types;
|
this->next = types;
|
||||||
this->name = mm_strdup(su_type.type_str);
|
this->name = mm_strdup(su_type.type_str);
|
||||||
|
this->brace_level = braces_open;
|
||||||
this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
|
this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
|
||||||
this->type->type_enum = su_type.type_enum;
|
this->type->type_enum = su_type.type_enum;
|
||||||
this->type->type_str = mm_strdup(su_type.type_str);
|
this->type->type_str = mm_strdup(su_type.type_str);
|
||||||
@ -5493,6 +5495,7 @@ ECPGTypedef: TYPE_P
|
|||||||
/* initial definition */
|
/* initial definition */
|
||||||
this->next = types;
|
this->next = types;
|
||||||
this->name = $3;
|
this->name = $3;
|
||||||
|
this->brace_level = braces_open;
|
||||||
this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
|
this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
|
||||||
this->type->type_enum = $5.type_enum;
|
this->type->type_enum = $5.type_enum;
|
||||||
this->type->type_str = mm_strdup($3);
|
this->type->type_str = mm_strdup($3);
|
||||||
|
@ -122,26 +122,27 @@ struct cursor
|
|||||||
|
|
||||||
struct typedefs
|
struct typedefs
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
struct this_type *type;
|
struct this_type *type;
|
||||||
struct ECPGstruct_member *struct_member_list;
|
struct ECPGstruct_member *struct_member_list;
|
||||||
struct typedefs *next;
|
int brace_level;
|
||||||
|
struct typedefs *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _defines
|
struct _defines
|
||||||
{
|
{
|
||||||
char *old;
|
char *old;
|
||||||
char *new;
|
char *new;
|
||||||
int pertinent;
|
int pertinent;
|
||||||
struct _defines *next;
|
struct _defines *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This is a linked list of the variable names and types. */
|
/* This is a linked list of the variable names and types. */
|
||||||
struct variable
|
struct variable
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
struct ECPGtype *type;
|
struct ECPGtype *type;
|
||||||
int brace_level;
|
int brace_level;
|
||||||
struct variable *next;
|
struct variable *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -275,13 +275,47 @@ find_variable(char *name)
|
|||||||
return (p);
|
return (p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
remove_typedefs(int brace_level)
|
||||||
|
{
|
||||||
|
struct typedefs *p,
|
||||||
|
*prev;
|
||||||
|
|
||||||
|
for (p = prev = types; p;)
|
||||||
|
{
|
||||||
|
if (p->brace_level >= brace_level)
|
||||||
|
{
|
||||||
|
/* remove it */
|
||||||
|
if (p == types)
|
||||||
|
prev = types = p->next;
|
||||||
|
else
|
||||||
|
prev->next = p->next;
|
||||||
|
|
||||||
|
if (p->type->type_enum == ECPGt_struct || p->type->type_enum == ECPGt_union)
|
||||||
|
free(p->struct_member_list);
|
||||||
|
free(p->type);
|
||||||
|
free(p->name);
|
||||||
|
free(p);
|
||||||
|
if (prev == types)
|
||||||
|
p = types;
|
||||||
|
else
|
||||||
|
p = prev ? prev->next : NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prev = p;
|
||||||
|
p = prev->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
remove_variables(int brace_level)
|
remove_variables(int brace_level)
|
||||||
{
|
{
|
||||||
struct variable *p,
|
struct variable *p,
|
||||||
*prev;
|
*prev;
|
||||||
|
|
||||||
for (p = prev = allvariables; p; p = p ? p->next : NULL)
|
for (p = prev = allvariables; p;)
|
||||||
{
|
{
|
||||||
if (p->brace_level >= brace_level)
|
if (p->brace_level >= brace_level)
|
||||||
{
|
{
|
||||||
@ -326,10 +360,16 @@ remove_variables(int brace_level)
|
|||||||
ECPGfree_type(p->type);
|
ECPGfree_type(p->type);
|
||||||
free(p->name);
|
free(p->name);
|
||||||
free(p);
|
free(p);
|
||||||
p = prev;
|
if (prev == allvariables)
|
||||||
|
p = allvariables;
|
||||||
|
else
|
||||||
|
p = prev ? prev->next : NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
prev = p;
|
prev = p;
|
||||||
|
p = prev->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user