From: Bruno Haible Date: Thu, 1 Jun 2023 14:18:02 +0000 (+0200) Subject: getprogname: Add support for ASCII-compatible environments in z/OS. X-Git-Tag: v1.0~1271 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=eaafa28803d0a694d7c3b25241d84e26a02ba7a7;p=gnulib.git getprogname: Add support for ASCII-compatible environments in z/OS. Reported by Mike Fulton in . * lib/getprogname.c (getprogname): On z/OS, when compiling for an ASCII-compatible environment, convert the result from EBCDIC to ASCII. --- diff --git a/ChangeLog b/ChangeLog index 74c17eaf1d..b48ca091ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2023-06-01 Bruno Haible + + getprogname: Add support for ASCII-compatible environments in z/OS. + Reported by Mike Fulton in + . + * lib/getprogname.c (getprogname): On z/OS, when compiling for an + ASCII-compatible environment, convert the result from EBCDIC to ASCII. + 2023-06-01 Mitch Capper gnulib-tool.py: Fix a format string mistake. diff --git a/lib/getprogname.c b/lib/getprogname.c index 279d79f012..204855a4a8 100644 --- a/lib/getprogname.c +++ b/lib/getprogname.c @@ -212,7 +212,19 @@ getprogname (void) { char *s = strdup (last_component (buf.ps_pathptr)); if (s) - p = s; + { +# if defined __XPLINK__ && __CHARSET_LIB == 1 + /* The compiler option -qascii is in use. + https://makingdeveloperslivesbetter.wordpress.com/2022/01/07/is-z-os-ascii-or-ebcdic-yes/ + https://www.ibm.com/docs/en/zos/2.5.0?topic=features-macros-related-compiler-option-settings + So, convert the result from EBCDIC to ASCII. + https://www.ibm.com/docs/en/zos/2.5.0?topic=functions-e2a-s-convert-string-from-ebcdic-ascii */ + if (__e2a_s (s) == (size_t)-1) + free (s); + else +# endif + p = s; + } break; } }