* [PATCH] ident: add NO_GECOS_IN_PWENT for systems without pw_gecos in struct passwd
@ 2011-05-19 11:37 Rafael Gieschke
0 siblings, 0 replies; only message in thread
From: Rafael Gieschke @ 2011-05-19 11:37 UTC (permalink / raw)
To: git, Junio C Hamano
NO_GECOS_IN_PWENT is defined in Makefile. If set, struct_passwd->pw_gecos is
not used but the capitalized login name is taken as a substitute.
Signed-off-by: Rafael Gieschke <rafael@gieschke.de>
---
Makefile | 6 ++++++
ident.c | 8 +++++++-
2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index d7147cf..de79c8f 100644
--- a/Makefile
+++ b/Makefile
@@ -71,6 +71,9 @@ all::
#
# Define NO_STRTOK_R if you don't have strtok_r in the C library.
#
+# Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
+# in the C library.
+#
# Define NO_FNMATCH if you don't have fnmatch in the C library.
#
# Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
@@ -1406,6 +1409,9 @@ ifdef NO_STRTOK_R
COMPAT_CFLAGS += -DNO_STRTOK_R
COMPAT_OBJS += compat/strtok_r.o
endif
+ifdef NO_GECOS_IN_PWENT
+ COMPAT_CFLAGS += -DNO_GECOS_IN_PWENT
+endif
ifdef NO_FNMATCH
COMPAT_CFLAGS += -Icompat/fnmatch
COMPAT_CFLAGS += -DNO_FNMATCH
diff --git a/ident.c b/ident.c
index 8e56b5e..bcd04e0 100644
--- a/ident.c
+++ b/ident.c
@@ -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;
@@ -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;
--
1.7.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-05-19 11:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-19 11:37 [PATCH] ident: add NO_GECOS_IN_PWENT for systems without pw_gecos in struct passwd Rafael Gieschke
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 NNTP newsgroup(s).