diff options
Diffstat (limited to 'gl/getprogname.c')
-rw-r--r-- | gl/getprogname.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/gl/getprogname.c b/gl/getprogname.c index 32c9604..392a9a2 100644 --- a/gl/getprogname.c +++ b/gl/getprogname.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* Program name management. | 1 | /* Program name management. |
2 | Copyright (C) 2016-2023 Free Software Foundation, Inc. | 2 | Copyright (C) 2016-2024 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software: you can redistribute it and/or modify | 4 | This program is free software: you can redistribute it and/or modify |
5 | it under the terms of the GNU Lesser General Public License as published by | 5 | it under the terms of the GNU Lesser General Public License as published by |
@@ -16,11 +16,10 @@ | |||
16 | 16 | ||
17 | #include <config.h> | 17 | #include <config.h> |
18 | 18 | ||
19 | /* Specification. */ | 19 | /* Specification. Also get __argv declaration. */ |
20 | #include "getprogname.h" | 20 | #include <stdlib.h> |
21 | 21 | ||
22 | #include <errno.h> /* get program_invocation_name declaration */ | 22 | #include <errno.h> /* get program_invocation_name declaration */ |
23 | #include <stdlib.h> /* get __argv declaration */ | ||
24 | 23 | ||
25 | #ifdef _AIX | 24 | #ifdef _AIX |
26 | # include <unistd.h> | 25 | # include <unistd.h> |
@@ -53,13 +52,12 @@ | |||
53 | 52 | ||
54 | #if defined __SCO_VERSION__ || defined __sysv5__ | 53 | #if defined __SCO_VERSION__ || defined __sysv5__ |
55 | # include <fcntl.h> | 54 | # include <fcntl.h> |
56 | # include <stdlib.h> | ||
57 | # include <string.h> | 55 | # include <string.h> |
58 | #endif | 56 | #endif |
59 | 57 | ||
60 | #include "basename-lgpl.h" | 58 | #include "basename-lgpl.h" |
61 | 59 | ||
62 | #ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */ | 60 | #ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Solaris >= 11, Cygwin, Android API level >= 21 */ |
63 | char const * | 61 | char const * |
64 | getprogname (void) | 62 | getprogname (void) |
65 | { | 63 | { |
@@ -214,7 +212,19 @@ getprogname (void) | |||
214 | { | 212 | { |
215 | char *s = strdup (last_component (buf.ps_pathptr)); | 213 | char *s = strdup (last_component (buf.ps_pathptr)); |
216 | if (s) | 214 | if (s) |
217 | p = s; | 215 | { |
216 | # if defined __XPLINK__ && __CHARSET_LIB == 1 | ||
217 | /* The compiler option -qascii is in use. | ||
218 | https://makingdeveloperslivesbetter.wordpress.com/2022/01/07/is-z-os-ascii-or-ebcdic-yes/ | ||
219 | https://www.ibm.com/docs/en/zos/2.5.0?topic=features-macros-related-compiler-option-settings | ||
220 | So, convert the result from EBCDIC to ASCII. | ||
221 | https://www.ibm.com/docs/en/zos/2.5.0?topic=functions-e2a-s-convert-string-from-ebcdic-ascii */ | ||
222 | if (__e2a_s (s) == (size_t)-1) | ||
223 | free (s); | ||
224 | else | ||
225 | # endif | ||
226 | p = s; | ||
227 | } | ||
218 | break; | 228 | break; |
219 | } | 229 | } |
220 | } | 230 | } |