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 $ */
2
2
3
3
/* Copyright comment */
4
4
%{
@@ -540,7 +540,7 @@ add_additional_variables(char *name, bool insert)
540
540
%type <str> col_name_keyword func_name_keyword precision opt_scale
541
541
%type <str> ECPGTypeName using_list ECPGColLabelCommon UsingConst
542
542
%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
544
544
545
545
%type <struct_union> s_struct_union_symbol
546
546
@@ -551,7 +551,6 @@ add_additional_variables(char *name, bool insert)
551
551
%type <dtype_enum> descriptor_item desc_header_item
552
552
553
553
%type <type> var_type common_type single_vt_type
554
- %type <type> struct_union_type_with_symbol
555
554
556
555
%type <action> action
557
556
@@ -4441,34 +4440,7 @@ single_var_declaration: storage_declaration
4441
4440
}
4442
4441
| struct_union_type_with_symbol ' ;'
4443
4442
{
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(" ;" ));
4472
4444
}
4473
4445
;
4474
4446
@@ -4658,6 +4630,7 @@ type_declaration: S_TYPEDEF
4658
4630
char * dimension = $6 .index1;
4659
4631
char * length = $6 .index2;
4660
4632
4633
+ printf (" MM: %s\n " , $5 );
4661
4634
if (($3 .type_enum == ECPGt_struct ||
4662
4635
$3 .type_enum == ECPGt_union) &&
4663
4636
initializer == 1 )
@@ -4735,34 +4708,7 @@ var_declaration: storage_declaration
4735
4708
}
4736
4709
| struct_union_type_with_symbol ' ;'
4737
4710
{
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(" ;" ));
4766
4712
}
4767
4713
;
4768
4714
@@ -4996,21 +4942,51 @@ struct_union_type_with_symbol: s_struct_union_symbol
4996
4942
}
4997
4943
' {' variable_declarations ' }'
4998
4944
{
4945
+ struct typedefs *ptr, *this ;
4946
+ struct this_type su_type;
4947
+
4999
4948
ECPGfree_struct_member (struct_member_list[struct_level]);
5000
4949
struct_member_list[struct_level] = NULL ;
5001
4950
free (actual_storage[struct_level--]);
5002
4951
if (strncmp($1 .su, " struct" , sizeof (" struct" )-1 ) == 0 )
5003
- $$ .type_enum = ECPGt_struct;
4952
+ su_type .type_enum = ECPGt_struct;
5004
4953
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);
5008
4956
free (forward_name);
5009
4957
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(" }" ));
5010
4986
}
5011
4987
;
5012
4988
5013
- struct_union_type : struct_union_type_with_symbol { $$ = $1 .type_sizeof ; }
4989
+ struct_union_type : struct_union_type_with_symbol { $$ = $1 ; }
5014
4990
| s_struct_union
5015
4991
{
5016
4992
struct_member_list[struct_level++] = NULL ;
0 commit comments