]> granicus.if.org Git - postgresql/commitdiff
Allow C array definitions to use sizeof().
authorMichael Meskes <meskes@postgresql.org>
Sun, 24 Nov 2013 11:51:21 +0000 (12:51 +0100)
committerMichael Meskes <meskes@postgresql.org>
Sun, 24 Nov 2013 11:51:21 +0000 (12:51 +0100)
When parsing C variable definitions ecpg should allow sizeof() operators as array dimensions.

src/interfaces/ecpg/preproc/ecpg.trailer

index 342b7bc4d4c0b6719cc67eb4d1a4d054046e454b..6ef9f1ab9d80c7996a33bed1f1cf5659fd013086 100644 (file)
@@ -1865,6 +1865,11 @@ Iresult:        Iconst                   { $$ = $1; }
                 | Iresult '%' Iresult   { $$ = cat_str(3, $1, mm_strdup("%"), $3); }
                 | ecpg_sconst          { $$ = $1; }
                 | ColId                 { $$ = $1; }
+               | ColId '(' ColId ')'   { if (pg_strcasecmp($1, "sizeof") != 0)
+                                               mmerror(PARSE_ERROR, ET_ERROR, "operator not allowed in variable definition");
+                                        else
+                                               $$ = cat_str(4,$1, mm_strdup("("), $3, mm_strdup(")"));
+                                       }
                 ;
 
 execute_rest: /* EMPTY */      { $$ = EMPTY; }