Skip to content

Commit

Permalink
Merge branch 'rg/no-gecos-in-pwent'
Browse files Browse the repository at this point in the history
* rg/no-gecos-in-pwent:
  ident: add NO_GECOS_IN_PWENT for systems without pw_gecos in struct passwd

Conflicts:
	Makefile
  • Loading branch information
Junio C Hamano committed May 26, 2011
2 parents ce5e953 + 590e081 commit 8784e4d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ all::
# Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
# FNM_CASEFOLD GNU extension.
#
# Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
# in the C library.
#
# Define NO_LIBGEN_H if you don't have libgen.h.
#
# Define NEEDS_LIBGEN if your libgen needs -lgen when linking
Expand Down
8 changes: 7 additions & 1 deletion ident.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

static char git_default_date[50];

#ifdef NO_GECOS_IN_PWENT
#define get_gecos(ignored) "&"
#else
#define get_gecos(struct_passwd) ((struct_passwd)->pw_gecos)
#endif

static void copy_gecos(const struct passwd *w, char *name, size_t sz)
{
char *src, *dst;
Expand All @@ -20,7 +26,7 @@ static void copy_gecos(const struct passwd *w, char *name, size_t sz)
* with commas. Also & stands for capitalized form of the login name.
*/

for (len = 0, dst = name, src = w->pw_gecos; len < sz; src++) {
for (len = 0, dst = name, src = get_gecos(w); len < sz; src++) {
int ch = *src;
if (ch != '&') {
*dst++ = ch;
Expand Down

0 comments on commit 8784e4d

Please sign in to comment.