mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Use static vars in frequently used APIs
This commit is contained in:
parent
5ae9993a12
commit
c3545dd82f
15
nnn.c
15
nnn.c
|
@ -450,7 +450,8 @@ static char *
|
||||||
xdirname(const char *path)
|
xdirname(const char *path)
|
||||||
{
|
{
|
||||||
static char *buf = g_buf;
|
static char *buf = g_buf;
|
||||||
static char *last_slash;
|
static char *last_slash, *runp;
|
||||||
|
|
||||||
|
|
||||||
xstrlcpy(buf, path, PATH_MAX);
|
xstrlcpy(buf, path, PATH_MAX);
|
||||||
|
|
||||||
|
@ -459,8 +460,6 @@ xdirname(const char *path)
|
||||||
|
|
||||||
if (last_slash != NULL && last_slash != buf && last_slash[1] == '\0') {
|
if (last_slash != NULL && last_slash != buf && last_slash[1] == '\0') {
|
||||||
/* Determine whether all remaining characters are slashes. */
|
/* Determine whether all remaining characters are slashes. */
|
||||||
char *runp;
|
|
||||||
|
|
||||||
for (runp = last_slash; runp != buf; --runp)
|
for (runp = last_slash; runp != buf; --runp)
|
||||||
if (runp[-1] != '/')
|
if (runp[-1] != '/')
|
||||||
break;
|
break;
|
||||||
|
@ -472,8 +471,6 @@ xdirname(const char *path)
|
||||||
|
|
||||||
if (last_slash != NULL) {
|
if (last_slash != NULL) {
|
||||||
/* Determine whether all remaining characters are slashes. */
|
/* Determine whether all remaining characters are slashes. */
|
||||||
char *runp;
|
|
||||||
|
|
||||||
for (runp = last_slash; runp != buf; --runp)
|
for (runp = last_slash; runp != buf; --runp)
|
||||||
if (runp[-1] != '/')
|
if (runp[-1] != '/')
|
||||||
break;
|
break;
|
||||||
|
@ -609,10 +606,12 @@ spawn(char *file, char *arg1, char *arg2, char *dir, uchar flag)
|
||||||
static char *
|
static char *
|
||||||
xgetenv(char *name, char *fallback)
|
xgetenv(char *name, char *fallback)
|
||||||
{
|
{
|
||||||
|
static char *value;
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return fallback;
|
return fallback;
|
||||||
|
|
||||||
char *value = getenv(name);
|
value = getenv(name);
|
||||||
|
|
||||||
return value && value[0] ? value : fallback;
|
return value && value[0] ? value : fallback;
|
||||||
}
|
}
|
||||||
|
@ -726,8 +725,8 @@ strstrip(char *s)
|
||||||
static char *
|
static char *
|
||||||
getmime(char *file)
|
getmime(char *file)
|
||||||
{
|
{
|
||||||
regex_t regex;
|
static regex_t regex;
|
||||||
uint i;
|
static uint i;
|
||||||
static uint len = LEN(assocs);
|
static uint len = LEN(assocs);
|
||||||
|
|
||||||
for (i = 0; i < len; ++i) {
|
for (i = 0; i < len; ++i) {
|
||||||
|
|
Loading…
Reference in a new issue