]> granicus.if.org Git - postgresql/commitdiff
In ecpg's parser removed a fixed length limit for constants defining an array dimension.
authorMichael Meskes <meskes@postgresql.org>
Sat, 8 Jan 2011 17:35:37 +0000 (18:35 +0100)
committerMichael Meskes <meskes@postgresql.org>
Sat, 8 Jan 2011 22:04:50 +0000 (23:04 +0100)
src/interfaces/ecpg/preproc/ecpg.trailer
src/interfaces/ecpg/test/expected/preproc-array_of_struct.c

index e80fece810ce279af6f91852c932fcb3b3501cee..ecae41b0bd5633be788edeaf522760fa7a061fe9 100644 (file)
@@ -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;
 
index c60bf51d9316358e9c05ea18a8fe87b0c6d8b573..5579ed4132ed709d9c4803885889b4da88a60db4 100644 (file)
@@ -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"