diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2024-03-03 19:11:32 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2024-03-03 19:11:32 +0100 |
commit | 00893e79fc62966067af1a106567db96bd170338 (patch) | |
tree | 52b35cd0b42ca28e62a2ffbecade2e13dd8332cf /tests/getprogname.c | |
parent | 26112352a774737e1ce5580c93654a26c1e82b39 (diff) |
New upstream version 1.2upstream/1.2
Diffstat (limited to 'tests/getprogname.c')
-rw-r--r-- | tests/getprogname.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/getprogname.c b/tests/getprogname.c index 62a48004..392a9a2f 100644 --- a/tests/getprogname.c +++ b/tests/getprogname.c @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2016-2022 Free Software Foundation, Inc. + Copyright (C) 2016-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -16,11 +16,10 @@ #include <config.h> -/* Specification. */ -#include "getprogname.h" +/* Specification. Also get __argv declaration. */ +#include <stdlib.h> #include <errno.h> /* get program_invocation_name declaration */ -#include <stdlib.h> /* get __argv declaration */ #ifdef _AIX # include <unistd.h> @@ -53,13 +52,12 @@ #if defined __SCO_VERSION__ || defined __sysv5__ # include <fcntl.h> -# include <stdlib.h> # include <string.h> #endif #include "basename-lgpl.h" -#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */ +#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Solaris >= 11, Cygwin, Android API level >= 21 */ char const * getprogname (void) { @@ -214,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; } } |