Re: Patch for pl/tcl Tcl_ExternalToUtf and Tcl_UtfToExternal support

From: Vsevolod Lobko <seva(at)sevasoft(dot)kiev(dot)ua>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Patch for pl/tcl Tcl_ExternalToUtf and Tcl_UtfToExternal support
Date: 2001-08-23 17:58:19
Message-ID: 20010823205540.L40612-100000@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

On Thu, 23 Aug 2001, Tom Lane wrote:

> Vsevolod Lobko <seva(at)sevasoft(dot)kiev(dot)ua> writes:
> > This patch adds calls to Tcl_ExternalToUtf and Tcl_UtfToExternal
> > functions on parameters of SPI functions.
>
> I hate to say it, but this is an amazingly ugly patch. Can't you
> do it without so many #ifdefs and duplicating a lot of code? Think
> of the next guy who has to look at/work on this code.
>
> Possibly a macro that invokes Tcl_ExternalToUtfDString or does nothing
> might help.

something like this?

#ifdef ENABLE_PLTCL_UTF
#warning bubu
# define UTF_BEGIN do { Tcl_DString _pltcl_ds_tmp;
# define UTF_END Tcl_DStringFree(&_pltcl_ds_tmp); } while (0);
# define UTF_U2E(x) (Tcl_UtfToExternalDString(NULL,(x),-1,\
&_pltcl_ds_tmp))
# define UTF_E2U(x) (Tcl_ExternalToUtfDString(NULL,(x),-1,\
&_pltcl_ds_tmp))
#else /* ENABLE_PLTCL_UTF */
# define UTF_BEGIN
# define UTF_END
# define UTF_U2E(x) (x)
# define UTF_E2U(x) (x)
#endif /* ENABLE_PLTCL_UTF */

and

if (part != NULL)
{
UTF_BEGIN
Tcl_DStringAppend(&unknown_src, UTF_E2U(part), -1);
UTF_END
pfree(part);
}

Is this looks better?

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2001-08-23 18:02:31 Re: insert multiple rows attempt two
Previous Message Bruce Momjian 2001-08-23 17:58:15 Re: Patch for pl/tcl Tcl_ExternalToUtf and Tcl_UtfToExternal support