diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2005-12-19 11:35:40 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2005-12-19 11:35:40 +0000 |
commit | 7a389a2fc3bd8a7884f7703bee606f829b408fc2 (patch) | |
tree | f5f7bd129e5936043586b379db31dff08d1c3919 /Src/Modules | |
parent | 809941459986c00660ef1077c3f5caa0860d77fe (diff) | |
download | zsh-7a389a2fc3bd8a7884f7703bee606f829b408fc2.tar.gz zsh-7a389a2fc3bd8a7884f7703bee606f829b408fc2.tar.xz zsh-7a389a2fc3bd8a7884f7703bee606f829b408fc2.zip |
22082: print out uid or gid in stat if name not available
Diffstat (limited to 'Src/Modules')
-rw-r--r-- | Src/Modules/stat.c | 24 |
1 files changed, 18 insertions, 6 deletions
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, ")"); } |