Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Commit e8bf52a

Browse files
gabylbrichardlau
authored andcommitted
Apply EBCDIC to ASCII conversions only if node wasn't built with -qASCII (#138)
PR-URL: #138 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent 2bf09c6 commit e8bf52a

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

src/utilities.cc

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <sys/procfs.h> // psinfo_t structure
1111
#endif
1212
#ifdef __MVS__
13+
#include <_Nascii.h>
1314
extern "C" char **__getargv_a(void);
1415
extern "C" int __getargc(void);
1516
extern "C" void *_convert_e2a(void *dst, const void *src, size_t size);
@@ -304,8 +305,10 @@ void reportEndpoint(uv_handle_t* h, struct sockaddr* addr, const char* prefix,
304305
uv_getnameinfo_t endpoint;
305306
if (uv_getnameinfo(h->loop, &endpoint, nullptr, addr, NI_NUMERICSERV) == 0) {
306307
#ifdef __MVS__
307-
__e2a_s(endpoint.host);
308-
__e2a_s(endpoint.service);
308+
if (__isASCII() == 0) {
309+
__e2a_s(endpoint.host);
310+
__e2a_s(endpoint.service);
311+
}
309312
#endif
310313
out << prefix << endpoint.host << ":" << endpoint.service;
311314
} else {
@@ -321,7 +324,9 @@ void reportEndpoint(uv_handle_t* h, struct sockaddr* addr, const char* prefix,
321324
reinterpret_cast<sockaddr_in*>(addr)->sin_port :
322325
reinterpret_cast<sockaddr_in6*>(addr)->sin6_port);
323326
#ifdef __MVS__
324-
__e2a_s(host);
327+
if (__isASCII() == 0) {
328+
__e2a_s(host);
329+
}
325330
#endif
326331
out << prefix << host << ":" << port;
327332
}
@@ -400,14 +405,20 @@ void reportPath(uv_handle_t* h, std::ostringstream& out) {
400405
if (rc == 0) {
401406
// buffer is not null terminated.
402407
#ifdef __MVS__
403-
char *tmpbuf = (char*)malloc(size);
404-
_convert_e2a(tmpbuf, buffer, size);
405-
std::string name(tmpbuf, size);
406-
free(tmpbuf);
408+
if (__isASCII() == 0) {
409+
char *tmpbuf = (char*)malloc(size);
410+
_convert_e2a(tmpbuf, buffer, size);
411+
std::string name(tmpbuf, size);
412+
free(tmpbuf);
413+
out << "filename: " << name;
414+
} else {
415+
std::string name(buffer, size);
416+
out << "filename: " << name;
417+
}
407418
#else
408419
std::string name(buffer, size);
409-
#endif
410420
out << "filename: " << name;
421+
#endif
411422
}
412423
free(buffer);
413424
}

0 commit comments

Comments
 (0)