Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5a5f0a6

Browse files
author
Michael Meskes
committed
- Changed struct definition handling so "struct foo {}" always gets defined.
1 parent 2ec8ee0 commit 5a5f0a6

File tree

2 files changed

+45
-64
lines changed

2 files changed

+45
-64
lines changed

src/interfaces/ecpg/ChangeLog

+5
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,11 @@ Mon Sep 22 15:13:02 CEST 2003
16511651
- Fixed order mismatch in processing "using" arguments.
16521652
- Fixed some minor things in test cases.
16531653
- Use defines for Informix error codes.
1654+
1655+
Tue Sep 23 14:50:45 CEST 2003
1656+
1657+
- Changed struct definition handling so "struct foo {}" always gets
1658+
defined.
16541659
- Set ecpg version to 3.0.0
16551660
- Set ecpg library to 4.0.0
16561661
- Set pgtypes library to 1.0.0

src/interfaces/ecpg/preproc/preproc.y

+40-64
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.258 2003/09/22 13:19:39 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.259 2003/09/23 12:56:35 meskes Exp $ */
22

33
/* Copyright comment */
44
%{
@@ -540,7 +540,7 @@ add_additional_variables(char *name, bool insert)
540540
%type <str> col_name_keyword func_name_keyword precision opt_scale
541541
%type <str> ECPGTypeName using_list ECPGColLabelCommon UsingConst
542542
%type <str> inf_val_list inf_col_list using_descriptor into_descriptor
543-
%type <str> ecpg_into_using prepared_name
543+
%type <str> ecpg_into_using prepared_name struct_union_type_with_symbol
544544

545545
%type <struct_union> s_struct_union_symbol
546546

@@ -551,7 +551,6 @@ add_additional_variables(char *name, bool insert)
551551
%type <dtype_enum> descriptor_item desc_header_item
552552

553553
%type <type> var_type common_type single_vt_type
554-
%type <type> struct_union_type_with_symbol
555554

556555
%type <action> action
557556

@@ -4441,34 +4440,7 @@ single_var_declaration: storage_declaration
44414440
}
44424441
| struct_union_type_with_symbol ';'
44434442
{
4444-
/* this is essantially a typedef but needs the keyword struct/union as well */
4445-
struct typedefs *ptr, *this;
4446-
4447-
for (ptr = types; ptr != NULL; ptr = ptr->next)
4448-
{
4449-
if (strcmp($1.type_str, ptr->name) == 0)
4450-
{
4451-
/* re-definition is a bug */
4452-
snprintf(errortext, sizeof(errortext), "Type %s already defined", $1.type_str);
4453-
mmerror(PARSE_ERROR, ET_ERROR, errortext);
4454-
}
4455-
}
4456-
4457-
this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
4458-
4459-
/* initial definition */
4460-
this->next = types;
4461-
this->name = $1.type_str;
4462-
this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
4463-
this->type->type_enum = $1.type_enum;
4464-
this->type->type_str = mm_strdup($1.type_str);
4465-
this->type->type_dimension = make_str("-1"); /* dimension of array */
4466-
this->type->type_index = make_str("-1"); /* length of string */
4467-
this->type->type_sizeof = ECPGstruct_sizeof;
4468-
this->struct_member_list = struct_member_list[struct_level];
4469-
4470-
types = this;
4471-
$$ = cat2_str($1.type_sizeof, make_str(";"));
4443+
$$ = cat2_str($1, make_str(";"));
44724444
}
44734445
;
44744446

@@ -4658,6 +4630,7 @@ type_declaration: S_TYPEDEF
46584630
char * dimension = $6.index1;
46594631
char * length = $6.index2;
46604632

4633+
printf("MM: %s\n", $5);
46614634
if (($3.type_enum == ECPGt_struct ||
46624635
$3.type_enum == ECPGt_union) &&
46634636
initializer == 1)
@@ -4735,34 +4708,7 @@ var_declaration: storage_declaration
47354708
}
47364709
| struct_union_type_with_symbol ';'
47374710
{
4738-
/* this is essantially a typedef but needs the keyword struct/union as well */
4739-
struct typedefs *ptr, *this;
4740-
4741-
for (ptr = types; ptr != NULL; ptr = ptr->next)
4742-
{
4743-
if (strcmp($1.type_str, ptr->name) == 0)
4744-
{
4745-
/* re-definition is a bug */
4746-
snprintf(errortext, sizeof(errortext), "Type %s already defined", $1.type_str);
4747-
mmerror(PARSE_ERROR, ET_ERROR, errortext);
4748-
}
4749-
}
4750-
4751-
this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
4752-
4753-
/* initial definition */
4754-
this->next = types;
4755-
this->name = $1.type_str;
4756-
this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
4757-
this->type->type_enum = $1.type_enum;
4758-
this->type->type_str = mm_strdup($1.type_str);
4759-
this->type->type_dimension = make_str("-1"); /* dimension of array */
4760-
this->type->type_index = make_str("-1"); /* length of string */
4761-
this->type->type_sizeof = ECPGstruct_sizeof;
4762-
this->struct_member_list = struct_member_list[struct_level];
4763-
4764-
types = this;
4765-
$$ = cat2_str($1.type_sizeof, make_str(";"));
4711+
$$ = cat2_str($1, make_str(";"));
47664712
}
47674713
;
47684714

@@ -4996,21 +4942,51 @@ struct_union_type_with_symbol: s_struct_union_symbol
49964942
}
49974943
'{' variable_declarations '}'
49984944
{
4945+
struct typedefs *ptr, *this;
4946+
struct this_type su_type;
4947+
49994948
ECPGfree_struct_member(struct_member_list[struct_level]);
50004949
struct_member_list[struct_level] = NULL;
50014950
free(actual_storage[struct_level--]);
50024951
if (strncmp($1.su, "struct", sizeof("struct")-1) == 0)
5003-
$$.type_enum = ECPGt_struct;
4952+
su_type.type_enum = ECPGt_struct;
50044953
else
5005-
$$.type_enum = ECPGt_union;
5006-
$$.type_str = cat2_str($1.su, $1.symbol);
5007-
$$.type_sizeof = cat_str(4, mm_strdup($$.type_str), make_str("{"), $4, make_str("}"));
4954+
su_type.type_enum = ECPGt_union;
4955+
su_type.type_str = cat2_str($1.su, $1.symbol);
50084956
free(forward_name);
50094957
forward_name = NULL;
4958+
4959+
/* This is essantially a typedef but needs the keyword struct/union as well.
4960+
* So we create the typedef for each struct definition with symbol */
4961+
for (ptr = types; ptr != NULL; ptr = ptr->next)
4962+
{
4963+
if (strcmp(su_type.type_str, ptr->name) == 0)
4964+
{
4965+
/* re-definition is a bug */
4966+
snprintf(errortext, sizeof(errortext), "Type %s already defined", su_type.type_str);
4967+
mmerror(PARSE_ERROR, ET_ERROR, errortext);
4968+
}
4969+
}
4970+
4971+
this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
4972+
4973+
/* initial definition */
4974+
this->next = types;
4975+
this->name = mm_strdup(su_type.type_str);
4976+
this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
4977+
this->type->type_enum = su_type.type_enum;
4978+
this->type->type_str = mm_strdup(su_type.type_str);
4979+
this->type->type_dimension = make_str("-1"); /* dimension of array */
4980+
this->type->type_index = make_str("-1"); /* length of string */
4981+
this->type->type_sizeof = ECPGstruct_sizeof;
4982+
this->struct_member_list = struct_member_list[struct_level];
4983+
4984+
types = this;
4985+
$$ = cat_str(4, su_type.type_str, make_str("{"), $4, make_str("}"));
50104986
}
50114987
;
50124988

5013-
struct_union_type: struct_union_type_with_symbol { $$ = $1.type_sizeof; }
4989+
struct_union_type: struct_union_type_with_symbol { $$ = $1; }
50144990
| s_struct_union
50154991
{
50164992
struct_member_list[struct_level++] = NULL;

0 commit comments

Comments
 (0)