mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Use static vars
This commit is contained in:
parent
b123985437
commit
a569d383bc
55
nnn.c
55
nnn.c
|
@ -121,6 +121,9 @@ static int idle;
|
||||||
static char *opener;
|
static char *opener;
|
||||||
static char *fallback_opener;
|
static char *fallback_opener;
|
||||||
static char *copier;
|
static char *copier;
|
||||||
|
static off_t blk_size;
|
||||||
|
static size_t fs_free;
|
||||||
|
static const double div_2_pow_10 = 1.0 / 1024.0;
|
||||||
static const char* size_units[] = {"B", "K", "M", "G", "T", "P", "E", "Z", "Y"};
|
static const char* size_units[] = {"B", "K", "M", "G", "T", "P", "E", "Z", "Y"};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -313,13 +316,6 @@ xgetenv(char *name, char *fallback)
|
||||||
return value && value[0] ? value : fallback;
|
return value && value[0] ? value : fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xisdigit(const char c) {
|
|
||||||
if (c >= '0' && c <= '9') \
|
|
||||||
return 1; \
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We assume none of the strings are NULL.
|
* We assume none of the strings are NULL.
|
||||||
*
|
*
|
||||||
|
@ -552,7 +548,7 @@ readln(void)
|
||||||
static int
|
static int
|
||||||
canopendir(char *path)
|
canopendir(char *path)
|
||||||
{
|
{
|
||||||
DIR *dirp;
|
static DIR *dirp;
|
||||||
|
|
||||||
dirp = opendir(path);
|
dirp = opendir(path);
|
||||||
if (dirp == NULL)
|
if (dirp == NULL)
|
||||||
|
@ -598,15 +594,18 @@ printent(struct entry *ent, int active)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void (*printptr)(struct entry *ent, int active) = &printent;
|
static void (*printptr)(struct entry *ent, int active) = &printent;
|
||||||
static const double div_2_pow_10 = 1.0 / 1024.0;
|
|
||||||
|
|
||||||
static char*
|
static char*
|
||||||
coolsize(off_t size)
|
coolsize(off_t size)
|
||||||
{
|
{
|
||||||
static char size_buf[12]; /* Buffer to hold human readable size */
|
static char size_buf[12]; /* Buffer to hold human readable size */
|
||||||
int i = 0;
|
static int i;
|
||||||
off_t fsize = size, tmp;
|
static off_t fsize, tmp;
|
||||||
long double rem = 0;
|
static long double rem;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
fsize = size;
|
||||||
|
rem = 0;
|
||||||
|
|
||||||
while (fsize > 1024) {
|
while (fsize > 1024) {
|
||||||
tmp = fsize;
|
tmp = fsize;
|
||||||
|
@ -688,7 +687,7 @@ printent_long(struct entry *ent, int active)
|
||||||
static char
|
static char
|
||||||
get_fileind(mode_t mode, char *desc)
|
get_fileind(mode_t mode, char *desc)
|
||||||
{
|
{
|
||||||
char c;
|
static char c;
|
||||||
|
|
||||||
if (S_ISREG(mode)) {
|
if (S_ISREG(mode)) {
|
||||||
c = '-';
|
c = '-';
|
||||||
|
@ -759,7 +758,7 @@ get_lsperms(mode_t mode, char *desc)
|
||||||
return(bits);
|
return(bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
get_output(char *buf, size_t bytes)
|
get_output(char *buf, size_t bytes)
|
||||||
{
|
{
|
||||||
char *ret;
|
char *ret;
|
||||||
|
@ -776,7 +775,7 @@ get_output(char *buf, size_t bytes)
|
||||||
/*
|
/*
|
||||||
* Follows the stat(1) output closely
|
* Follows the stat(1) output closely
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
show_stats(char* fpath, char* fname, struct stat *sb)
|
show_stats(char* fpath, char* fname, struct stat *sb)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX + 48];
|
char buf[PATH_MAX + 48];
|
||||||
|
@ -885,7 +884,7 @@ show_stats(char* fpath, char* fname, struct stat *sb)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
show_help(void)
|
show_help(void)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
@ -929,9 +928,6 @@ show_help(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t blk_size;
|
|
||||||
size_t fs_free = 0;
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sum_sizes(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
|
sum_sizes(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
|
||||||
{
|
{
|
||||||
|
@ -954,11 +950,12 @@ dentfill(char *path, struct entry **dents,
|
||||||
int (*filter)(regex_t *, char *), regex_t *re)
|
int (*filter)(regex_t *, char *), regex_t *re)
|
||||||
{
|
{
|
||||||
static char newpath[PATH_MAX];
|
static char newpath[PATH_MAX];
|
||||||
DIR *dirp;
|
static DIR *dirp;
|
||||||
struct dirent *dp;
|
static struct dirent *dp;
|
||||||
struct stat sb;
|
static struct stat sb;
|
||||||
struct statvfs svb;
|
static struct statvfs svb;
|
||||||
int r, n = 0;
|
static int r, n;
|
||||||
|
r = n = 0;
|
||||||
|
|
||||||
dirp = opendir(path);
|
dirp = opendir(path);
|
||||||
if (dirp == NULL)
|
if (dirp == NULL)
|
||||||
|
@ -1023,8 +1020,10 @@ dentfind(struct entry *dents, int n, char *path)
|
||||||
if (!path)
|
if (!path)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int i;
|
static int i;
|
||||||
char *p = xmemrchr(path, '/', strlen(path));
|
static char *p;
|
||||||
|
|
||||||
|
p = xmemrchr(path, '/', strlen(path));
|
||||||
if (!p)
|
if (!p)
|
||||||
p = path;
|
p = path;
|
||||||
else
|
else
|
||||||
|
@ -1044,8 +1043,8 @@ dentfind(struct entry *dents, int n, char *path)
|
||||||
static int
|
static int
|
||||||
populate(char *path, char *oldpath, char *fltr)
|
populate(char *path, char *oldpath, char *fltr)
|
||||||
{
|
{
|
||||||
regex_t re;
|
static regex_t re;
|
||||||
int r;
|
static int r;
|
||||||
|
|
||||||
/* Can fail when permissions change while browsing */
|
/* Can fail when permissions change while browsing */
|
||||||
if (canopendir(path) == 0)
|
if (canopendir(path) == 0)
|
||||||
|
|
Loading…
Reference in a new issue