From 833a2b57bcbebda29fc1eb0b98c0d94ae2c31b7b Mon Sep 17 00:00:00 2001 From: Michael Meskes Date: Sat, 8 Jan 2011 18:35:37 +0100 Subject: [PATCH] In ecpg's parser removed a fixed length limit for constants defining an array dimension. --- src/interfaces/ecpg/preproc/ecpg.trailer | 8 ++++---- .../ecpg/test/expected/preproc-array_of_struct.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer index e80fece810..ecae41b0bd 100644 --- a/src/interfaces/ecpg/preproc/ecpg.trailer +++ b/src/interfaces/ecpg/preproc/ecpg.trailer @@ -840,7 +840,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize struct ECPGtype * type; char *dimension = $3.index1; /* dimension of array */ char *length = $3.index2; /* length of string */ - char dim[14L]; + char *dim_str; char *vcn; adjust_array(actual_type[struct_level].type_enum, &dimension, &length, actual_type[struct_level].type_dimension, actual_type[struct_level].type_index, strlen($1), false); @@ -864,9 +864,9 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, varchar_counter), dimension); if (strcmp(dimension, "0") == 0 || abs(atoi(dimension)) == 1) - *dim = '\0'; + dim_str=make_str(""); else - sprintf(dim, "[%s]", dimension); + dim_str=cat_str(3, make_str("["), mm_strdup(dimension), make_str("]")); /* cannot check for atoi <= 0 because a defined constant will yield 0 here as well */ if (atoi(length) < 0 || strcmp(length, "0") == 0) mmerror(PARSE_ERROR, ET_ERROR, "pointers to varchar are not implemented"); @@ -877,7 +877,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize if (strcmp(dimension, "0") == 0) $$ = cat_str(7, make2_str(make_str(" struct varchar_"), vcn), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } *"), mm_strdup($2), $4, $5); else - $$ = cat_str(8, make2_str(make_str(" struct varchar_"), vcn), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } "), mm_strdup($2), mm_strdup(dim), $4, $5); + $$ = cat_str(8, make2_str(make_str(" struct varchar_"), vcn), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } "), mm_strdup($2), dim_str, $4, $5); varchar_counter++; break; diff --git a/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c b/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c index c60bf51d93..5579ed4132 100644 --- a/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c +++ b/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c @@ -114,7 +114,7 @@ int main() int r ; #line 45 "array_of_struct.pgc" - struct varchar_onlyname_5 { int len; char arr[ 50 ]; } onlyname [2] ; + struct varchar_onlyname_5 { int len; char arr[ 50 ]; } onlyname [ 2 ] ; /* exec sql end declare section */ #line 46 "array_of_struct.pgc" -- 2.40.0