Unlimited bookmarks, several fixes

This commit is contained in:
Arun Prakash Jana 2020-02-29 09:53:07 +05:30
parent a1e2ef055e
commit 5198c62863
No known key found for this signature in database
GPG key ID: A75979F35C080412

View file

@ -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");