return value is @code{nil}.
@end defun
+@defun user-login-name gid
+This runction returns the group name that corresponds to @var{gid},
+or @code{nil} if there is no such group.
+@end defun
+
@node Time of Day
@section Time of Day
uses of this function all but disappeared by now, so we are
un-obsoleting it.
++++
+** New function 'group-name' returns a group name based on a group-GID
+
\f
* Changes in Emacs 27.1 on Non-Free Operating Systems
return (pw ? build_string (pw->pw_name) : Qnil);
}
+DEFUN ("group-name", Fgroup_name, Sgroup_name, 1, 1, 0,
+ doc: /* If argument GID is an integer or a float, return the login name
+of the group with that gid, or nil if there is no such GID. */)
+ (Lisp_Object gid)
+{
+ struct group *gr;
+ gid_t id;
+
+ CONS_TO_INTEGER (gid, gid_t, id);
+ block_input ();
+ gr = getgrgid (id);
+ unblock_input ();
+ return (gr ? build_string (gr->gr_name) : Qnil);
+}
+
DEFUN ("user-real-login-name", Fuser_real_login_name, Suser_real_login_name,
0, 0, 0,
doc: /* Return the name of the user's real uid, as a string.
defsubr (&Sinsert_byte);
defsubr (&Suser_login_name);
+ defsubr (&Sgroup_name);
defsubr (&Suser_real_login_name);
defsubr (&Suser_uid);
defsubr (&Suser_real_uid);
(should (equal (format "%-#50.40x" v3)
"-0x000000003ffffffffffffffe000000000000000 "))))
+(ert-deftest group-name ()
+ (let ((list `((0 . "root")
+ (1000 . ,(user-login-name 1000))
+ (1212345 . nil))))
+ (dolist (test list)
+ (should (equal (group-name (car test)) (cdr test))))))
+
;;; editfns-tests.el ends here