aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-06-14 00:31:48 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-06-14 00:31:48 +0530
commitb3076e35d60e1b75fc3006efe0e9a32e76c1d9d4 (patch)
tree2e0e8efed162ff51e3e705f581de58b6abf1ddbe
parenta1ec2236d8f48613b28f4bfe82e47d73f9423541 (diff)
downloadnnn-b3076e35d60e1b75fc3006efe0e9a32e76c1d9d4.tar.gz
Refactor key-val pair parsing
-rw-r--r--src/nnn.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 1b3427e..3d07cb1 100644
--- a/src/nnn.c
+++ b/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;
}