aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-05-09 07:34:10 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-05-22 08:44:19 +0530
commitc8e54ce4e24036f35d81b475033cf24c1838f317 (patch)
treeb6d4d8bdf854e6cf66e2a6800b39bd8d67835270
parent30aaa12e6fe535518e1d0b71e5fc8b6bc66bf3b4 (diff)
downloadnnn-c8e54ce4e24036f35d81b475033cf24c1838f317.tar.gz
Code refactor
-rw-r--r--Makefile2
-rw-r--r--src/nnn.c28
2 files changed, 12 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 7dcf5eb..8750af0 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ else
LDLIBS_CURSES ?= -lncurses
endif
-CFLAGS += -Wall -Wextra -Wno-unused-parameter
+CFLAGS += -Wall -Wextra -Wno-unused-parameter -Wno-format-truncation
CFLAGS += $(CFLAGS_OPTIMIZATION)
CFLAGS += $(CFLAGS_CURSES)
diff --git a/src/nnn.c b/src/nnn.c
index 70fe67c..4615db5 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2017,8 +2017,8 @@ static char *coolsize(off_t size)
{
static const char * const U = "BKMGTPEZY";
static char size_buf[12]; /* Buffer to hold human readable size */
- static off_t rem;
- static int i;
+ off_t rem;
+ int i;
rem = i = 0;
@@ -2065,19 +2065,21 @@ static char *coolsize(off_t size)
}
if (i > 0 && i < 6)
- snprintf(size_buf, 12, "%lu.%0*lu%c", (ulong)size, i, (ulong)rem, U[i]);
+ snprintf(size_buf, 12, "%lu.%0*lu%c", size, i, rem, U[i]);
else
- snprintf(size_buf, 12, "%lu%c", (ulong)size, U[i]);
+ snprintf(size_buf, 12, "%lu%c", size, U[i]);
return size_buf;
}
-static char *get_file_sym(mode_t mode)
+static void printent(const struct entry *ent, int sel, uint namecols)
{
- static char ind[2];
+ const char *pname = unescape(ent->name, namecols);
+ const char cp = (ent->flags & FILE_COPIED) ? '+' : ' ';
+ char ind[2];
+ mode_t mode = ent->mode;
- ind[0] = '\0';
- ind[1] = '\0';
+ ind[0] = ind[1] = '\0';
switch (mode & S_IFMT) {
case S_IFREG:
@@ -2104,18 +2106,10 @@ static char *get_file_sym(mode_t mode)
break;
}
- return ind;
-}
-
-static void printent(const struct entry *ent, int sel, uint namecols)
-{
- const char *pname = unescape(ent->name, namecols);
- const char cp = (ent->flags & FILE_COPIED) ? '+' : ' ';
-
/* Directories are always shown on top */
resetdircolor(ent->flags);
- printw("%s%c%s%s\n", CURSYM(sel), cp, pname, get_file_sym(ent->mode));
+ printw("%s%c%s%s\n", CURSYM(sel), cp, pname, ind);
}
static void printent_long(const struct entry *ent, int sel, uint namecols)