]> git.eshelyaron.com Git - emacs.git/commitdiff
Port to certain Android environments with no GUI
authorPo Lu <luangruo@yahoo.com>
Fri, 17 May 2024 11:21:05 +0000 (19:21 +0800)
committerEshel Yaron <me@eshelyaron.com>
Sat, 18 May 2024 18:52:31 +0000 (20:52 +0200)
* configure.ac (USER_FULL_NAME): Define to
android_user_full_name only when a GUI system is being built.
Otherwise, set to pw->pw_gecos or NULL consistently with the
presence of pw->pw_gecos.

* src/editfns.c (Fuser_full_name): Adjust to match.  Accept NULL
values from USER_FULL_NAME.

(cherry picked from commit 1f08984a67c94e957bec7f8c59818b627a67427b)

configure.ac
src/editfns.c

index 8821d3b3330274355946bbcc248e1fdac286c177..47a657a6d2048cd292cb03f29e631f64188e51c3 100644 (file)
@@ -2464,11 +2464,6 @@ AC_DEFINE_UNQUOTED([SYSTEM_TYPE], ["$SYSTEM_TYPE"],
   [The type of system you are compiling for; sets 'system-type'.])
 AC_SUBST([SYSTEM_TYPE])
 
-# Check for pw_gecos in struct passwd; this is known to be missing on
-# Android.
-
-AC_CHECK_MEMBERS([struct passwd.pw_gecos], [], [], [#include <pwd.h>])
-
 pre_PKG_CONFIG_CFLAGS=$CFLAGS
 pre_PKG_CONFIG_LIBS=$LIBS
 
@@ -2754,6 +2749,17 @@ AC_SUBST([ANDROID_BUILD_CFLAGS])
 AC_SUBST([ANDROID_SHARED_USER_ID])
 AC_SUBST([ANDROID_SHARED_USER_NAME])
 
+# Check for pw_gecos in struct passwd; this is known to be missing on
+# Android.
+
+AH_TEMPLATE([USER_FULL_NAME], [How to get a user's full name.])
+AC_CHECK_MEMBERS([struct passwd.pw_gecos], [], [], [#include <pwd.h>])
+AS_IF([test x"$REALLY_ANDROID" = "xyes"],
+  [AC_DEFINE([USER_FULL_NAME], [android_user_full_name (pw)])],
+  [AS_IF([test x"$ac_cv_member_struct_passwd_pw_gecos" = "xyes"],
+    [AC_DEFINE([USER_FULL_NAME], [pw->pw_gecos])],
+    [AC_DEFINE([USER_FULL_NAME], [NULL])])])
+
 if test "${with_pgtk}" = "yes"; then
   window_system=pgtk
 fi
@@ -6493,9 +6499,6 @@ AC_SUBST([SEPCHAR])
 dnl Everybody supports this, except MS-DOS.
 AC_DEFINE([subprocesses], [1], [Define to enable asynchronous subprocesses.])
 
-AC_DEFINE([USER_FULL_NAME], [pw->pw_gecos], [How to get a user's full name.])
-
-
 AC_DEFINE([DIRECTORY_SEP], ['/'],
   [Character that separates directories in a file name.])
 
index fbfaaf666449f5abb0414492acfaffa0d37a1e90..6b110b3d0e00145f42e382483edff896cc3b6b5f 100644 (file)
@@ -1247,11 +1247,10 @@ is in general a comma-separated list.  */)
   if (!pw)
     return Qnil;
 
-#if defined HAVE_ANDROID && !defined ANDROID_STUBIFY
-  p = android_user_full_name (pw);
-#else
   p = USER_FULL_NAME;
-#endif
+  if (!p)
+    return Qnil;
+
   /* Chop off everything after the first comma, since 'pw_gecos' is a
      comma-separated list. */
   q = strchr (p, ',');