pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Wimmer <seppwimmer@hotmail.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: type text in c functions
Date: Sat, 18 Dec 2004 22:21:07 -0500
Message-ID: <8230.1103426467@sss.pgh.pa.us> (raw)
In-Reply-To: <BAY10-F27712116B982BAC5BEEC10D0A10@phx.gbl>
References: <BAY10-F27712116B982BAC5BEEC10D0A10@phx.gbl>

"Robert Wimmer" <seppwimmer@hotmail.com> writes:
>   text *t = PG_GETARG_TEXT_P(0);

>   l = VARSIZE(t) - VARHDRSZ;

>   for (i = 0; i < l; i++) { if ( (t->vl_dat[i] < '0') || (t->vl_dat[i] > 
> '9')) break; }

>   if (i==l) ret = 0;
>   else ret = i;

I think you need to rethink your return convention --- success and
failure at the first character both return 0.

Directly using the vl_dat field doesn't seem like good style (you won't
find it anywhere in the backend sources) but it works.

			regards, tom lane



view thread (2+ messages)

Message-ID: <8230.1103426467@sss.pgh.pa.us>
Permalink:  ../8230.1103426467@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8230.1103426467@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, seppwimmer@hotmail.com
  Subject: Re: type text in c functions
  In-Reply-To: <8230.1103426467@sss.pgh.pa.us>

* 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