tonly show link references at the bottom if there are any, remove #ifdef for it - webdump - [FORK] git://git.codemadness.org/webdump
(HTM) git clone git://git.z3bra.org/webdump.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 044d586ba0ed57e8cba46603e68a6392a22b3511
(DIR) parent 41c9468ad0eecb17decb3417d3cd60d3be70bace
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 8 Dec 2019 15:57:44 +0100
only show link references at the bottom if there are any, remove #ifdef for it
Diffstat:
M webdump.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
---
(DIR) diff --git a/webdump.c b/webdump.c
t@@ -37,8 +37,6 @@ static int showlinkrefs = 0; /* show link references at the bottom */
static int softlinewrap = 0; /* soft line-wrapping */
static int termwidth = 72; /* terminal width */
-#define LINKREFS
-#ifdef LINKREFS
/* linked-list of link references */
struct linkref {
char *type;
t@@ -49,7 +47,6 @@ struct linkref {
static struct linkref *links_head;
static struct linkref *links_cur;
static int linkcount;
-#endif
enum DisplayType {
DisplayUnknown = 0,
t@@ -687,7 +684,6 @@ xmltagstartparsed(XMLParser *p, const char *t, size_t tl, int isshort)
cur = &nodes[curnode];
-#ifdef LINKREFS
/* show links as reference at the bottom */
if (showlinkrefs && src[0]) {
absurl[0] = '\0';
t@@ -717,7 +713,6 @@ xmltagstartparsed(XMLParser *p, const char *t, size_t tl, int isshort)
}
src[0] = '\0';
}
-#endif
#if 0
/* show links inline */
t@@ -805,19 +800,20 @@ xmlattr(XMLParser *p, const char *tag, size_t taglen, const char *name,
strlcpy(src, value, sizeof(src));
}
-#ifdef LINKREFS
void
printlinkrefs(void)
{
size_t i;
+ if (!links_head)
+ return;
+
printf("\n\nLink references:\n");
/* TODO: add title attribute or some basic description? */
for (i = 1, links_cur = links_head; links_cur; links_cur = links_cur->next, i++)
printf("[%zu] - %s (%s)\n", i, links_cur->url, links_cur->type);
}
-#endif
void
usage(void)
t@@ -865,10 +861,8 @@ main(int argc, char **argv)
parser.getnext = getchar;
xml_parse(&parser);
-#ifdef LINKREFS
if (showlinkrefs)
printlinkrefs();
-#endif
if (ncharsline)
putchar('\n');