]> granicus.if.org Git - postgresql/commitdiff
More improvement to comment parsing in ecpg.
authorMichael Meskes <meskes@postgresql.org>
Mon, 25 Nov 2013 14:29:51 +0000 (15:29 +0100)
committerMichael Meskes <meskes@postgresql.org>
Mon, 25 Nov 2013 14:38:09 +0000 (15:38 +0100)
ECPG is not supposed to allow and output nested comments in C. These comments
are only allowed in the SQL parts and must not be written into the C file.
Also the different handling of different comments is documented.

doc/src/sgml/ecpg.sgml
src/interfaces/ecpg/preproc/pgc.l

index c629726affe6a642c8fde26e9a2ca0920af479be..120d760ba219bbd814f5be50aae79e076785b62c 100644 (file)
@@ -64,8 +64,10 @@ EXEC SQL ...;
    These statements syntactically take the place of a C statement.
    Depending on the particular statement, they can appear at the
    global level or within a function.  Embedded
-   <acronym>SQL</acronym> statements follow the case-sensitivity rules
-   of normal <acronym>SQL</acronym> code, and not those of C.
+   <acronym>SQL</acronym> statements follow the case-sensitivity rules of
+   normal <acronym>SQL</acronym> code, and not those of C. Also they allow nested
+   C-style comments that are part of the SQL standard. The C part of the
+   program, however, follows the C standard of not accepting nested comments.
   </para>
 
   <para>
index 6deef59d53faa88d213c5815beaca380a3e2dde1..f04e34a53dec95bf47637d002558ec1fa2c18366 100644 (file)
@@ -394,17 +394,20 @@ cppline                   {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
                                        xcdepth++;
                                        /* Put back any characters past slash-star; see above */
                                        yyless(2);
-                                       fputs("/*", yyout);
+                                       fputs("/_*", yyout);
                                }
 <xcsql>{xcstop}        {
-                                       ECHO;
                                        if (xcdepth <= 0)
                                        {
+                                               ECHO;
                                                BEGIN(state_before);
                                                token_start = NULL;
                                        }
                                        else
+                                       {
                                                xcdepth--;
+                                               fputs("*_/", yyout);
+                                       }
                                }
 <xcc>{xcstop}  {
                                        ECHO;
@@ -861,6 +864,7 @@ cppline                     {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
                                                        }
                                                }
                                        }
+<C>{xcstop}                    { mmerror(PARSE_ERROR, ET_ERROR, "nested /* ... */ comments"); }
 <C>":"                         { return(':'); }
 <C>";"                         { return(';'); }
 <C>","                         { return(','); }