aboutsummaryrefslogtreecommitdiffstats
path: root/src/nnn.c
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-01-18 14:58:27 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-01-18 14:58:48 +0530
commitafb7efc860a50d683c8c3df36126b664caff9300 (patch)
tree0f5ed55e9846321403cadb939b1e2ecb20a5fb02 /src/nnn.c
parent1dd691d20b53530ab87403686431add2807fd942 (diff)
downloadnnn-afb7efc860a50d683c8c3df36126b664caff9300.tar.gz
Merge functions
Diffstat (limited to 'src/nnn.c')
-rw-r--r--src/nnn.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/nnn.c b/src/nnn.c
index d769e3a..adbf942 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2783,47 +2783,39 @@ static char *coolsize(off_t size)
return size_buf;
}
-static char get_fileind(mode_t mode)
+/* Convert a mode field into "ls -l" type perms field. */
+static char *get_lsperms(mode_t mode)
{
- char c = '\0';
+ static const char * const rwx[] = {"---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"};
+ static char bits[11] = {'\0'};
switch (mode & S_IFMT) {
case S_IFREG:
- c = '-';
+ bits[0] = '-';
break;
case S_IFDIR:
- c = 'd';
+ bits[0] = 'd';
break;
case S_IFLNK:
- c = 'l';
+ bits[0] = 'l';
break;
case S_IFSOCK:
- c = 's';
+ bits[0] = 's';
break;
case S_IFIFO:
- c = 'p';
+ bits[0] = 'p';
break;
case S_IFBLK:
- c = 'b';
+ bits[0] = 'b';
break;
case S_IFCHR:
- c = 'c';
+ bits[0] = 'c';
break;
default:
- c = '?';
+ bits[0] = '?';
break;
}
- return c;
-}
-
-/* Convert a mode field into "ls -l" type perms field. */
-static char *get_lsperms(mode_t mode)
-{
- static const char * const rwx[] = {"---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"};
- static char bits[11] = {'\0'};
-
- bits[0] = get_fileind(mode);
xstrlcpy(&bits[1], rwx[(mode >> 6) & 7], 4);
xstrlcpy(&bits[4], rwx[(mode >> 3) & 7], 4);
xstrlcpy(&bits[7], rwx[(mode & 7)], 4);