Skip to content

Commit 8784e4d

Browse files
committed
Merge branch 'rg/no-gecos-in-pwent'
* rg/no-gecos-in-pwent: ident: add NO_GECOS_IN_PWENT for systems without pw_gecos in struct passwd Conflicts: Makefile
2 parents ce5e953 + 590e081 commit 8784e4d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ all::
7070
# Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
7171
# FNM_CASEFOLD GNU extension.
7272
#
73+
# Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
74+
# in the C library.
75+
#
7376
# Define NO_LIBGEN_H if you don't have libgen.h.
7477
#
7578
# Define NEEDS_LIBGEN if your libgen needs -lgen when linking

ident.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
static char git_default_date[50];
1111

12+
#ifdef NO_GECOS_IN_PWENT
13+
#define get_gecos(ignored) "&"
14+
#else
15+
#define get_gecos(struct_passwd) ((struct_passwd)->pw_gecos)
16+
#endif
17+
1218
static void copy_gecos(const struct passwd *w, char *name, size_t sz)
1319
{
1420
char *src, *dst;
@@ -20,7 +26,7 @@ static void copy_gecos(const struct passwd *w, char *name, size_t sz)
2026
* with commas. Also & stands for capitalized form of the login name.
2127
*/
2228

23-
for (len = 0, dst = name, src = w->pw_gecos; len < sz; src++) {
29+
for (len = 0, dst = name, src = get_gecos(w); len < sz; src++) {
2430
int ch = *src;
2531
if (ch != '&') {
2632
*dst++ = ch;

0 commit comments

Comments
 (0)