aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-02-29 09:53:07 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-02-29 09:53:49 +0530
commit5198c6286329889cf65fce766675aeeac73eae1a (patch)
treef7e70f63ea404ce38afee86e4da78e0ff7bfb427 /src
parenta1e2ef055eb0853ea5b0189860351b6d40dd118c (diff)
downloadnnn-5198c6286329889cf65fce766675aeeac73eae1a.tar.gz
Unlimited bookmarks, several fixes
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/nnn.c b/src/nnn.c
index ab125fe..4511587 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2925,6 +2925,14 @@ static bool parsekvpair(kv **arr, char **envcpy, const uchar id, ushort *items)
xerror();
return FALSE;
}
+
+ if (nextkey - ptr > 1) {
+ --nextkey;
+ /* Clear trailing ; or / */
+ if (*nextkey == ';' || (*nextkey == '/' && *(nextkey - 1) != ':'))
+ *(*envcpy + (nextkey - ptr)) = '\0';
+ }
+
ptr = *envcpy;
nextkey = ptr;
@@ -2935,6 +2943,8 @@ static bool parsekvpair(kv **arr, char **envcpy, const uchar id, ushort *items)
return FALSE;
if (*++ptr == '\0')
return FALSE;
+ if (*ptr == ';') /* Empty location */
+ return FALSE;
kvarr[i].val = ptr;
++i;
}
@@ -2951,11 +2961,10 @@ static bool parsekvpair(kv **arr, char **envcpy, const uchar id, ushort *items)
++ptr;
}
- if (i < maxitems) {
- if (kvarr[i - 1].val && *kvarr[i - 1].val == '\0')
- return FALSE;
- kvarr[i].key = '\0';
- }
+ maxitems = i;
+
+ if (kvarr[i - 1].val && *kvarr[i - 1].val == '\0')
+ return FALSE;
for (i = 0; i < maxitems && kvarr[i].key; ++i)
if (strlen(kvarr[i].val) >= PATH_MAX)
@@ -2975,6 +2984,9 @@ static char *get_kv_val(kv *kvarr, char *buf, int key, uchar max, bool path)
{
int r = 0;
+ if (!kvarr)
+ return NULL;
+
for (; kvarr[r].key && r < max; ++r) {
if (kvarr[r].key == key) {
if (!path)
@@ -4068,13 +4080,13 @@ static void show_help(const char *path)
fprintf(fp, "\nVOLUME: %s of ", coolsize(get_fs_info(path, FREE)));
fprintf(fp, "%s free\n\n", coolsize(get_fs_info(path, CAPACITY)));
- if (bookmark[0].val) {
+ if (bookmark) {
fprintf(fp, "BOOKMARKS\n");
printkv(bookmark, fp, maxbm);
fprintf(fp, "\n");
}
- if (plug[0].val) {
+ if (plug) {
fprintf(fp, "PLUGIN KEYS\n");
printkv(plug, fp, maxplug);
fprintf(fp, "\n");