[wiki] [sites] build-page: fix highlight of menus starting with the same name || Hiltjo Posthuma
commit daafc6fcb9669cf44f875b3d0ff6602f579cb4c8
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun Nov 17 18:42:16 2019 +0100
build-page: fix highlight of menus starting with the same name
check for / or end of string (NUL byte).
This happened on the menu for st for the patches: alpha and
alphafocushighlight.
diff --git a/build-page.c b/build-page.c
index f945fcb5..1e882d71 100644
--- a/build-page.c
+++ b/build-page.c
_AT_@ -214,7 +214,7 @@ menu_panel(char *domain, char *page, char *this, int depth)
char newdir[PATH_MAX];
char *d_list[DIR_MAX], *d;
size_t d_len, l;
- int i;
+ int i, highlight;
if ((dp = opendir(this ? this : ".")) == NULL)
die_perror("opendir: %s", this ? this : ".");
_AT_@ -235,10 +235,13 @@ menu_panel(char *domain, char *page, char *this, int depth)
if (!stat_isdir(newdir))
continue;
+ highlight = page && !strncmp(newdir, page, strlen(newdir)) &&
+ strchr("/", page[strlen(newdir)]); /* / or NUL */
+
for (i = 0; i < depth + 1; ++i)
putchar(' ');
fputs("<li>", stdout);
- if (page && !strncmp(newdir, page, strlen(newdir))) {
+ if (highlight) {
printf("<a href=\"//%s/%s/\"><b>", domain, newdir);
print_name(d);
fputs("/</b></a>", stdout);
_AT_@ -248,7 +251,7 @@ menu_panel(char *domain, char *page, char *this, int depth)
fputs("/</a>", stdout);
}
- if (page && !strncmp(newdir, page, strlen(newdir))) {
+ if (highlight) {
putchar('
');
for (i = 0; i < depth + 2; ++i)
putchar(' ');
Received on Sun Nov 17 2019 - 18:43:08 CET
This archive was generated by hypermail 2.3.0
: Sun Nov 17 2019 - 18:48:32 CET