about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-12-19 11:35:40 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-12-19 11:35:40 +0000
commit7a389a2fc3bd8a7884f7703bee606f829b408fc2 (patch)
treef5f7bd129e5936043586b379db31dff08d1c3919
parent809941459986c00660ef1077c3f5caa0860d77fe (diff)
downloadzsh-7a389a2fc3bd8a7884f7703bee606f829b408fc2.tar.gz
zsh-7a389a2fc3bd8a7884f7703bee606f829b408fc2.tar.xz
zsh-7a389a2fc3bd8a7884f7703bee606f829b408fc2.zip
22082: print out uid or gid in stat if name not available
-rw-r--r--ChangeLog5
-rw-r--r--Src/Modules/stat.c24
2 files changed, 23 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index f66e4cf96..57c670d58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-12-19  Peter Stephenson  <pws@csr.com>
+
+	* 22082: Src/Modules/stat.c: print out UID or GID instead
+	of ??? if the user or group name is unavailable.
+
 2005-12-18  Wayne Davison  <wayned@users.sourceforge.net>
 
 	* unposted: Etc/FAQ.yo, Zsh/contrib.yo: Changed some UTF-8
diff --git a/Src/Modules/stat.c b/Src/Modules/stat.c
index 188b37fc7..01a050703 100644
--- a/Src/Modules/stat.c
+++ b/Src/Modules/stat.c
@@ -140,10 +140,16 @@ statuidprint(uid_t uid, char *outbuf, int flags)
 #ifdef HAVE_GETPWUID
 	struct passwd *pwd;
 	pwd = getpwuid(uid);
-	strcat(outbuf, pwd ? pwd->pw_name : "???");
-#else /* !HAVE_GETPWUID */
-	strcat(outbuf, "???");
+	if (pwd)
+	    strcat(outbuf, pwd->pw_name);
+	else
 #endif /* !HAVE_GETPWUID */
+	{
+	    char *optr;
+	    for (optr = outbuf; *optr; optr++)
+		;
+	    sprintf(optr, "%lu", (unsigned long)uid);
+	}
 	if (flags & STF_RAW)
 	    strcat(outbuf, ")");
     }
@@ -163,10 +169,16 @@ statgidprint(gid_t gid, char *outbuf, int flags)
 #ifdef HAVE_GETGRGID
 	struct group *gr;
 	gr = getgrgid(gid);
-	strcat(outbuf, gr ? gr->gr_name : "???");
-#else /* !HAVE_GETGRGID */
-	strcat(outbuf, "???");
+	if (gr)
+	    strcat(outbuf, gr->gr_name);
+	else
 #endif /* !HAVE_GETGRGID */
+	{
+	    char *optr;
+	    for (optr = outbuf; *optr; optr++)
+		;
+	    sprintf(optr, "%lu", (unsigned long)gid);
+	}
 	if (flags & STF_RAW)
 	    strcat(outbuf, ")");
     }