Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A300E475F47 for ; Thu, 21 Nov 2002 18:05:45 -0500 (EST) Received: from out001.verizon.net (out001pub.verizon.net [206.46.170.140]) by postgresql.org (Postfix) with ESMTP id D0241475E3E for ; Thu, 21 Nov 2002 18:05:44 -0500 (EST) Received: from URLWIN ([63.76.230.60]) by out001.verizon.net (InterMail vM.5.01.05.09 201-253-122-126-109-20020611) with ESMTP id <20021121230546.OPHY22402.out001.verizon.net@URLWIN>; Thu, 21 Nov 2002 17:05:46 -0600 From: "Jeff Urlwin" To: "Tim Bunce" , "David Wheeler" Cc: "Jeff Urlwin" , , Subject: Re: :PgSQL: More Queestions Date: Thu, 21 Nov 2002 18:05:42 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4920.2300 In-Reply-To: <20021121092316.GF381@dansat.data-plan.com> Importance: Normal X-Authentication-Info: Submitted using SMTP AUTH LOGIN at out001.verizon.net from [63.76.230.60] at Thu, 21 Nov 2002 17:05:42 -0600 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/146 X-Sequence-Number: 3394 > > On Wed, Nov 20, 2002 at 10:30:00PM -0800, David Wheeler wrote: > > On Wednesday, November 20, 2002, at 06:53 AM, Tim Bunce wrote: > > > > >>But if I change it (as I'm seriously considering, in light of > > >>PostgreSQL 7.3's support for prepared statements), I'll probably do no > > >>parsing for comments. > > > > > >I think that would be a bad move. > > > > Yes, your last post makes very clear why. Thanks. > > > > >If it's seen the start of a string ("..." or '...') then it just > > >keeps copying the string till it finds the same type of quote > > >character to mark the end of the string. The 'fiddly bit in the > > >middle' is handling backslashes used to escape quote chars in the > > >middle of the string: "...\"..." and "...\\" (odd vs even number). > > > > Seems rather opaque. Maybe I'm just reflecting my C-newbieness, but why > > wouldn't this work as well? Borrowing a bit from DBD::ODBC here (but > > allowing for both kinds of escaping of the quote characters): > > > > if (*src == '"' || *src == '\'') { > > if (!in_literal) { > > literal_ch = *src; > > in_literal = 1; > > No need for in_literal as literal_ch can serve as a flag as well. True...I was hacking that in and overlooked it. > > > } else { > > if (*src == literal_ch && *(src-1) != '//' > > && *(src-1) != literal_ch) { > > in_literal = 0; > > } > > } > > } > > Can't distinguish between > "....\\\\" - final double quote ends the string > "...\\\\\" - final double quote is escaped and string > continues... > > If the original code isn't broken it doesn't need fixing, maybe > just commenting. I'm tempted to leave it, since nobody is complaining, at the moment...but I'll put it on the list. Jeff