Re: type text in c functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Robert Wimmer" <seppwimmer(at)hotmail(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: type text in c functions
Date: 2004-12-19 03:21:07
Message-ID: 8230.1103426467@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

"Robert Wimmer" <seppwimmer(at)hotmail(dot)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

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message atanu ghosh 2004-12-21 04:41:04 which front - end tools will support in PostgreSQL
Previous Message Robert Wimmer 2004-12-19 01:16:44 type text in c functions