I understand current GCC supports various source and target character
sets a lot better out of the box, so it may be EBCDIC isn't even an
issue any more. If there are other problems related to MVS host
I think the EBCDIC support is largely theoretical and not tested on any
actual EBCDIC host (or target). cpplib knows the character set name
UTF-EBCDIC, but whenever it does anything internally that involves the
encoding of its internal character set it uses UTF-8 rules (which is not
something valid to do with UTF-EBCDIC).
From the hercules-os380 files section, here's the relevant change
to 3.4.6 to stop it being theoretical:
Index: gccnew/gcc/cppcharset.c
diff -c gccnew/gcc/cppcharset.c:1.1.1.1 gccnew/gcc/cppcharset.c:1.6
*** gccnew/gcc/cppcharset.c:1.1.1.1 Wed Apr 15 16:26:16 2009
--- gccnew/gcc/cppcharset.c Wed May 13 11:07:08 2009
***************
*** 23,28 ****
--- 23,30 ----
#include "cpplib.h"
#include "cpphash.h"
#include "cppucnid.h"
+ #include "coretypes.h"
+ #include "tm.h"
/* Character set handling for C-family languages.
***************
*** 529,534 ****
--- 531,561 ----
return conversion_loop (one_utf32_to_utf8, cd, from, flen, to);
}
+ #ifdef MAP_OUTCHAR
+ /* convert ASCII to EBCDIC */
+ static bool
+ convert_asc_ebc (iconv_t cd ATTRIBUTE_UNUSED,
+ const uchar *from, size_t flen, struct _cpp_strbuf *to)
+ {
+ size_t x;
+ int c;
+
+ if (to->len + flen > to->asize)
+ {
+ to->asize = to->len + flen;
+ to->text = xrealloc (to->text, to->asize);
+ }
+ for (x = 0; x < flen; x++)
+ {
+ c = from[x];
+ c = MAP_OUTCHAR(c);
+ to->text[to->len + x] = c;
+ }
+ to->len += flen;
+ return true;
+ }
+ #endif
+
/* Identity conversion, used when we have no alternative. */
static bool
convert_no_conversion (iconv_t cd ATTRIBUTE_UNUSED,
***************
*** 606,611 ****
--- 633,641 ----
{ "UTF-32BE/UTF-8", convert_utf32_utf8, (iconv_t)1 },
{ "UTF-16LE/UTF-8", convert_utf16_utf8, (iconv_t)0 },
{ "UTF-16BE/UTF-8", convert_utf16_utf8, (iconv_t)1 },
+ #if defined(TARGET_EBCDIC)
+ { "UTF-8/UTF-EBCDIC", convert_asc_ebc, (iconv_t)0 },
+ #endif
};
/* Subroutine of cpp_init_iconv: initialize and return a
***************
*** 683,688 ****
--- 713,722 ----
bool be = CPP_OPTION (pfile, bytes_big_endian);
+ #if defined(TARGET_EBCDIC)
+ ncset = "UTF-EBCDIC";
+ wcset = "UTF-EBCDIC";
+ #else
if (CPP_OPTION (pfile, wchar_precision) >= 32)
default_wcset = be ? "UTF-32BE" : "UTF-32LE";
else if (CPP_OPTION (pfile, wchar_precision) >= 16)
***************
*** 696,701 ****
--- 730,736 ----
ncset = SOURCE_CHARSET;
if (!wcset)
wcset = default_wcset;
+ #endif
pfile->narrow_cset_desc = init_iconv_desc (pfile, ncset,
SOURCE_CHARSET);
pfile->wide_cset_desc = init_iconv_desc (pfile, wcset, SOURCE_CHARSET);
The generated code appears to be fine from visual inspection.
BFN. Paul.