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

[PATCH] #1 Update on port to OS400/EBCDIC

From: Paul Burba <paulb_at_softlanding.com>
Date: 2006-02-09 22:40:19 CET

Hello All,

This is a follow-up to Mark's message yesterday, see
http://svn.haxx.se/dev/archive-2006-02/0519.shtml

This is the first of several (probably 5 - 10) patch submissions that will
allow subversion to run on the IBM iSeries under OS400 V5R4. I'll try to
keep each patch relatively small and focused on one problem.

Ok then, here is patch #1. It addresses the problem that argv arguments
to main() are encoded in ebcdic. If anyone out there has some time to
review it we'd appreciate it.

Thanks,

Paul B.

================================================================================

[[[
* subversion/svn/main.c:
* subversion/svnadmin/main.c
* subversion/svndumpfilter/main.c
* subversion/svnlook/main.c
* subversion/svnserve/main.c
* subversion/svnsync/main.c
* subversion/svnversion/main.c
   (SVN_UTF_ETOU_XLATE_HANDLE): Xlate key for ebcdic (CCSID 0) to utf-8
    conversions.
   (main): Convert incoming argv strings to utf-8. Note that
    svn_utf_cstring_to_utf8_ex() is used instead of
svn_utf_cstring_to_utf8
    because V5R4 thinks native strings are in utf-8.
]]]

Index: subversion/svn/main.c
===================================================================
--- subversion/svn/main.c (revision 18362)
+++ subversion/svn/main.c (working copy)
@@ -48,6 +48,9 @@
 
 #include "svn_private_config.h"
 
+#if AS400_UTF8
+#define SVN_UTF_ETOU_XLATE_HANDLE "svn-utf-etou-xlate-handle"
+#endif
 
 /*** Option Processing ***/
 
@@ -780,6 +783,11 @@
   svn_cl__cmd_baton_t command_baton;
   svn_auth_baton_t *ab;
   svn_config_t *cfg;
+#if AS400_UTF8
+ /* Even when compiled with UTF support in V5R4, argv is still
+ * encoded in ebcdic, so we'll need to convert it to utf-8. */
+ const char ** argv_utf8;
+#endif
 
   /* Initialize the app. */
   if (svn_cmdline_init ("svn", stderr) != EXIT_SUCCESS)
@@ -831,7 +839,20 @@
     }
 
   /* Else, parse options. */
+#if !AS400_UTF8
   apr_getopt_init (&os, pool, argc, argv);
+#else
+ /* Convert argv to utf-8 for call to apr_getopt_init(). */
+ argv_utf8 = apr_palloc (pool, sizeof(char *) * argc);
+ for (i = 0; i < argc; i++)
+ {
+ /* Use "0" for default job ccsid. */
+ if (svn_utf_cstring_to_utf8_ex (&argv_utf8[i], argv[i], "0",
+ SVN_UTF_ETOU_XLATE_HANDLE, pool))
+ return EXIT_FAILURE;
+ }
+ apr_getopt_init (&os, pool, argc, argv_utf8);
+#endif
   os->interleave = 1;
   while (1)
     {
Index: subversion/svnadmin/main.c
===================================================================
--- subversion/svnadmin/main.c (revision 18362)
+++ subversion/svnadmin/main.c (working copy)
@@ -37,6 +37,10 @@
 
 #include "svn_private_config.h"
 
+#if AS400_UTF8
+#define SVN_UTF_ETOU_XLATE_HANDLE "svn-utf-etou-xlate-handle"
+#endif
+
 
 /*** Code. ***/
 
@@ -1138,6 +1142,11 @@
   int opt_id;
   apr_array_header_t *received_opts;
   int i;
+#if AS400_UTF8
+ /* Even when compiled with UTF support in V5R4, argv is still
+ * encoded in ebcdic, so we'll need to convert it to utf-8. */
+ const char **argv_utf8;
+#endif
 
   /* Initialize the app. */
   if (svn_cmdline_init ("svnadmin", stderr) != EXIT_SUCCESS)
@@ -1179,7 +1188,20 @@
   opt_state.end_revision.kind = svn_opt_revision_unspecified;
 
   /* Parse options. */
+#if !AS400_UTF8
   apr_getopt_init (&os, pool, argc, argv);
+#else
+ /* Convert argv to utf-8 for call to apr_getopt_init(). */
+ argv_utf8 = apr_palloc (pool, sizeof(char *) * argc);
+ for (i = 0; i < argc; i++)
+ {
+ /* Use "0" for default job ccsid. */
+ if (svn_utf_cstring_to_utf8_ex (&argv_utf8[i], argv[i], "0",
+ SVN_UTF_ETOU_XLATE_HANDLE, pool))
+ return EXIT_FAILURE;
+ }
+ apr_getopt_init (&os, pool, argc, argv_utf8);
+#endif
   os->interleave = 1;
 
   while (1)
Index: subversion/svndumpfilter/main.c
===================================================================
--- subversion/svndumpfilter/main.c (revision 18362)
+++ subversion/svndumpfilter/main.c (working copy)
@@ -34,6 +34,10 @@
 #include "svn_sorts.h"
 #include "svn_props.h"
 
+#if AS400_UTF8
+#define SVN_UTF_ETOU_XLATE_HANDLE "svn-utf-etou-xlate-handle"
+#endif
+
 
 /*** Code. ***/
 
@@ -1080,6 +1084,11 @@
   int opt_id;
   apr_array_header_t *received_opts;
   int i;
+#if AS400_UTF8
+ /* Even when compiled with UTF support in V5R4, argv is still
+ * encoded in ebcdic, so we'll need to convert it to utf-8. */
+ const char **argv_utf8;
+#endif
 
 
   /* Initialize the app. */
@@ -1122,7 +1131,20 @@
   opt_state.end_revision.kind = svn_opt_revision_unspecified;
 
   /* Parse options. */
+#if !AS400_UTF8
   apr_getopt_init (&os, pool, argc, argv);
+#else
+ /* Convert argv to utf-8 for call to apr_getopt_init(). */
+ argv_utf8 = apr_palloc (pool, sizeof(char *) * argc);
+ for (i = 0; i < argc; i++)
+ {
+ /* Use "0" for default job ccsid. */
+ if (svn_utf_cstring_to_utf8_ex (&argv_utf8[i], argv[i], "0",
+ SVN_UTF_ETOU_XLATE_HANDLE, pool))
+ return EXIT_FAILURE;
+ }
+ apr_getopt_init (&os, pool, argc, argv_utf8);
+#endif
   os->interleave = 1;
   while (1)
     {
Index: subversion/svnlook/main.c
===================================================================
--- subversion/svnlook/main.c (revision 18362)
+++ subversion/svnlook/main.c (working copy)
@@ -44,6 +44,10 @@
 
 #include "svn_private_config.h"
 
+#if AS400_UTF8
+#define SVN_UTF_ETOU_XLATE_HANDLE "svn-utf-etou-xlate-handle"
+#endif
+
 
 /*** Some convenience macros and types. ***/
 
@@ -1987,6 +1991,11 @@
   int opt_id;
   apr_array_header_t *received_opts;
   int i;
+#if AS400_UTF8
+ /* Even when compiled with UTF support in V5R4, argv is still
+ * encoded in ebcdic, so we'll need to convert it to utf-8. */
+ const char **argv_utf8;
+#endif
 
   /* Initialize the app. */
   if (svn_cmdline_init ("svnlook", stderr) != EXIT_SUCCESS)
@@ -2027,7 +2036,20 @@
   opt_state.rev = SVN_INVALID_REVNUM;
 
   /* Parse options. */
+#if !AS400_UTF8
   apr_getopt_init (&os, pool, argc, argv);
+#else
+ /* Convert argv to utf-8 for call to apr_getopt_init(). */
+ argv_utf8 = apr_palloc (pool, sizeof(char *) * argc);
+ for (i = 0; i < argc; i++)
+ {
+ /* Use "0" for default job ccsid. */
+ if (svn_utf_cstring_to_utf8_ex (&argv_utf8[i], argv[i], "0",
+ SVN_UTF_ETOU_XLATE_HANDLE, pool))
+ return EXIT_FAILURE;
+ }
+ apr_getopt_init (&os, pool, argc, argv_utf8);
+#endif
   os->interleave = 1;
   while (1)
     {
Index: subversion/svnserve/main.c
===================================================================
--- subversion/svnserve/main.c (revision 18362)
+++ subversion/svnserve/main.c (working copy)
@@ -100,6 +100,10 @@
 #define SVNSERVE_OPT_VERSION 260
 #define SVNSERVE_OPT_PID_FILE 261
 
+#if AS400_UTF8
+#define SVN_UTF_ETOU_XLATE_HANDLE "svn-utf-etou-xlate-handle"
+#endif
+
 static const apr_getopt_option_t svnserve__options[] =
   {
     {"daemon", 'd', 0, N_("daemon mode")},
@@ -273,6 +277,12 @@
   apr_status_t status;
   svn_ra_svn_conn_t *conn;
   apr_proc_t proc;
+#if AS400_UTF8
+ int i;
+ /* Even when compiled with UTF support in V5R4, argv is still
+ * encoded in ebcdic, so we'll need to convert it to utf-8. */
+ const char **argv_utf8;
+#endif
 #if APR_HAS_THREADS
   apr_threadattr_t *tattr;
   apr_thread_t *tid;
@@ -313,7 +323,20 @@
       return EXIT_FAILURE;
     }
 
+#if !AS400_UTF8
   apr_getopt_init(&os, pool, argc, argv);
+#else
+ /* Convert argv to utf-8 for call to apr_getopt_init(). */
+ argv_utf8 = apr_palloc(pool, sizeof(char *) * argc);
+ for (i = 0; i < argc; i++)
+ {
+ /* Use "0" for default job ccsid. */
+ if (svn_utf_cstring_to_utf8_ex(&argv_utf8[i], argv[i], "0",
+ SVN_UTF_ETOU_XLATE_HANDLE, pool))
+ return EXIT_FAILURE;
+ }
+ apr_getopt_init(&os, pool, argc, argv_utf8);
+#endif
 
   params.root = "/";
   params.tunnel = FALSE;
Index: subversion/svnsync/main.c
===================================================================
--- subversion/svnsync/main.c (revision 18362)
+++ subversion/svnsync/main.c (working copy)
@@ -23,6 +23,7 @@
 #include "svn_auth.h"
 #include "svn_opt.h"
 #include "svn_ra.h"
+#include "svn_utf.h"
 
 #include "svn_private_config.h"
 
@@ -38,6 +39,10 @@
 #define LAST_MERGED_REV_PROP PROP_PREFIX "last-merged-rev"
 #define CURRENTLY_COPYING_PROP PROP_PREFIX "currently-copying"
 
+#if AS400_UTF8
+#define SVN_UTF_ETOU_XLATE_HANDLE "svn-utf-etou-xlate-handle"
+#endif
+
 static svn_opt_subcommand_t initialize_cmd,
                             synchronize_cmd,
                             copy_revprops_cmd,
@@ -1165,6 +1170,11 @@
   apr_pool_t *pool;
   svn_error_t *err;
   int opt_id, i;
+#if AS400_UTF8
+ /* Even when compiled with UTF support in V5R4, argv is still
+ * encoded in ebcdic, so we'll need to convert it to utf-8. */
+ const char **argv_utf8;
+#endif
 
   if (svn_cmdline_init ("svnsync", stderr) != EXIT_SUCCESS)
     {
@@ -1200,7 +1210,20 @@
       return EXIT_FAILURE;
     }
 
+#if !AS400_UTF8
   apr_getopt_init (&os, pool, argc, argv);
+#else
+ /* Convert argv to utf-8 for call to apr_getopt_init(). */
+ argv_utf8 = apr_palloc (pool, sizeof(char *) * argc);
+ for (i = 0; i < argc; i++)
+ {
+ /* Use "0" for default job ccsid. */
+ if (svn_utf_cstring_to_utf8_ex (&argv_utf8[i], argv[i], "0",
+ SVN_UTF_ETOU_XLATE_HANDLE, pool))
+ return EXIT_FAILURE;
+ }
+ apr_getopt_init (&os, pool, argc, argv_utf8);
+#endif
 
   os->interleave = 1;
 
Index: subversion/svnversion/main.c
===================================================================
--- subversion/svnversion/main.c (revision 18362)
+++ subversion/svnversion/main.c (working copy)
@@ -25,6 +25,9 @@
 
 #define SVNVERSION_OPT_VERSION SVN_OPT_FIRST_LONGOPT_ID
 
+#if AS400_UTF8
+#define SVN_UTF_ETOU_XLATE_HANDLE "svn-utf-etou-xlate-handle"
+#endif
 
 static svn_error_t * version(apr_getopt_t *os, apr_pool_t *pool)
 {
@@ -124,6 +127,12 @@
       {"version", SVNVERSION_OPT_VERSION, 0, N_("show version
information")},
       {0, 0, 0, 0}
     };
+#if AS400_UTF8
+ int i;
+ /* Even when compiled with UTF support in V5R4, argv is still
+ * encoded in ebcdic, so we'll need to convert it to utf-8. */
+ const char **argv_utf8;
+#endif
 
   /* Initialize the app. */
   if (svn_cmdline_init ("svnversion", stderr) != EXIT_SUCCESS)
@@ -163,7 +172,20 @@
     }
 #endif
 
+#if !AS400_UTF8
   apr_getopt_init(&os, pool, argc, argv);
+#else
+ /* Convert argv to utf-8 for call to apr_getopt_init(). */
+ argv_utf8 = apr_palloc (pool, sizeof(char *) * argc);
+ for (i = 0; i < argc; i++)
+ {
+ /* Use "0" for default job ccsid. */
+ if (svn_utf_cstring_to_utf8_ex (&argv_utf8[i], argv[i], "0",
+ SVN_UTF_ETOU_XLATE_HANDLE, pool))
+ return EXIT_FAILURE;
+ }
+ apr_getopt_init (&os, pool, argc, argv_utf8);
+#endif
   os->interleave = 1;
   while (1)
     {

_____________________________________________________________________________
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 Feb 9 22:41:12 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.