{"thread":{"id":"27404","subject":"[PATCH] ident: add NO_GECOS_IN_PWENT for systems without pw_gecos in struct passwd","startedAt":"2011-05-19T11:37:55Z","lastAt":"2011-05-19T11:37:55Z","messageCount":1,"participants":["Rafael Gieschke"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"168208","messageId":"A5E9A01E-716A-4A34-96C6-C489CDF2CFDE@gieschke.de","threadId":"27404","inReplyTo":null,"subject":"[PATCH] ident: add NO_GECOS_IN_PWENT for systems without pw_gecos in struct passwd","fromName":"Rafael Gieschke","fromEmail":"rafael@gieschke.de","sentAt":"2011-05-19T11:37:55Z","receivedAt":"2011-05-19T11:37:55Z","isPatch":true,"sender":{"key":"rafael@gieschke.de","avatar":"https://avatars.githubusercontent.com/u/6069565?v=4"},"body":"\nNO_GECOS_IN_PWENT is defined in Makefile. If set, struct_passwd->pw_gecos is\nnot used but the capitalized login name is taken as a substitute.\n\nSigned-off-by: Rafael Gieschke <rafael@gieschke.de>\n---\n Makefile |    6 ++++++\n ident.c  |    8 +++++++-\n 2 files changed, 13 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex d7147cf..de79c8f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -71,6 +71,9 @@ all::\n #\n # Define NO_STRTOK_R if you don't have strtok_r in the C library.\n #\n+# Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd\n+# in the C library.\n+#\n # Define NO_FNMATCH if you don't have fnmatch in the C library.\n #\n # Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the\n@@ -1406,6 +1409,9 @@ ifdef NO_STRTOK_R\n \tCOMPAT_CFLAGS += -DNO_STRTOK_R\n \tCOMPAT_OBJS += compat/strtok_r.o\n endif\n+ifdef NO_GECOS_IN_PWENT\n+\tCOMPAT_CFLAGS += -DNO_GECOS_IN_PWENT\n+endif\n ifdef NO_FNMATCH\n \tCOMPAT_CFLAGS += -Icompat/fnmatch\n \tCOMPAT_CFLAGS += -DNO_FNMATCH\ndiff --git a/ident.c b/ident.c\nindex 8e56b5e..bcd04e0 100644\n--- a/ident.c\n+++ b/ident.c\n@@ -9,6 +9,12 @@\n \n static char git_default_date[50];\n \n+#ifdef NO_GECOS_IN_PWENT\n+#define get_gecos(ignored) \"&\"\n+#else\n+#define get_gecos(struct_passwd) (struct_passwd->pw_gecos)\n+#endif\n+\n static void copy_gecos(const struct passwd *w, char *name, size_t sz)\n {\n \tchar *src, *dst;\n@@ -20,7 +26,7 @@ static void copy_gecos(const struct passwd *w, char *name, size_t sz)\n \t * with commas.  Also & stands for capitalized form of the login name.\n \t */\n \n-\tfor (len = 0, dst = name, src = w->pw_gecos; len < sz; src++) {\n+\tfor (len = 0, dst = name, src = get_gecos(w); len < sz; src++) {\n \t\tint ch = *src;\n \t\tif (ch != '&') {\n \t\t\t*dst++ = ch;\n-- \n1.7.4\n"}]}