From: Jules Tamagnan <jtamagnan@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 33195@debbugs.gnu.org
Subject: bug#33195: 27.0.50; user-login-name has no group-login-name
Date: Tue, 30 Oct 2018 11:28:16 -0700 [thread overview]
Message-ID: <87tvl3cmrj.fsf@gmail.com> (raw)
In-Reply-To: <837ehzlo3a.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 30 Oct 2018 12:34:49 +0200")
[-- Attachment #1: Type: text/plain, Size: 94 bytes --]
I noticed that I had marked GID as optional in the manual, below is a
patch with that fixed.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch-2 --]
[-- Type: text/x-diff, Size: 2922 bytes --]
From 5c67d0177ba14428e6e3f5acdaf34c2be7ee93be Mon Sep 17 00:00:00 2001
From: Jules Tamagnan <jtamagnan@gmail.com>
Date: Tue, 30 Oct 2018 10:22:03 -0700
Subject: [PATCH] src/editfns.c (group-name): New function.
---
doc/lispref/os.texi | 5 +++++
etc/NEWS | 3 +++
src/editfns.c | 16 ++++++++++++++++
test/src/editfns-tests.el | 7 +++++++
4 files changed, 31 insertions(+)
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index cb33757..6d1b3f3 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -1230,6 +1230,11 @@ User Identification
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
diff --git a/etc/NEWS b/etc/NEWS
index 226ae1e..a0bcbb5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1228,6 +1228,9 @@ where there's no better alternative. We believe that the incorrect
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
diff --git a/src/editfns.c b/src/editfns.c
index e995b38..15a0fa7 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1143,6 +1143,21 @@ of the user with that uid, or nil if there is no such user. */)
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.
@@ -4487,6 +4502,7 @@ it to be non-nil. */);
defsubr (&Sinsert_byte);
defsubr (&Suser_login_name);
+ defsubr (&Sgroup_name);
defsubr (&Suser_real_login_name);
defsubr (&Suser_uid);
defsubr (&Suser_real_uid);
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
index 17b2c51..6ee0ab0 100644
--- a/test/src/editfns-tests.el
+++ b/test/src/editfns-tests.el
@@ -351,4 +351,11 @@ transpose-test-get-byte-positions
(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
--
2.7.4
next prev parent reply other threads:[~2018-10-30 18:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-29 18:52 bug#33195: 27.0.50; user-login-name has no group-login-name Jules Tamagnan
2018-10-30 10:34 ` Eli Zaretskii
2018-10-30 18:25 ` Jules Tamagnan
2018-11-10 18:36 ` Glenn Morris
2018-11-10 18:49 ` Glenn Morris
2018-11-10 19:00 ` Jules Tamagnan
2018-11-10 19:12 ` Glenn Morris
2018-11-10 19:15 ` Eli Zaretskii
2018-11-10 21:02 ` Andreas Schwab
2018-11-11 3:17 ` Glenn Morris
2018-10-30 18:28 ` Jules Tamagnan [this message]
2018-11-10 9:24 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tvl3cmrj.fsf@gmail.com \
--to=jtamagnan@gmail.com \
--cc=33195@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).