Hello All,
This is the second in a series of patch submissions that will allow
subversion to run on the IBM iSeries under OS400 V5R4.
See: http://svn.haxx.se/dev/archive-2006-02/0519.shtml
Please review at your leisure.
Thanks,
Paul B.
[[[
OS400/EBCDIC Port: Handle xlate page differences.
This is the second of several patches to allow Subversion to run on IBM's
OS400 V5R4.
OS400 uses integers (Coded Character Set Identifiers or CCSIDs in
IBM-speak)
to represent charsets rather than strings, e.g. 1208 vs. "UTF-8". This
has
two implications for the subversion code:
1) apr_xlate_open() has a different signature, taking ints for topage
and frompage.
2) APR_DEFAULT_CHARSET and APR_LOCALE_CHARSET are of type int not
const char *.
The first case necessitates some changes to the svn_utf_* functions that
work
with xlate_handle_node_t and to the struct itself. In the second we just
convert APR_LOCALE_CHARSET to it's string representation.
* subversion/libsvn_client/diff.c
(svn_client_diff2, svn_client_diff_peg2):
* subversion/libsvn_diff/diff_file.c
(svn_diff_file_output_unified):
* subversion/libsvn_subr/cmdline.c
(svn_cmdline_output_encoding):
Convert APR_LOCALE_CHARSET to it's string representation.
* subversion/libsvn_subr/utf.c
(xlate_handle_node_t): Declare struct members topage and frompage as
type int not const char*.
(get_xlate_handle_node): Change signature on OS400 so topage and
frompage
are of type int. Disable assert that doesn't apply to V5R4 and handle
error condition this may now permit. Account for fact
xlate_handle_node_t has int members on OS400 when populating the
struct.
(get_ntou_xlate_handle_node, get_uton_xlate_handle_node,
svn_utf_cstring_to_utf8_ex, svn_utf_cstring_from_utf8_ex): Assume
from/topage is string representation of intended CCSID to convert
from/to. Use 1208 int constant in place of "UTF-8" string constant
when calling get_xlate_handle_node().
(convert_to_stringbuf): Account for fact xlate_handle_node_t
has int members on OS400 when creating error messages.
]]]
================================================================================
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);
}
@@ -2646,8 +2651,13 @@
return svn_client_diff_peg3 (options, path, peg_revision,
start_revision,
end_revision, recurse, ignore_ancestry,
no_diff_deleted, ignore_content_type,
- APR_LOCALE_CHARSET, outfile, errfile,
- ctx, pool);
+#ifndef AS400
+ APR_LOCALE_CHARSET,
+#else
+ apr_psprintf (pool, "%i",
+ APR_LOCALE_CHARSET),
+#endif
+ outfile, errfile, ctx, pool);
}
svn_error_t *
Index: subversion/libsvn_diff/diff_file.c
===================================================================
--- subversion/libsvn_diff/diff_file.c (revision 18448)
+++ subversion/libsvn_diff/diff_file.c (working copy)
@@ -994,7 +994,13 @@
return svn_diff_file_output_unified2(output_stream, diff,
original_path, modified_path,
original_header, modified_header,
- APR_LOCALE_CHARSET, pool);
+#ifndef AS400
+ APR_LOCALE_CHARSET,
+#else
+ apr_psprintf (pool, "%i",
+ APR_LOCALE_CHARSET),
+#endif
+ pool);
}
Index: subversion/libsvn_subr/cmdline.c
===================================================================
--- subversion/libsvn_subr/cmdline.c (revision 18448)
+++ subversion/libsvn_subr/cmdline.c (working copy)
@@ -308,7 +308,11 @@
if (output_encoding)
return apr_pstrdup (pool, output_encoding);
else
+#ifndef AS400
return APR_LOCALE_CHARSET;
+#else
+ return apr_psprintf (pool, "%i", APR_LOCALE_CHARSET);
+#endif
}
int
Index: subversion/libsvn_subr/utf.c
===================================================================
--- 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;
@@ -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
/* 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
err = convert_cstring (dest, src, node, pool);
put_xlate_handle_node (node, convset_key, pool);
_____________________________________________________________________________
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 Mon Feb 13 22:05:54 2006