[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: Paul Burba <paulb_at_softlanding.com>
Date: 2006-02-15 16:54:00 CET

Philip Martin <philip@codematters.co.uk> wrote on 02/14/2006 12:24:08 PM:

> Paul Burba <paulb@softlanding.com> writes:

> > - 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

In V5R4 IBM defines APR_LOCALE_CHARSET this way:

#define APR_LOCALE_CHARSET (int)1208

So we can't stringify it, we'd get "(int)1208". At least that's the way
it works on OS400, I confess that the whole APR_STRINGIFY macro puzzles
me:

#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
/** Helper macro for APR_STRINGIFY */
#define APR_STRINGIFY_HELPER(n) #n

It doesn't look like it should do anything to me, if anyone wants to
explain this they have my eternal gratitude, I have no cash prizes to
offer :-)

Anyway...
 
> 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

I took this second approach and put the following in svn_utf.h (as my
other e-mail mentioned I'm open to putting this somewhere more
appropriate, but for now it's here):

#ifndef AS400
#define SVN_APR_LOCALE_CHARSET APR_LOCALE_CHARSET
#define SVN_APR_DEFAULT_CHARSET APR_DEFAULT_CHARSET
#else
/* APR_LOCALE_CHARSET and APR_DEFAULT_CHARSET are defined as ints on
 * OS400. */
#define SVN_APR_LOCALE_CHARSET (const char*)APR_LOCALE_CHARSET
#define SVN_APR_DEFAULT_CHARSET (const char*)APR_DEFAULT_CHARSET
#endif

The replacement for SVN_APR_DEFAULT_CHARSET isn't technically needed right
now, but seems appropriate(?) to add to minimize confusion.
 
> > --- 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?

Yes, but even better, as I read your ideas I realized I don't need to use
strings like "1208" anywhere. (const char*)1208 works fine and the only
change needed is to cast topage and frompage to ints when calling
apr_xlate_open().

> > +#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)

I took the latter approach and put it in utf.c:

> depending on whether you use APR_STRINGIFY or "cast to char*".
>
> --
> Philip Martin

Thanks for the help Philip, a new log and much smaller patch follow.

Paul B.

[[[
* subversion/include/svn_utf.h
   (SVN_APR_LOCALE_CHARSET, SVN_APR_DEFAULT_CHARSET): New symbol
    replacements for APR_LOCALE_CHARSET and APR_DEFAULT_CHARSET
    respectively.
* 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):
    Use SVN_APR_LOCALE_CHARSET in place of APR_LOCALE_CHARSET.

* subversion/libsvn_subr/utf.c
   (SVN_APR_UTF8_CHARSET) New symbolic constant.
   (get_xlate_handle_node): Use SVN_APR_DEFAULT_CHARSET and
    SVN_APR_LOCALE_CHARSET in place of APR_DEFAULT_CHARSET and
    APR_LOCALE_CHARSET respectively. Disable assert that doesn't
    apply to V5R4 and handle error condition this may now permit.
    Cast arguments to apr_xlate_open() to agree with OS400 signature.
   (convert_to_stringbuf): Account for fact xlate_handle_node_t
    topage and frompage members are always ints on OS400 when
    creating error messages.
]]]

_____________________________________________________________________________
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 Wed Feb 15 17:16:16 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.