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

Re: [PATCH] #2 Update on port to OS400/EBCDIC

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2006-02-14 18:24:08 CET

Paul Burba <paulb@softlanding.com> writes:

> Index: subversion/libsvn_client/diff.c
> ===================================================================
> --- subversion/libsvn_client/diff.c (revision 18448)
> +++ subversion/libsvn_client/diff.c (working copy)
> @@ -2546,7 +2546,12 @@
> {
> return svn_client_diff3 (options, path1, revision1, path2, revision2,
> recurse, ignore_ancestry, no_diff_deleted,
> - ignore_content_type, APR_LOCALE_CHARSET,
> + ignore_content_type,
> +#ifndef AS400
> + APR_LOCALE_CHARSET,
> +#else
> + apr_psprintf (pool, "%i", APR_LOCALE_CHARSET),
> +#endif
> outfile, errfile, ctx, pool);
> }

I'd much rather see the conditional stuff hidden behind some sort of
macro. Perhaps something like:

#ifndef AS400
#define SVN_APR_LOCALE_CHARSET APR_LOCALE_CHARSET
#else
#define SVN_APR_LOCALE_CHARSET APR_STRINGIFY(APR_LOCALE_CHARSET)
#endif

or (following apr)

#ifndef AS400
#define SVN_APR_LOCALE_CHARSET APR_LOCALE_CHARSET
#else
#define SVN_APR_LOCALE_CHARSET ((const char*)APR_LOCALE_CHARSET)
#endif

> --- subversion/libsvn_subr/utf.c (revision 18448)
> +++ subversion/libsvn_subr/utf.c (working copy)
> @@ -57,7 +57,11 @@
> destroyed. */
> svn_boolean_t valid;
> /* The name of a char encoding or APR_LOCALE_CHARSET. */
> +#ifndef AS400
> const char *frompage, *topage;
> +#else
> + int frompage, topage;
> +#endif
> struct xlate_handle_node_t *next;
> } xlate_handle_node_t;

Is it possible to avoid changing xlate_handle_node_t and instead
convert the strings to integers just before calling apr_xlate_open?

> @@ -136,7 +140,12 @@
> in the pool of xlate_handle_hash. */
> static svn_error_t *
> get_xlate_handle_node (xlate_handle_node_t **ret,
> +#ifndef AS400
> const char *topage, const char *frompage,
> +#else
> + /* apr_xlate_open() takes ints on OS400. */
> + int topage, int frompage,
> +#endif
> const char *userdata_key, apr_pool_t *pool)
> {
> xlate_handle_node_t **old_node_p;
> @@ -200,8 +209,12 @@
>
> /* The error handling doesn't support the following cases, since we
> don't
> use them currently. Catch this here. */
> +#ifndef AS400_UTF8
> + /* On OS400 APR_DEFAULT_CHARSET and APR_LOCALE_CHARSET are both UTF-8
> + * (CCSID 1208), so we can't allow this assert. */
> assert (frompage != APR_DEFAULT_CHARSET && topage !=
> APR_DEFAULT_CHARSET
> && (frompage != APR_LOCALE_CHARSET || topage !=
> APR_LOCALE_CHARSET));
> +#endif

The APR_STRINGIFY approach would need to include a further macro to do
charset idicator comparisons using strcmp on OS400 and != otherwise.
That might be a reason to use the alternative "cast to char*"
approach.

>
> /* Use the correct pool for creating the handle. */
> if (userdata_key && xlate_handle_hash)
> @@ -217,6 +230,7 @@
> const char *errstr;
> /* Can't use svn_error_wrap_apr here because it calls functions in
> this file, leading to infinite recursion. */
> +#ifndef AS400
> if (frompage == APR_LOCALE_CHARSET)
> errstr = apr_psprintf (pool,
> _("Can't create a character converter from
> "
> @@ -229,6 +243,13 @@
> errstr = apr_psprintf (pool,
> _("Can't create a character converter from
> "
> "'%s' to '%s'"), frompage, topage);
> +#else
> + /* Handle the error condition normally prevented by the assert
> + * above. */
> + errstr = apr_psprintf (pool,
> + _("Can't create a character converter from "
> + "'%i' to '%i'"), frompage, topage);
> +#endif
> err = svn_error_create (apr_err, NULL, errstr);
> goto cleanup;
> }
> @@ -237,10 +258,16 @@
> *ret = apr_palloc (pool, sizeof(xlate_handle_node_t));
> (*ret)->handle = handle;
> (*ret)->valid = TRUE;
> +#ifndef AS400
> (*ret)->frompage = ((frompage != APR_LOCALE_CHARSET)
> ? apr_pstrdup (pool, frompage) : frompage);
> (*ret)->topage = ((topage != APR_LOCALE_CHARSET)
> ? apr_pstrdup (pool, topage) : topage);
> +#else
> + /* frompage and topage are ints on OS400. */
> + (*ret)->frompage = frompage;
> + (*ret)->topage = topage;
> +#endif
> (*ret)->next = NULL;
>
> /* If we are called from inside a pool cleanup handler, the just
> created
> @@ -315,8 +342,13 @@
> static svn_error_t *
> get_ntou_xlate_handle_node (xlate_handle_node_t **ret, apr_pool_t *pool)
> {
> +#ifndef AS400
> return get_xlate_handle_node (ret, "UTF-8", APR_LOCALE_CHARSET,
> SVN_UTF_NTOU_XLATE_HANDLE, pool);
> +#else
> + return get_xlate_handle_node (ret, 1208, APR_LOCALE_CHARSET,
> + SVN_UTF_NTOU_XLATE_HANDLE, pool);
> +#endif
> }
>
>
> @@ -328,8 +360,13 @@
> static svn_error_t *
> get_uton_xlate_handle_node (xlate_handle_node_t **ret, apr_pool_t *pool)
> {
> +#ifndef AS400
> return get_xlate_handle_node (ret, APR_LOCALE_CHARSET, "UTF-8",
> SVN_UTF_UTON_XLATE_HANDLE, pool);
> +#else
> + return get_xlate_handle_node (ret, APR_LOCALE_CHARSET, 1208,
> + SVN_UTF_UTON_XLATE_HANDLE, pool);
> +#endif
> }
>
>
> @@ -451,15 +488,27 @@
> this file, leading to infinite recursion. */
> if (node->frompage == APR_LOCALE_CHARSET)
> errstr = apr_psprintf
> +#ifndef AS400
> (pool, _("Can't convert string from native encoding to '%s':"),
> +#else
> + (pool, _("Can't convert string from native encoding to '%d':"),
> +#endif
> node->topage);
> else if (node->topage == APR_LOCALE_CHARSET)
> errstr = apr_psprintf
> +#ifndef AS400
> (pool, _("Can't convert string from '%s' to native encoding:"),
> +#else
> + (pool, _("Can't convert string from '%d' to native encoding:"),
> +#endif
> node->frompage);
> else
> errstr = apr_psprintf
> +#ifndef AS400
> (pool, _("Can't convert string from '%s' to '%s':"),
> +#else
> + (pool, _("Can't convert string from '%d' to '%d':"),
> +#endif
> node->frompage, node->topage);
> err = svn_error_create (apr_err, NULL, fuzzy_escape (src_data,
> src_length,
> pool));
> @@ -694,7 +743,14 @@
> xlate_handle_node_t *node;
> svn_error_t *err;
>
> +#ifndef AS400
> SVN_ERR (get_xlate_handle_node (&node, "UTF-8", frompage, convset_key,
> pool));
> +#else
> + /* On OS400 we assume frompage is a string representation of a CCSID
> int
> + * and attempt to get a translation node for that CCSID. */
> + SVN_ERR (get_xlate_handle_node (&node, 1208, atoi (frompage),
> convset_key,
> + pool));
> +#endif
> err = convert_cstring (dest, src, node, pool);
> put_xlate_handle_node (node, convset_key, pool);
> SVN_ERR (err);
> @@ -796,7 +852,14 @@
>
> SVN_ERR (check_utf8 (src, strlen (src), pool));
>
> +#ifndef AS400
> SVN_ERR (get_xlate_handle_node (&node, topage, "UTF-8", convset_key,
> pool));
> +#else
> + /* On OS400 we assume topage is a string representation of a CCSID int
> + * and attempt to get a translation node for that CCSID. */
> + SVN_ERR (get_xlate_handle_node (&node, atoi (topage), 1208,
> convset_key,
> + pool));
> +#endif

Rather than change all the "UTF-8" to 1208 can you recognise "UTF-8"
at runtime and convert to 1208 just before calling apr_xlate_open? If
you want to avoid the runtime conversion then I'd prefer a macro

#ifndef OS400
#define SVN_APR_UTF8_CHARSET "UTF-8"
#else
#define SVN_APR_UTF8_CHARSET "1208"
#endif

or

#define SVN_APR_UTF8_CHARSET ((const char *)1208)

depending on whether you use APR_STRINGIFY or "cast to char*".

-- 
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Feb 14 18:24:42 2006

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.