From bc1ccaccb5b7ec71775a5eb7e529bb93811956ce Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 13 Aug 2016 15:19:29 -0500 Subject: Move getusername/getgroupname to lib. (Return name or string representation of number, but never NULL. Both returned in static buffer good through next call.) --- toys/posix/ls.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'toys') diff --git a/toys/posix/ls.c b/toys/posix/ls.c index 3ad28da4..d48fb831 100644 --- a/toys/posix/ls.c +++ b/toys/posix/ls.c @@ -61,7 +61,7 @@ GLOBALS( unsigned screen_width; int nl_title; - char uid_buf[12], gid_buf[12], *escmore; + char *escmore; ) // Callback from crunch_str to represent unprintable chars @@ -121,22 +121,6 @@ static char endtype(struct stat *st) return 0; } -static char *getusername(uid_t uid) -{ - struct passwd *pw = bufgetpwuid(uid); - - sprintf(TT.uid_buf, "%u", (unsigned)uid); - return pw ? pw->pw_name : TT.uid_buf; -} - -static char *getgroupname(gid_t gid) -{ - struct group *gr = bufgetgrgid(gid); - - sprintf(TT.gid_buf, "%u", (unsigned)gid); - return gr ? gr->gr_name : TT.gid_buf; -} - static int numlen(long long ll) { return snprintf(0, 0, "%llu", ll); -- cgit v1.2.3