mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
Compact switch cases
This commit is contained in:
parent
98308b8444
commit
ed55fbd9d5
55
src/nnn.c
55
src/nnn.c
|
@ -3601,19 +3601,13 @@ static void print_time(const time_t *timep)
|
||||||
static char get_detail_ind(const struct entry *ent)
|
static char get_detail_ind(const struct entry *ent)
|
||||||
{
|
{
|
||||||
switch (ent->mode & S_IFMT) {
|
switch (ent->mode & S_IFMT) {
|
||||||
case S_IFDIR:
|
case S_IFDIR: // fallthrough
|
||||||
case S_IFREG:
|
case S_IFREG: return ' ';
|
||||||
return ' ';
|
case S_IFLNK: return '@';
|
||||||
case S_IFLNK:
|
case S_IFSOCK: return '=';
|
||||||
return '@';
|
case S_IFIFO: return '|';
|
||||||
case S_IFSOCK:
|
case S_IFBLK: return 'b';
|
||||||
return '=';
|
case S_IFCHR: return 'c';
|
||||||
case S_IFIFO:
|
|
||||||
return '|';
|
|
||||||
case S_IFBLK:
|
|
||||||
return 'b';
|
|
||||||
case S_IFCHR:
|
|
||||||
return 'c';
|
|
||||||
}
|
}
|
||||||
return '?';
|
return '?';
|
||||||
}
|
}
|
||||||
|
@ -3621,19 +3615,13 @@ static char get_detail_ind(const struct entry *ent)
|
||||||
static char get_name_ind(const struct entry *ent)
|
static char get_name_ind(const struct entry *ent)
|
||||||
{
|
{
|
||||||
switch (ent->mode & S_IFMT) {
|
switch (ent->mode & S_IFMT) {
|
||||||
case S_IFREG:
|
case S_IFREG: return (ent->mode & 0100) ? '*' : '\0';
|
||||||
return (ent->mode & 0100) ? '*' : '\0';
|
case S_IFDIR: return '/';
|
||||||
case S_IFDIR:
|
case S_IFLNK: return (ent->flags & DIR_OR_LINK_TO_DIR) ? '/' : '@';
|
||||||
return '/';
|
case S_IFSOCK: return '=';
|
||||||
case S_IFLNK:
|
case S_IFIFO: return '|';
|
||||||
return (ent->flags & DIR_OR_LINK_TO_DIR) ? '/' : '@';
|
case S_IFBLK: // fallthrough
|
||||||
case S_IFSOCK:
|
case S_IFCHR: return '\0';
|
||||||
return '=';
|
|
||||||
case S_IFIFO:
|
|
||||||
return '|';
|
|
||||||
case S_IFBLK:
|
|
||||||
case S_IFCHR:
|
|
||||||
return '\0';
|
|
||||||
}
|
}
|
||||||
return '?';
|
return '?';
|
||||||
}
|
}
|
||||||
|
@ -3653,16 +3641,11 @@ static uchar_t get_color_pair(const struct entry *ent, bool detailed)
|
||||||
if (!g_state.oldcolor || detailed)
|
if (!g_state.oldcolor || detailed)
|
||||||
return (ent->flags & SYM_ORPHAN) ? C_ORP : C_LNK;
|
return (ent->flags & SYM_ORPHAN) ? C_ORP : C_LNK;
|
||||||
return 0;
|
return 0;
|
||||||
case S_IFDIR:
|
case S_IFDIR: return (!g_state.oldcolor && g_state.dirctx) ? cfg.curctx + 1 : C_DIR;
|
||||||
return (!g_state.oldcolor && g_state.dirctx) ? cfg.curctx + 1 : C_DIR;
|
case S_IFSOCK: return C_SOC;
|
||||||
case S_IFSOCK:
|
case S_IFIFO: return C_PIP;
|
||||||
return C_SOC;
|
case S_IFBLK: return C_BLK;
|
||||||
case S_IFIFO:
|
case S_IFCHR: return C_CHR;
|
||||||
return C_PIP;
|
|
||||||
case S_IFBLK:
|
|
||||||
return C_BLK;
|
|
||||||
case S_IFCHR:
|
|
||||||
return C_CHR;
|
|
||||||
}
|
}
|
||||||
return C_UND;
|
return C_UND;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue