struct vector {
int want_href;
char *name;
+ int literal; /* should the name be formatted in fixed-pitch? */
unsigned long index;
unsigned long long sizes[MAXCOLOUR+1];
};
}
static struct vector *make_vector(struct html *ctx, char *path,
- int want_href, char *name)
+ int want_href, char *name, int literal)
{
unsigned long xi1, xi2;
struct vector *vec = snew(struct vector);
vec->want_href = want_href;
vec->name = name ? dupstr(name) : NULL;
+ vec->literal = literal;
get_indices(ctx->t, path, &xi1, &xi2);
htprintf(ctx, "<a href=\"%s\">", ctx->href);
doing_href = 1;
}
+ if (vec->literal)
+ htprintf(ctx, "<code>");
htescape(ctx, vec->name, strlen(vec->name), 1);
+ if (vec->literal)
+ htprintf(ctx, "</code>");
if (doing_href)
htprintf(ctx, "</a>");
}
htprintf(ctx, "</td>\n</tr>\n");
}
+int strcmptrailingpathsep(const char *a, const char *b)
+{
+ while (*a == *b && *a)
+ a++, b++;
+
+ if ((*a == pathsep && !a[1] && !*b) ||
+ (*b == pathsep && !b[1] && !*a))
+ return 0;
+
+ return (int)(unsigned char)*a - (int)(unsigned char)*b;
+}
+
char *html_query(const void *t, unsigned long index,
const struct html_config *cfg)
{
*zp = '\0';
index2 = trie_before(t, path);
trie_getpath(t, index2, path2);
- if (!strcmp(path, path2) && cfg->format) {
+ if (!strcmptrailingpathsep(path, path2) && cfg->format) {
snprintf(href, hreflen, cfg->format, index2);
if (!*href) /* special case that we understand */
strcpy(href, "./");
vecsize = 64;
vecs = snewn(vecsize, struct vector *);
nvecs = 1;
- vecs[0] = make_vector(ctx, path, 0, NULL);
+ vecs[0] = make_vector(ctx, path, 0, NULL, 0);
print_heading(ctx, "Overall");
write_report_line(ctx, vecs[0]);
vecs = sresize(vecs, vecsize, struct vector *);
}
assert(strlen(path2) > pathlen);
- vecs[nvecs] = make_vector(ctx, path2, 1, path2 + subdirpos);
+ vecs[nvecs] = make_vector(ctx, path2, 1, path2 + subdirpos, 1);
for (i = 0; i <= MAXCOLOUR; i++)
vecs[0]->sizes[i] -= vecs[nvecs]->sizes[i];
nvecs++;