mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Refactor key-val pair parsing
This commit is contained in:
parent
a1ec2236d8
commit
b3076e35d6
11
src/nnn.c
11
src/nnn.c
|
@ -3010,7 +3010,7 @@ static int xlink(char *prefix, char *path, char *curfname, char *buf, int *prese
|
|||
|
||||
static bool parsekvpair(kv **arr, char **envcpy, const uchar id, uchar *items)
|
||||
{
|
||||
bool next = TRUE;
|
||||
bool new = TRUE;
|
||||
const uchar INCR = 8;
|
||||
uint i = 0;
|
||||
kv *kvarr = NULL;
|
||||
|
@ -3028,7 +3028,7 @@ static bool parsekvpair(kv **arr, char **envcpy, const uchar id, uchar *items)
|
|||
ptr = *envcpy;
|
||||
|
||||
while (*ptr && i < 100) {
|
||||
if (next) {
|
||||
if (new) {
|
||||
if (!(i & (INCR - 1))) {
|
||||
kvarr = xrealloc(kvarr, sizeof(kv) * (i + INCR));
|
||||
*arr = kvarr;
|
||||
|
@ -3043,13 +3043,14 @@ static bool parsekvpair(kv **arr, char **envcpy, const uchar id, uchar *items)
|
|||
return FALSE;
|
||||
kvarr[i].off = ptr - *envcpy;
|
||||
++i;
|
||||
|
||||
new = FALSE;
|
||||
}
|
||||
|
||||
if (*ptr == ';') {
|
||||
*ptr = '\0';
|
||||
next = TRUE;
|
||||
} else if (next)
|
||||
next = FALSE;
|
||||
new = TRUE;
|
||||
}
|
||||
|
||||
++ptr;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue