From 0089cdbb132d9486413c0c1a5fa2fba7571e8dae Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 15 Nov 2008 09:04:21 +0000 Subject: [PATCH] Handle another fiddly special case in HTML back-link generation. This enables agedu -w to deal sensibly with scans generated on Windows and starting in a drive's root directory such as "c:\". git-svn-id: svn://svn.tartarus.org/sgt/agedu@8297 cda61777-01e9-0310-a592-d414129be87e --- html.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/html.c b/html.c index 5ca85e0..d6d6ad1 100644 --- a/html.c +++ b/html.c @@ -367,6 +367,18 @@ static void write_report_line(struct html *ctx, struct vector *vec) htprintf(ctx, "\n\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) { @@ -442,7 +454,7 @@ char *html_query(const void *t, unsigned long index, *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, "./"); -- 2.11.0