瀏覽代碼

Code refactor

master
Arun Prakash Jana 6 年之前
父節點
當前提交
c8e54ce4e2
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: A75979F35C080412
共有 2 個文件被更改,包括 12 次插入18 次删除
  1. +1
    -1
      Makefile
  2. +11
    -17
      src/nnn.c

+ 1
- 1
Makefile 查看文件

@@ -18,7 +18,7 @@ else
LDLIBS_CURSES ?= -lncurses LDLIBS_CURSES ?= -lncurses
endif endif


CFLAGS += -Wall -Wextra -Wno-unused-parameter CFLAGS += -Wall -Wextra -Wno-unused-parameter -Wno-format-truncation
CFLAGS += $(CFLAGS_OPTIMIZATION) CFLAGS += $(CFLAGS_OPTIMIZATION)
CFLAGS += $(CFLAGS_CURSES) CFLAGS += $(CFLAGS_CURSES)




+ 11
- 17
src/nnn.c 查看文件

@@ -2017,8 +2017,8 @@ static char *coolsize(off_t size)
{ {
static const char * const U = "BKMGTPEZY"; static const char * const U = "BKMGTPEZY";
static char size_buf[12]; /* Buffer to hold human readable size */ static char size_buf[12]; /* Buffer to hold human readable size */
static off_t rem; off_t rem;
static int i; int i;


rem = i = 0; rem = i = 0;


@@ -2065,19 +2065,21 @@ static char *coolsize(off_t size)
} }


if (i > 0 && i < 6) 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 else
snprintf(size_buf, 12, "%lu%c", (ulong)size, U[i]); snprintf(size_buf, 12, "%lu%c", size, U[i]);


return size_buf; 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[0] = ind[1] = '\0';
ind[1] = '\0';


switch (mode & S_IFMT) { switch (mode & S_IFMT) {
case S_IFREG: case S_IFREG:
@@ -2104,18 +2106,10 @@ static char *get_file_sym(mode_t mode)
break; 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 */ /* Directories are always shown on top */
resetdircolor(ent->flags); 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) static void printent_long(const struct entry *ent, int sel, uint namecols)


||||||
x
 
000:0
Loading…
取消
儲存