pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tim Bunce <Tim.Bunce@pobox.com>
To: David Wheeler <david@wheeler.net>
Cc: Tim Bunce <Tim.Bunce@pobox.com>
Cc: Jeff Urlwin <jurlwin@bellatlantic.net>
Cc: dbi-dev@perl.org
Cc: pgsql-interfaces@postgresql.org
Subject: Re: :PgSQL: More Queestions
Date: Thu, 21 Nov 2002 09:23:16 +0000
Message-ID: <20021121092316.GF381@dansat.data-plan.com> (raw)
In-Reply-To: <A95C6280-FD1A-11D6-8943-0003931A964A@wheeler.net>
References: <20021120145301.GY381@dansat.data-plan.com>
	<A95C6280-FD1A-11D6-8943-0003931A964A@wheeler.net>

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.

>             } 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.

Tim.



view thread (22+ messages)  latest in thread

Message-ID: <20021121092316.GF381@dansat.data-plan.com>
Permalink:  ../20021121092316.GF381@dansat.data-plan.com/
Also on:    postgresql.org/message-id/20021121092316.GF381@dansat.data-plan.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: Tim.Bunce@pobox.com, david@wheeler.net, jurlwin@bellatlantic.net, dbi-dev@perl.org
  Subject: Re: :PgSQL: More Queestions
  In-Reply-To: <20021121092316.GF381@dansat.data-plan.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox