[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: More documentation for svn_utf_cstring_from_utf8_ex() etc.

From: Paul Burba <paulb_at_softlanding.com>
Date: 2006-03-23 18:05:24 CET

Julian Foad <julianfoad@btopenworld.com> wrote on 03/22/2006 05:36:05 PM:

> Julian Foad wrote:
> > 2. What is the meaning and purpose of the "convset_key" parameter? I
> > can see what's written; I don't understand what sort of value I have
> > pass and what function it performs.
> Paul Burba wrote of the values, in a separate thread:
> > My description of these is likely not clear enough. They are keys for

> > caching xlate_handle_node_t structs for conversions between EBCDIC and

> > UTF-8 and vice-versa when calling svn_utf_cstring_to_utf8_ex() and
> > svn_utf_cstring_from_utf8_ex(), i.e. the convset_key argument to these

> > functions.
> [...]
> > +/* Cache keys for the charset converters used by
> > + * svn_utf_cstring_from_utf8_ex and svn_utf_cstring_to_utf8_ex
> > + * when performing conversions between UTF-8 and EBCDIC.
> > + */
> > +#define SVN_UTF_UTOE_XLATE_HANDLE "svn-utf-utoe-xlate-handle"
> > +#define SVN_UTF_ETOU_XLATE_HANDLE "svn-utf-etou-xlate-handle"
> When you say they are "keys for caching", does that mean that
> everything works
> regardless of what values you pass for these keys, even if the values
> between one call and the next, and the only ill-effect of not
> passing the same
> value consistently is that the conversions are slower?
> If so, then we could regard these as private to each library: we need
not use
> the same values throughout the application. I'm not saying we want
> to do that,
> just trying to understand what's possible and suggesting that this
_might_ be
> better than making them public.

> I can't help thinking that this parameter is redundant. Why can't the
> "frompage" or "topage" parameter to svn_utf_cstring_*_utf8_ex() be
> used as the
> cache key?

Hmmm, yes, why can't we do that? Except for the hassle of an API change,
can't we eventually use something like this?

 /** Set @a *dest to a utf8-encoded C string from @a frompage C string
- * @a src; allocate @a *dest in @a pool. Use @a convset_key as the
- * cache key for the charset converter; if it's NULL, don't cache the
- * converter.
+ * @a src; allocate @a *dest in @a pool.
 svn_error_t *svn_utf_cstring_to_utf8_ex(const char **dest,
                                         const char *src,
                                         const char *frompage,
- const char *convset_key,
                                         apr_pool_t *pool);

 svn_utf_cstring_to_utf8_ex(const char **dest,
                            const char *src,
                            const char *frompage,
- const char *convset_key,
                            apr_pool_t *pool)
   xlate_handle_node_t *node;
   svn_error_t *err;
+#ifndef AS400
+ const char *convset_key = apr_psprintf(pool,
+ "svn-utf-%stou-xlate-handle",
+ frompage);
+ const char *convset_key = apr_psprintf(pool,
+ "svn-utf-%dtou-xlate-handle",
+ frompage);
   SVN_ERR(get_xlate_handle_node(&node, SVN_APR_UTF8_CHARSET, frompage,
                                 convset_key, pool));
   err = convert_cstring(dest, src, node, pool);
   put_xlate_handle_node(node, convset_key, pool);

(and the equivalent for svn_utf_cstring_from_utf8_ex)

Paul B.

Scanned for SoftLanding Systems, Inc. and SoftLanding Europe Plc by IBM Email Security Management Services powered by MessageLabs.

To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Mar 23 18:05:53 2006

This is an archived mail posted to the Subversion Dev mailing list.