You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by od...@apache.org on 2008/05/21 13:12:10 UTC
svn commit: r658629 - in
/harmony/enhanced/classlib/trunk/modules/portlib/src:
main/native/port/unix/hyfiletext.c test/native/hyfile/shared/hyfile.c
Author: odeakin
Date: Wed May 21 04:12:10 2008
New Revision: 658629
URL: http://svn.apache.org/viewvc?rev=658629&view=rev
Log:
Make sure we convert strings on EBCDIC platforms correctly.
Modified:
harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hyfiletext.c
harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/shared/hyfile.c
Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hyfiletext.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hyfiletext.c?rev=658629&r1=658628&r2=658629&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hyfiletext.c (original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/hyfiletext.c Wed May 21 04:12:10 2008
@@ -49,6 +49,9 @@
#endif
/* a2e overrides nl_langinfo to return ASCII strings. We need the native EBCDIC string */
+#if defined(ZOS) && defined (nl_langinfo)
+#undef nl_langinfo
+#endif
#define CDEV_CURRENT_FUNCTION _prototypes_private
#if (defined(HYVM_USE_ICONV))
@@ -105,9 +108,18 @@
char* outBuf = NULL;
IDATA i;
int requiresTranslation = 0;
-
+#ifdef ZOS
+#pragma convlit(suspend)
+#endif /* ZOS */
const char *utf8Encoding = "UTF-8";
-
+#ifdef ZOS
+#pragma convlit(resume)
+#endif /* ZOS */
+
+#ifdef ZOS
+ /* z/OS always needs to translate to EBCDIC */
+ requiresTranslation = 1;
+#else
/* we can short circuit if the string is all ASCII */
for (i = 0; i < nbytes; i++)
{
@@ -117,6 +129,7 @@
break;
}
}
+#endif /* ZOS */
if (!requiresTranslation
|| strcmp (nl_langinfo (CODESET), utf8Encoding) == 0)
@@ -157,8 +170,18 @@
IDATA result, i;
int requiresTranslation = 0;
+#ifdef ZOS
+#pragma convlit(suspend)
+#endif
const char *utf8Encoding = "UTF-8";
+#ifdef ZOS
+#pragma convlit(resume)
+#endif
+#ifdef ZOS
+ /* z/OS always needs to translate to EBCDIC */
+ requiresTranslation = 1;
+#else
/* we can short circuit if the string is all ASCII */
for (i = 0; i < nbytes; i++)
{
@@ -168,6 +191,7 @@
break;
}
}
+#endif /* ZOS */
if (!requiresTranslation
|| strcmp (nl_langinfo (CODESET), utf8Encoding) == 0)
@@ -371,8 +395,16 @@
iconv_t converter;
size_t inbytesleft, outbytesleft;
char *inbuf, *outbuf;
+
/* iconv_open is not an a2e function, so we need to pass it honest-to-goodness EBCDIC strings */
+#ifdef ZOS
+#pragma convlit(suspend)
+#endif /* ZOS */
converter = iconv_open (nl_langinfo (CODESET), "UTF-8");
+#ifdef ZOS
+#pragma convlit(resume)
+#endif /* ZOS */
+
if (converter == (iconv_t) - 1)
{
/* no converter available for this code set. Just dump the UTF-8 chars */
Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/shared/hyfile.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/shared/hyfile.c?rev=658629&r1=658628&r2=658629&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/shared/hyfile.c (original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/test/native/hyfile/shared/hyfile.c Wed May 21 04:12:10 2008
@@ -266,6 +266,14 @@
IDATA bytes;
char tmpAbsolutePath[255];
char buf[255];
+
+#ifdef ZOS
+#pragma convlit(suspend)
+#endif
+ char resultString[] = "000000009 -0002 3.14";
+#ifdef ZOS
+#pragma convlit(resume)
+#endif
printf("testing hyfile_printf......\n");
generateAbsoluteFilePath(hyportLibrary,tmpAbsolutePath,"hytest.tmp");
@@ -279,10 +287,9 @@
cleanup(*hyportLibrary);
return -1;
}
-
+
hyportLibrary->file_printf(hyportLibrary, fd, "%09d %7.4d %7.2f",9,-2,3.1415926535);
-
rc = hyportLibrary->file_close(hyportLibrary, fd);
if (rc != 0) {
Hytest_setErrMsg(hyportLibrary, "hyfile_close failed %s(%s)\n",
@@ -314,8 +321,8 @@
}
- if (strcmp(buf, "000000009 -0002 3.14") != 0) {
- Hytest_setErrMsg(hyportLibrary, "Output should be [%s] not [%s] (%s)\n","000000009 -0002 3.14",buf,HY_GET_CALLSITE());
+ if (strcmp(buf, resultString) != 0) {
+ Hytest_setErrMsg(hyportLibrary, "Output should be [%s] not [%s] (%s)\n", resultString, buf, HY_GET_CALLSITE());
hyportLibrary->file_close(hyportLibrary, fd);
cleanup(*hyportLibrary);
return -1;
@@ -544,6 +551,14 @@
IDATA bytes;
char tmpAbsolutePath[255];
char buf[20];
+
+#ifdef ZOS
+#pragma convlit(suspend)
+#endif
+ char resultString[] = "01234";
+#ifdef ZOS
+#pragma convlit(resume)
+#endif
printf("testing hyfile_read......\n");
generateAbsoluteFilePath(hyportLibrary,tmpAbsolutePath,"hytest.tmp");
@@ -597,8 +612,8 @@
return -1;
}
- if (strcmp(buf, "01234") != 0) {
- Hytest_setErrMsg(hyportLibrary, "Output should be [%s] not [%s] (%s)\n","02134",buf,HY_GET_CALLSITE());
+ if (strcmp(buf, resultString) != 0) {
+ Hytest_setErrMsg(hyportLibrary, "Output should be [%s] not [%s] (%s)\n", resultString, buf, HY_GET_CALLSITE());
hyportLibrary->file_close(hyportLibrary, fd);
cleanup(*hyportLibrary);
return -1;