Re: psql patch - Mailing list pgsql-patches
From | Bruce Momjian |
---|---|
Subject | Re: psql patch |
Date | |
Msg-id | 200303210340.h2L3e3u15742@candle.pha.pa.us Whole thread Raw |
In response to | psql patch ("Jeroen T. Vermeulen" <jtv@xs4all.nl>) |
Responses |
Re: psql patch
|
List | pgsql-patches |
OK, I applied your suggested cleanup. I don't think I can move the code up or I would not be able to do nested /* */ comments, which the code seems to support. --------------------------------------------------------------------------- Jeroen T. Vermeulen wrote: > 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 > > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 Index: src/bin/psql/mainloop.c =================================================================== RCS file: /cvsroot/pgsql-server/src/bin/psql/mainloop.c,v retrieving revision 1.54 diff -c -c -r1.54 mainloop.c *** src/bin/psql/mainloop.c 20 Mar 2003 22:08:50 -0000 1.54 --- src/bin/psql/mainloop.c 21 Mar 2003 03:26:40 -0000 *************** *** 281,295 **** /* in or end of extended comment? */ else if (in_xcomment) { ! if (line[i] == '*' && line[i + thislen] == '/') ! { ! in_xcomment--; ! if (in_xcomment <= 0) ! { ! in_xcomment = 0; ADVANCE_1; - } - } } /* start of quote? */ --- 281,289 ---- /* in or end of extended comment? */ else if (in_xcomment) { ! if (line[i] == '*' && line[i + thislen] == '/' && ! !--in_xcomment) ADVANCE_1; } /* start of quote? */
pgsql-patches by date: