rename html_label_t to html_tag_t master
authoryu.dongliang <18588496441@163.com>
Sat, 6 Jun 2026 07:08:34 +0000 (15:08 +0800)
committeryu.dongliang <18588496441@163.com>
Sat, 6 Jun 2026 07:08:34 +0000 (15:08 +0800)
html/abc_css.c
html/abc_html.c
html/abc_html.h

index ba92c419da787056b3e2b8681496781eb898f099..16112df9f4864c6282cfaefceb0bbcb4c1590507 100644 (file)
@@ -1,8 +1,8 @@
 #include"abc_html.h"
 
 #include"abc_html.h"
 
-int            __html_add_attr   (abc_obj_t*  obj,  int    type, abc_str_t* names, size_t n_names, const char* value, int flags);
-html_label_t*  __html_find_label (const char* name, size_t len);
-html_label_t*  __html_find_label2(const int   type);
+int            __html_add_attr(abc_obj_t*  obj,  int    type, abc_str_t* names, size_t n_names, const char* value, int flags);
+html_tag_t*  __html_find_tag  (const char* name, size_t len);
+html_tag_t*  __html_find_tag2 (const int   type);
 
 static int __css_drop_comment(abc_obj_t* style)
 {
 
 static int __css_drop_comment(abc_obj_t* style)
 {
@@ -329,42 +329,42 @@ static int __css_parse_type(css_rule_t* css)
                };
        }
 
                };
        }
 
-       html_label_t*  label;
+       html_tag_t*  tag;
 
        if (id >= 0)
 
        if (id >= 0)
-               label = __html_find_label2(ABC_CSS_ID);
+               tag = __html_find_tag2(ABC_CSS_ID);
 
        else if (class >= 0)
 
        else if (class >= 0)
-               label = __html_find_label2(ABC_CSS_CLASS);
+               tag = __html_find_tag2(ABC_CSS_CLASS);
 
        else if (attr >= 0)
 
        else if (attr >= 0)
-               label = __html_find_label2(ABC_CSS_ATTR);
+               tag = __html_find_tag2(ABC_CSS_ATTR);
 
        else if (pseClass >= 0)
 
        else if (pseClass >= 0)
-               label = __html_find_label2(ABC_CSS_PSE_CLASS);
+               tag = __html_find_tag2(ABC_CSS_PSE_CLASS);
 
        else if (pseElement >= 0)
 
        else if (pseElement >= 0)
-               label = __html_find_label2(ABC_CSS_PSE_ELEMENT);
+               tag = __html_find_tag2(ABC_CSS_PSE_ELEMENT);
 
        else if (combinator >= 0)
 
        else if (combinator >= 0)
-               label = __html_find_label2(ABC_CSS_COMBINATOR);
+               tag = __html_find_tag2(ABC_CSS_COMBINATOR);
        else {
        else {
-               label = __html_find_label(css->text->data, css->text->len);
-               if (!label) {
+               tag = __html_find_tag(css->text->data, css->text->len);
+               if (!tag) {
                        scf_loge("css selector '%s' invalid, file: %s, line: %d\n", css->text->data, css->file->data, css->line);
                        return -EINVAL;
                }
 
                        scf_loge("css selector '%s' invalid, file: %s, line: %d\n", css->text->data, css->file->data, css->line);
                        return -EINVAL;
                }
 
-               scf_logd("css selector '%s', label->name: %s\n", css->text->data, label->names[0].data);
+               scf_logd("css selector '%s', tag->name: %s\n", css->text->data, tag->names[0].data);
 
                scf_string_free(css->text);
                css->text = NULL;
        }
 
 
                scf_string_free(css->text);
                css->text = NULL;
        }
 
-       css->type   = label->type;
-       css->keys   = label->names;
-       css->n_keys = label->n_names;
-       css->flags  = label->flags;
+       css->type   = tag->type;
+       css->keys   = tag->names;
+       css->n_keys = tag->n_names;
+       css->flags  = tag->flags;
 
        if (css->text) {
                if (j < 0)
 
        if (css->text) {
                if (j < 0)
@@ -384,9 +384,9 @@ static int __css_parse_type(css_rule_t* css)
                        case '~':
                                j++;
                        default:
                        case '~':
                                j++;
                        default:
-                               label = __html_find_label(css->text->data + j, k - j);
+                               tag = __html_find_tag(css->text->data + j, k - j);
 
 
-                               css->key_type = label->type;
+                               css->key_type = tag->type;
                                break;
                };
 
                                break;
                };
 
@@ -403,7 +403,7 @@ static int __css_end_obj(int c)
        return 0;
 }
 
        return 0;
 }
 
-static int __css_parse_selectors(abc_obj_t* style, scf_string_t* key, html_label_t* label, scf_list_t* h)
+static int __css_parse_selectors(abc_obj_t* style, scf_string_t* key, html_tag_t* tag, scf_list_t* h)
 {
        int tmp = EOF;
        do {
 {
        int tmp = EOF;
        do {
@@ -418,15 +418,15 @@ static int __css_parse_selectors(abc_obj_t* style, scf_string_t* key, html_label
                        break;
 
                if (key->len > 0) {
                        break;
 
                if (key->len > 0) {
-                       css_rule_t* css = css_rule_alloc(style->file, style->text_line, style->text_pos, label->type);
+                       css_rule_t* css = css_rule_alloc(style->file, style->text_line, style->text_pos, tag->type);
                        if (!css) {
                                scf_string_free(key);
                                return -ENOMEM;
                        }
 
                        if (!css) {
                                scf_string_free(key);
                                return -ENOMEM;
                        }
 
-                       css->flags  = label->flags;
-                       css->keys   = label->names;
-                       css->n_keys = label->n_names;
+                       css->flags  = tag->flags;
+                       css->keys   = tag->names;
+                       css->n_keys = tag->n_names;
                        css->parent = style;
 
                        css->text = key;
                        css->parent = style;
 
                        css->text = key;
@@ -444,7 +444,7 @@ static int __css_parse_selectors(abc_obj_t* style, scf_string_t* key, html_label
 
 static int __css_parse_obj(abc_obj_t* style, abc_char_t* c)
 {
 
 static int __css_parse_obj(abc_obj_t* style, abc_char_t* c)
 {
-       html_label_t*  label;
+       html_tag_t*    tag;
        scf_string_t*  key = scf_string_cstr_len(c->utf8, c->len);
 
        style->text_pos += c->len;
        scf_string_t*  key = scf_string_cstr_len(c->utf8, c->len);
 
        style->text_pos += c->len;
@@ -454,9 +454,9 @@ static int __css_parse_obj(abc_obj_t* style, abc_char_t* c)
        if (!key)
                return -ENOMEM;
 
        if (!key)
                return -ENOMEM;
 
-       label = __html_find_label2(ABC_CSS_COMBINATOR);
-       if (!label) {
-               scf_loge("invalid HTML label '%s' in file: %s, line: %d\n", key->data, style->file->data, style->text_line);
+       tag = __html_find_tag2(ABC_CSS_COMBINATOR);
+       if (!tag) {
+               scf_loge("invalid HTML tag '%s' in file: %s, line: %d\n", key->data, style->file->data, style->text_line);
                scf_string_free(key);
                return -EINVAL;
        }
                scf_string_free(key);
                return -EINVAL;
        }
@@ -468,7 +468,7 @@ static int __css_parse_obj(abc_obj_t* style, abc_char_t* c)
 
        scf_list_init(&h);
 
 
        scf_list_init(&h);
 
-       int ret = __css_parse_selectors(style, key, label, &h);
+       int ret = __css_parse_selectors(style, key, tag, &h);
        if ('{' != ret) {
                ret = -EINVAL;
                goto error;
        if ('{' != ret) {
                ret = -EINVAL;
                goto error;
@@ -483,7 +483,7 @@ static int __css_parse_obj(abc_obj_t* style, abc_char_t* c)
 
                if (!src) {
                        src = css;
 
                if (!src) {
                        src = css;
-                       ret = __css_parse_attr(style, css, label->attrs, label->n_attrs);
+                       ret = __css_parse_attr(style, css, tag->attrs, tag->n_attrs);
                } else
                        ret = abc_css_copy_attrs(css, src);
                if (ret < 0)
                } else
                        ret = abc_css_copy_attrs(css, src);
                if (ret < 0)
@@ -1619,8 +1619,8 @@ int abc_css_use(abc_html_t* html, abc_obj_t* obj)
 
        if (attr && attr->value && attr->value->len > 0)
        {
 
        if (attr && attr->value && attr->value->len > 0)
        {
-               html_label_t*  label = __html_find_label2(obj->type);
-               abc_io_t*      io    = abc_io_array[ABC_PROTO_STR];
+               html_tag_t*  tag = __html_find_tag2(obj->type);
+               abc_io_t*    io  = abc_io_array[ABC_PROTO_STR];
 
                abc_obj_t* css = abc_obj_alloc(obj->file, obj->line, obj->pos, ABC_HTML_STYLE);
                if (!css)
 
                abc_obj_t* css = abc_obj_alloc(obj->file, obj->line, obj->pos, ABC_HTML_STYLE);
                if (!css)
@@ -1642,7 +1642,7 @@ int abc_css_use(abc_html_t* html, abc_obj_t* obj)
                        return ret;
                }
 
                        return ret;
                }
 
-               ret = __css_parse_attr(css, (css_rule_t*)css, label->attrs, label->n_attrs);
+               ret = __css_parse_attr(css, (css_rule_t*)css, tag->attrs, tag->n_attrs);
                io->close(&css->io);
                if (ret < 0 && EOF != ret) {
                        abc_obj_free(css);
                io->close(&css->io);
                if (ret < 0 && EOF != ret) {
                        abc_obj_free(css);
index fbe18328e829e98fb2334eb82eaaf1a4548cf4aa..37946b06805732b417890eabfb33c9456762108d 100644 (file)
@@ -88,7 +88,7 @@ static abc_str_t  content_keys[]       = {ABC_STR("content"),           ABC_STR(
 
 static abc_str_t  http_equiv_keys[]    = {ABC_STR("http-equiv")};
 
 
 static abc_str_t  http_equiv_keys[]    = {ABC_STR("http-equiv")};
 
-// HTML labels
+// HTML tags
 static abc_str_t  html_keys[]   = {ABC_STR("html"),  ABC_STR("网页")};
 static abc_str_t  head_keys[]   = {ABC_STR("head"),  ABC_STR("头部")};
 static abc_str_t  body_keys[]   = {ABC_STR("body"),  ABC_STR("主体")};
 static abc_str_t  html_keys[]   = {ABC_STR("html"),  ABC_STR("网页")};
 static abc_str_t  head_keys[]   = {ABC_STR("head"),  ABC_STR("头部")};
 static abc_str_t  body_keys[]   = {ABC_STR("body"),  ABC_STR("主体")};
@@ -606,7 +606,7 @@ static html_attr_t  script_attrs[] =
        {font_size_keys,  abc_number_of(font_size_keys), "16",       ABC_HTML_ATTR_FONT_SIZE, 0},
 };
 
        {font_size_keys,  abc_number_of(font_size_keys), "16",       ABC_HTML_ATTR_FONT_SIZE, 0},
 };
 
-static html_label_t  html_labels[] =
+static html_tag_t  html_tags[] =
 {
        {html_keys,  abc_number_of(html_keys),     ABC_HTML,          abc_number_of(html_attrs),    html_attrs,    ABC_HTML_FLAG_CLOSE | ABC_HTML_FLAG_SHOW},
        {meta_keys,  abc_number_of(meta_keys),     ABC_HTML_META,     abc_number_of(meta_attrs),    meta_attrs,    ABC_HTML_FLAG_OPEN  | ABC_HTML_FLAG_SHOW},
 {
        {html_keys,  abc_number_of(html_keys),     ABC_HTML,          abc_number_of(html_attrs),    html_attrs,    ABC_HTML_FLAG_CLOSE | ABC_HTML_FLAG_SHOW},
        {meta_keys,  abc_number_of(meta_keys),     ABC_HTML_META,     abc_number_of(meta_attrs),    meta_attrs,    ABC_HTML_FLAG_OPEN  | ABC_HTML_FLAG_SHOW},
@@ -665,37 +665,37 @@ static html_label_t  html_labels[] =
 
 static int __html_parse_obj(abc_html_t* html, abc_char_t* c);
 
 
 static int __html_parse_obj(abc_html_t* html, abc_char_t* c);
 
-html_label_t* __html_find_label(const char* name, size_t len)
+html_tag_t* __html_find_tag(const char* name, size_t len)
 {
 {
-       html_label_t* label;
-       abc_str_t*    s;
+       html_tag_t*  tag;
+       abc_str_t*   s;
        int i;
        int j;
 
        int i;
        int j;
 
-       for (i = 0; i < sizeof(html_labels) / sizeof(html_labels[0]); i++) {
-               label     =       &html_labels[i];
+       for (i  = 0; i < sizeof(html_tags) / sizeof(html_tags[0]); i++) {
+               tag =             &html_tags[i];
 
 
-               for (j = 0; j < label->n_names; j++) {
-                       s  =      &(label->names[j]);
+               for (j = 0; j < tag->n_names; j++) {
+                       s  =      &(tag->names[j]);
 
                        if (len == s->len && !__html_strncmp(s->data, name, len))
 
                        if (len == s->len && !__html_strncmp(s->data, name, len))
-                               return  label;
+                               return  tag;
                }
        }
 
        return NULL;
 }
 
                }
        }
 
        return NULL;
 }
 
-html_label_t* __html_find_label2(const int type)
+html_tag_t* __html_find_tag2(const int type)
 {
 {
-       html_label_t* label;
+       html_tag_t* tag;
        int i;
 
        int i;
 
-       for (i = 0; i < sizeof(html_labels) / sizeof(html_labels[0]); i++) {
-               label     =       &html_labels[i];
+       for (i  = 0; i < sizeof(html_tags) / sizeof(html_tags[0]); i++) {
+               tag =              &html_tags[i];
 
 
-               if (type == label->type)
-                       return  label;
+               if (type == tag->type)
+                       return  tag;
        }
 
        return NULL;
        }
 
        return NULL;
@@ -731,18 +731,18 @@ int __html_add_attr(abc_obj_t* obj, int type, abc_str_t* names, size_t n_names,
 
 static int __html_add_controls(abc_obj_t* obj)
 {
 
 static int __html_add_controls(abc_obj_t* obj)
 {
-       html_label_t* label;
-       abc_obj_t*    play;
-       abc_obj_t*    progress;
+       html_tag_t*  tag;
+       abc_obj_t*   play;
+       abc_obj_t*   progress;
 
        play = abc_obj_alloc(obj->file, obj->line, obj->pos, ABC_HTML_PLAY);
        if (!play)
                return -ENOMEM;
 
 
        play = abc_obj_alloc(obj->file, obj->line, obj->pos, ABC_HTML_PLAY);
        if (!play)
                return -ENOMEM;
 
-       label        = __html_find_label2(ABC_HTML_PLAY);
-       play->flags  = label->flags;
-       play->keys   = label->names;
-       play->n_keys = label->n_names;
+       tag          = __html_find_tag2(ABC_HTML_PLAY);
+       play->flags  = tag->flags;
+       play->keys   = tag->names;
+       play->n_keys = tag->n_names;
        play->parent = obj;
 
        progress = abc_obj_alloc(obj->file, obj->line, obj->pos, ABC_HTML_PROGRESS);
        play->parent = obj;
 
        progress = abc_obj_alloc(obj->file, obj->line, obj->pos, ABC_HTML_PROGRESS);
@@ -751,10 +751,10 @@ static int __html_add_controls(abc_obj_t* obj)
                return -ENOMEM;
        }
 
                return -ENOMEM;
        }
 
-       label            = __html_find_label2(ABC_HTML_PROGRESS);
-       progress->flags  = label->flags;
-       progress->keys   = label->names;
-       progress->n_keys = label->n_names;
+       tag              = __html_find_tag2(ABC_HTML_PROGRESS);
+       progress->flags  = tag->flags;
+       progress->keys   = tag->names;
+       progress->n_keys = tag->n_names;
        progress->parent = obj;
 
        scf_list_add_tail(&obj->childs, &play->list);
        progress->parent = obj;
 
        scf_list_add_tail(&obj->childs, &play->list);
@@ -998,7 +998,7 @@ static int __html_parse_end(abc_html_t* html, abc_obj_t* obj)
                }
        }
 
                }
        }
 
-       scf_loge("end label '%s' file: %s, line: %d, NOT for label '%s' line: %d\n",
+       scf_loge("end tag '%s' file: %s, line: %d, NOT for tag '%s' line: %d\n",
                        end->data, html->file->data, html->n_lines, obj->keys[0].data, obj->line);
 
        scf_string_free(end);
                        end->data, html->file->data, html->n_lines, obj->keys[0].data, obj->line);
 
        scf_string_free(end);
@@ -1007,7 +1007,7 @@ static int __html_parse_end(abc_html_t* html, abc_obj_t* obj)
 
 static int __html_parse_text(abc_html_t* html, abc_obj_t* obj)
 {
 
 static int __html_parse_text(abc_html_t* html, abc_obj_t* obj)
 {
-       if (ABC_HTML_FLAG_OPEN == (obj->flags & 0x1)) // single labels
+       if (ABC_HTML_FLAG_OPEN == (obj->flags & 0x1)) // single tags
                return 0;
 
        scf_string_t* text = scf_string_alloc();
                return 0;
 
        scf_string_t* text = scf_string_alloc();
@@ -1445,7 +1445,7 @@ static int __html_run_js(abc_html_t* html, abc_obj_t* obj)
 
 static int __html_parse_obj(abc_html_t* html, abc_char_t* c)
 {
 
 static int __html_parse_obj(abc_html_t* html, abc_char_t* c)
 {
-       html_label_t*  label;
+       html_tag_t*    tag;
        abc_obj_t*     obj;
        abc_attr_t*    type;
        scf_string_t*  key = scf_string_cstr_len(c->utf8, c->len);
        abc_obj_t*     obj;
        abc_attr_t*    type;
        scf_string_t*  key = scf_string_cstr_len(c->utf8, c->len);
@@ -1486,9 +1486,9 @@ static int __html_parse_obj(abc_html_t* html, abc_char_t* c)
        free(c);
        c = NULL;
 
        free(c);
        c = NULL;
 
-       label = __html_find_label(key->data, key->len);
-       if (!label) {
-               scf_loge("invalid HTML label '%s' in file: %s, line: %d\n",
+       tag = __html_find_tag(key->data, key->len);
+       if (!tag) {
+               scf_loge("invalid HTML tag '%s' in file: %s, line: %d\n",
                                key->data, html->file->data, html->n_lines);
                scf_string_free(key);
                return -1;
                                key->data, html->file->data, html->n_lines);
                scf_string_free(key);
                return -1;
@@ -1497,17 +1497,16 @@ static int __html_parse_obj(abc_html_t* html, abc_char_t* c)
        scf_string_free(key);
        key = NULL;
 
        scf_string_free(key);
        key = NULL;
 
-       obj = abc_obj_alloc(html->file, html->n_lines, html->pos, label->type);
+       obj = abc_obj_alloc(html->file, html->n_lines, html->pos, tag->type);
        if (!obj)
                return -ENOMEM;
 
        if (!obj)
                return -ENOMEM;
 
-       obj->flags  = label->flags;
-       obj->keys   = label->names;
-       obj->n_keys = label->n_names;
-
+       obj->flags  = tag->flags;
+       obj->keys   = tag->names;
+       obj->n_keys = tag->n_names;
        obj->parent = html->current;
 
        obj->parent = html->current;
 
-       int ret = __html_load_attrs(obj, label->attrs, label->n_attrs);
+       int ret = __html_load_attrs(obj, tag->attrs, tag->n_attrs);
        if (ret < 0) {
                abc_obj_free(obj);
                return ret;
        if (ret < 0) {
                abc_obj_free(obj);
                return ret;
@@ -1515,7 +1514,7 @@ static int __html_parse_obj(abc_html_t* html, abc_char_t* c)
 
        switch (tmp) {
                case ' ':
 
        switch (tmp) {
                case ' ':
-                       ret = __html_parse_attr(html, obj, label->attrs, label->n_attrs);
+                       ret = __html_parse_attr(html, obj, tag->attrs, tag->n_attrs);
                        if (ret < 0) {
                                abc_obj_free(obj);
                                return ret;
                        if (ret < 0) {
                                abc_obj_free(obj);
                                return ret;
@@ -1554,7 +1553,7 @@ static int __html_parse_obj(abc_html_t* html, abc_char_t* c)
                c = NULL;
 
                if ('>' != tmp) {
                c = NULL;
 
                if ('>' != tmp) {
-                       scf_loge("HTML label '%s' (%d) not closed, in file: %s, line: %d\n",
+                       scf_loge("HTML tag '%s' (%d) not closed, in file: %s, line: %d\n",
                                        obj->keys[0].data, tmp, html->file->data, html->n_lines);
                        return -1;
                }
                                        obj->keys[0].data, tmp, html->file->data, html->n_lines);
                        return -1;
                }
index 4b7baaceb2a90bd05bda632a8d0575a39f755b9f..ff5a67540e52e1e5984f9018fd83bbbfe3f1213e 100644 (file)
@@ -26,7 +26,7 @@ typedef struct {
        html_attr_t*  attrs;
 
        uint32_t      flags;
        html_attr_t*  attrs;
 
        uint32_t      flags;
-} html_label_t;
+} html_tag_t;
 
 #define abc_number_of(__array)  (sizeof(__array) / sizeof(__array[0]))
 
 
 #define abc_number_of(__array)  (sizeof(__array) / sizeof(__array[0]))