summaryrefslogtreecommitdiff
path: root/tests/getprogname.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/getprogname.c')
-rw-r--r--tests/getprogname.c24
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;
}
}