Re: psql patch - Mailing list pgsql-patches

From Jeroen T. Vermeulen
Subject Re: psql patch
Date
Msg-id 20030320223904.GH28190@xs4all.nl
Whole thread Raw
In response to Re: psql patch  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-patches
On Thu, Mar 20, 2003 at 05:13:05PM -0500, Bruce Momjian wrote:
>
> I have applied the following patch to fix a bug in the new psql patch.
> It wasn't handling multi-line /* */ comments properly.  Jeroen, would
> you review the change.  The rest of the changes look very good.

Yes, come to think of it I can see now that it also wouldn't deal
with special sequences like '--' or unmatched quotes and parentheses
very well either.  Nor did the original version, from the looks of
it, so I'd like to suggest moving the whole "if (in_xcomment)" clause
up a little in the else-if chain, to just below the "if (in_quote)"
one.  That would make the thing ignore all special sequences except
'*/' when inside an xcomment, and all sequences inside a quote
(except a closing quote, of course).  Plus, just in case any
legitimate expression could give rise to the sequence "*/" ouside
of an xcomment, that would also be handled properly.

BTW your version could be simplified a little:

    /* [ "if (in_quote)" clause here ] */

    /* end of extended comment? */
    else if (in_xcomment)
    {
        if ((line[i] == '*') &&
            (line[i + thislen] == '/') &&
            !--in_xcomment)
            ADVANCE_1;
    }

    /* start of extended comment? */
    /* [ '/*' clause here ] */


Lessee...  I hope this says it all, but if you like I can submit
a patch to today's CVS version.


Jeroen


pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: FW: New function - hostmask
Next
From: "Jeroen T. Vermeulen"
Date:
Subject: Re: psql patch (2)