bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getprogname: Port to Android 4.3


From: Bruno Haible
Subject: getprogname: Port to Android 4.3
Date: Sat, 26 Jan 2019 00:46:28 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )

On Android 4.3, this test fails:

FAIL: test-getprogname
======================

FAIL test-getprogname (exit status: 139)


The reason is that __progname contains the full argv[0], not just the last
component of it (like on OpenBSD).

This patch fixes it.


2019-01-25  Bruno Haible  <address@hidden>

        getprogname: Port to Android 4.3.
        * lib/getprogname.c (getprogname): On Android, take only the last
        component of __progname.

diff --git a/lib/getprogname.c b/lib/getprogname.c
index 09e65f8..1f264a1 100644
--- a/lib/getprogname.c
+++ b/lib/getprogname.c
@@ -73,7 +73,7 @@ getprogname (void)
   /* https://msdn.microsoft.com/en-us/library/dn727674.aspx */
   const char *p = __argv && __argv[0] ? __argv[0] : "?";
   return last_component (p);
-# elif HAVE_VAR___PROGNAME                                  /* OpenBSD, QNX */
+# elif HAVE_VAR___PROGNAME                                  /* OpenBSD, 
Android, QNX */
   /* https://man.openbsd.org/style.9 */
   /* 
http://www.qnx.de/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.neutrino_lib_ref%2Fp%2F__progname.html
 */
   /* Be careful to declare this only when we absolutely need it
@@ -82,7 +82,11 @@ getprogname (void)
      malfunction (have zero length) with Fedora 25's glibc.  */
   extern char *__progname;
   const char *p = __progname;
+#  if defined __ANDROID__
+  return last_component (p);
+#  else
   return p && p[0] ? p : "?";
+#  endif
 # elif _AIX                                                 /* AIX */
   /* Idea by Bastien ROUCARIÈS,
      https://lists.gnu.org/r/bug-gnulib/2010-12/msg00095.html




reply via email to

[Prev in Thread] Current Thread [Next in Thread]