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(); xerror();
return FALSE; return FALSE;
} }
if (nextkey - ptr > 1) {
--nextkey;
/* Clear trailing ; or / */
if (*nextkey == ';' || (*nextkey == '/' && *(nextkey - 1) != ':'))
*(*envcpy + (nextkey - ptr)) = '\0';
}
ptr = *envcpy; ptr = *envcpy;
nextkey = ptr; nextkey = ptr;
@ -2935,6 +2943,8 @@ static bool parsekvpair(kv **arr, char **envcpy, const uchar id, ushort *items)
return FALSE; return FALSE;
if (*++ptr == '\0') if (*++ptr == '\0')
return FALSE; return FALSE;
if (*ptr == ';') /* Empty location */
return FALSE;
kvarr[i].val = ptr; kvarr[i].val = ptr;
++i; ++i;
} }
@ -2951,11 +2961,10 @@ static bool parsekvpair(kv **arr, char **envcpy, const uchar id, ushort *items)
++ptr; ++ptr;
} }
if (i < maxitems) { maxitems = i;
if (kvarr[i - 1].val && *kvarr[i - 1].val == '\0') if (kvarr[i - 1].val && *kvarr[i - 1].val == '\0')
return FALSE; return FALSE;
kvarr[i].key = '\0';
}
for (i = 0; i < maxitems && kvarr[i].key; ++i) for (i = 0; i < maxitems && kvarr[i].key; ++i)
if (strlen(kvarr[i].val) >= PATH_MAX) 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; int r = 0;
if (!kvarr)
return NULL;
for (; kvarr[r].key && r < max; ++r) { for (; kvarr[r].key && r < max; ++r) {
if (kvarr[r].key == key) { if (kvarr[r].key == key) {
if (!path) 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, "\nVOLUME: %s of ", coolsize(get_fs_info(path, FREE)));
fprintf(fp, "%s free\n\n", coolsize(get_fs_info(path, CAPACITY))); fprintf(fp, "%s free\n\n", coolsize(get_fs_info(path, CAPACITY)));
if (bookmark[0].val) { if (bookmark) {
fprintf(fp, "BOOKMARKS\n"); fprintf(fp, "BOOKMARKS\n");
printkv(bookmark, fp, maxbm); printkv(bookmark, fp, maxbm);
fprintf(fp, "\n"); fprintf(fp, "\n");
} }
if (plug[0].val) { if (plug) {
fprintf(fp, "PLUGIN KEYS\n"); fprintf(fp, "PLUGIN KEYS\n");
printkv(plug, fp, maxplug); printkv(plug, fp, maxplug);
fprintf(fp, "\n"); fprintf(fp, "\n");