X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A89243A1922 for ; Sun, 19 Dec 2004 03:21:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31946-05 for ; Sun, 19 Dec 2004 03:21:05 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0805D3A190D for ; Sun, 19 Dec 2004 03:21:08 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iBJ3L7Rh008231; Sat, 18 Dec 2004 22:21:07 -0500 (EST) To: "Robert Wimmer" Cc: pgsql-interfaces@postgresql.org Subject: Re: type text in c functions In-reply-to: References: Comments: In-reply-to "Robert Wimmer" message dated "Sun, 19 Dec 2004 01:16:44 +0000" Date: Sat, 18 Dec 2004 22:21:07 -0500 Message-ID: <8230.1103426467@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200412/44 X-Sequence-Number: 5214 "Robert Wimmer" 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