trename count to nchildren, some cleanups - 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 fc07cb6c73b027722f67b491899d9fc7f5fff505
 (DIR) parent b86543ca5fdf0639730cfe957866904abbf398f1
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Wed, 20 Nov 2019 18:29:34 +0100
       
       rename count to nchildren, some cleanups
       
       Diffstat:
         M webdump.c                           |      19 ++++++-------------
       
       1 file changed, 6 insertions(+), 13 deletions(-)
       ---
 (DIR) diff --git a/webdump.c b/webdump.c
       t@@ -63,18 +63,16 @@ enum DisplayType {
        
        struct tag {
                char *name;
       -        enum DisplayType displaytype; // TODO: use struct tag reference
       -        enum DisplayType parenttype;
       +        enum DisplayType displaytype;
       +        enum DisplayType parenttype; /* display type belonging to element */
        };
        
        struct node {
                char tagname[256];
                struct tag tag;
       -        size_t count; // TODO: rename: childnodes or w/e
       +        size_t nchildren; /* Child nodes for it's type */
        };
        
       -typedef struct node Node; // TODO: remove
       -
        /* String data / memory pool */
        typedef struct string {
                char   *data;   /* data */
       t@@ -533,7 +531,6 @@ xmldataentity(XMLParser *p, const char *data, size_t datalen)
        
                /* &nbsp; &copy;, copy table from Links (check license) */
                /* rsquo, hellip, ndash, lsquo */
       -        /* TODO: add to tscrape too */
                /* TODO: support some more HTML entities */
        
                n = 0;
       t@@ -573,12 +570,8 @@ xmltagstart(XMLParser *x, const char *t, size_t tl)
                /* set display type */
                for (i = 0; i < sizeof(tags) / sizeof(*tags); i++) {
                        if (!strcasecmp(tags[i].name, t)) {
       -                        cur->count = 0;
       +                        cur->nchildren = 0;
                                memcpy(&(cur->tag), &tags[i], sizeof(tags[i]));
       -
       -//                        cur->displaytype = tags[i].displaytype;
       -//                        printf("DEBUG: match on tag: %s == %s, displaytype: %d\n",
       -//                               tags[i].tag, t, cur->tag.displaytype);
                                break;
                        }
                }
       t@@ -693,7 +686,7 @@ xmltagstartparsed(XMLParser *p, const char *t, size_t tl, int isshort)
        
                /* find first parent node of type and increase child node count */
                if (cur->tag.parenttype && (parent = findparentoftype(curnode)))
       -                parent->count++;
       +                parent->nchildren++;
        
                if (cur->tag.displaytype & DisplayBlock) {
                        newline();
       t@@ -716,7 +709,7 @@ xmltagstartparsed(XMLParser *p, const char *t, size_t tl, int isshort)
                        /* find first parent node and ordered numbers or unordered */
                        if (parent) {
                                if (parent->tag.displaytype & DisplayListOrdered)
       -                                printf("%zu. ", parent->count);
       +                                printf("%zu. ", parent->nchildren);
                                else
                                        fputs("* ", stdout);
                        }