Re: Patch for pl/tcl Tcl_ExternalToUtf and Tcl_UtfToExternal support - Mailing list pgsql-patches

From Vsevolod Lobko
Subject Re: Patch for pl/tcl Tcl_ExternalToUtf and Tcl_UtfToExternal support
Date
Msg-id 20010823205540.L40612-100000@localhost
Whole thread Raw
In response to Re: Patch for pl/tcl Tcl_ExternalToUtf and Tcl_UtfToExternal support  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches

On Thu, 23 Aug 2001, Tom Lane wrote:

> Vsevolod Lobko <seva@sevasoft.kiev.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?


pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: Patch for pl/tcl Tcl_ExternalToUtf and Tcl_UtfToExternal support
Next
From: Tom Lane
Date:
Subject: Re: insert multiple rows attempt two