• Patch: Elm ME+ 2.5 PLalpha62 -> Elm ME+ 2.5 PLalpha63 [6/7] (3/5)

    From Kari Hurtta@21:1/5 to All on Wed Jan 3 13:53:20 2024
    [continued from previous message]

    + struct tagfilter_tags text_html_noscript_head = {
    + TAGFILTER_TAGS_magic,
    +
    + "text/html content of <noscript> on <head>",
    +
    + &(tagfilter_html_noscript_head[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_datalist = {
    + TAGFILTER_TAGS_magic,
    +
    + "text/html content of <datalist>",
    + &(tagfilter_html_datalist[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_details = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <details>",
    + &(tagfilter_html_details[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_dl = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <dl>",
    + &(tagfilter_html_dl[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_fieldset = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <fieldset>",
    + &(tagfilter_html_fieldset[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_figure = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <figure>",
    + &(tagfilter_html_figure[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_footer = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <footer>",
    + &(tagfilter_html_footer[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_form = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <form>",
    + &(tagfilter_html_form[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_hgroup = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <hgroup>",
    + &(tagfilter_html_hgroup[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_label = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <label>",
    + &(tagfilter_html_label[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_list_items = {
    + TAGFILTER_TAGS_magic,
    + "text/html list items",
    + &(tagfilter_html_list_items[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_close_li = {
    + TAGFILTER_TAGS_magic,
    + "text/html closing tags for <li>",
    + &(tagfilter_html_close_li[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_close_p = {
    + TAGFILTER_TAGS_magic,
    + "text/html closing tags for <p>",
    + &(tagfilter_html_close_p[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_address = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <address>",
    + &(tagfilter_html_address[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_meter = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <meter>",
    + &(tagfilter_html_meter[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_picture = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <picture>",
    + &(tagfilter_html_picture[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_progress = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <progress>",
    + &(tagfilter_html_progress[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_ruby = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <ruby>",
    + &(tagfilter_html_ruby[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_table = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <table>",
    + &(tagfilter_html_table[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_div_dl = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <div> on <dl>",
    + &(tagfilter_html_div_dl[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_caption = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <caption>",
    + &(tagfilter_html_caption[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_colgroup = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <colgroup>",
    + &(tagfilter_html_colgroup[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_tr_list = {
    + TAGFILTER_TAGS_magic,
    + "text/html <tr> items",
    + &(tagfilter_html_tr_list[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_tr = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <tr>",
    + &(tagfilter_html_tr[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_close_thead = {
    + TAGFILTER_TAGS_magic,
    + "text/html closing tags for <thead>",
    + &(tagfilter_html_close_thead[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_close_tbody = {
    + TAGFILTER_TAGS_magic,
    + "text/html closing tags for <tbody>",
    + &(tagfilter_html_close_tbody[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_close_tr = {
    + TAGFILTER_TAGS_magic,
    + "text/html closing tags for <tr>",
    + &(tagfilter_html_close_tr[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_close_td = {
    + TAGFILTER_TAGS_magic,
    + "text/html closing tags for <td>",
    + &(tagfilter_html_close_td[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_th = {
    + TAGFILTER_TAGS_magic,
    + "text/html content of <th>",
    + &(tagfilter_html_th[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_close_th = {
    + TAGFILTER_TAGS_magic,
    + "text/html closing tags for <th>",
    + &(tagfilter_html_close_th[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_close_dtdd = {
    + TAGFILTER_TAGS_magic,
    + "text/html closing tags for <dt> and <dd>",
    + &(tagfilter_html_close_dtdd[0]),
    + NULL
    + };
    +
    + struct tagfilter_tags text_html_close_rtrp = {
    + TAGFILTER_TAGS_magic,
    + "text/html closing tags for <rt> and <rp>",
    + &(tagfilter_html_close_rtrp[0]),
    + NULL
    + };
    +
    + E_(give_top_stack_item_f give_top_text_html)
    + struct tagfilter_stack_item * give_top_text_html
    + P_((mime_t * body,
    + struct in_state * state_in,
    + struct out_state * state_out,
    + const struct decode_opts * decode_opt,
    + charset_t text_charset,
    + struct tagfilter_selection * tagfilter));
    + struct tagfilter_stack_item * give_top_text_html(body,state_in,state_out,
    + decode_opt,text_charset,
    + tagfilter)
    + mime_t * body;
    + struct in_state * state_in;
    + struct out_state * state_out;
    + const struct decode_opts * decode_opt;
    + charset_t text_charset;
    + struct tagfilter_selection * tagfilter;
    + {
    + struct tagfilter_stack_item * ret = NULL;
    + struct pager_range * html_body_range = NULL;
    +
    + /* What is good settings ? */
    +
    +
    + if (MIME_magic != body->magic)
    + mime_panic(__FILE__,__LINE__,"give_top_text_html",
    + "Bad magic number (mime_t)");
    +
    + if (decode_opt)
    + html_body_range =
    + state_add_simple_pager_range(state_out,
    + /* Handles quote prefix */
    + decode_opt->range,
    + PR_WORD_WRAP|PR_JOIN_LINES|
    + PR_ADD_SPACE,0,0);
    + else
    + html_body_range =
    + state_add_simple_pager_range(state_out,
    + NULL,
    + PR_WORD_WRAP|PR_JOIN_LINES|
    + PR_ADD_SPACE,0,0);
    +
    + ret = tagfilter_new_stack_item(html_body_range,
    + 0,
    + &text_html_top,
    + NULL);
    +
    + if (TAGFILTER_STACK_ITEM_magic != ret->magic)
    + mime_panic(__FILE__,__LINE__,"give_top_text_html",
    + "Bad magic number (tagfilter_stack_item)");
    +
    + free_pager_range(&html_body_range);
    +
    + return ret;
    + }
    +
    + static struct pager_range *new_html_item_hlp1
    + P_((struct tagfilter_cmd * current_tag,
    + struct pager_range * prev_range,
    + struct out_state * state_out,
    + int * text_visible_p,
    + int inherit_pg_flags
    +
    + ));
    + static struct pager_range *
    + new_html_item_hlp1(current_tag,
    + prev_range,
    + state_out,
    + text_visible_p,
    + inherit_pg_flags)
    + struct tagfilter_cmd * current_tag;
    + struct pager_range * prev_range;
    + struct out_state * state_out;
    + int * text_visible_p;
    + int inherit_pg_flags;
    + {
    + struct pager_range * new_range = NULL;
    + int text_visible = * text_visible_p;
    +
    + if (TAGFILTER_CMD_magic != current_tag->magic)
    + mime_panic(__FILE__,__LINE__,
    + "new_html_item_hlp1",
    + "Bad magic number (tagfilter_cmd)");
    +
    + if (text_visible && ison(current_tag->cmd_mode,
    + TAGFLT_CMD_hide_text))
    + text_visible = 0;
    + else if (ison(current_tag->cmd_mode,
    + TAGFLT_CMD_show_text))
    + text_visible = 1;
    +
    +
    + switch (current_tag->code.html) {
    + int i;
    + case tfc_html_unsupported:
    + case tfc_html_none: break;
    + case tfc_html_br: {
    + int prev_flags = 0;
    +
    + if (prev_range &&
    + (prev_flags = get_pager_range_flags(prev_range)) &&
    + ison(prev_flags,PR_JOIN_LINES)) {
    +
    + /* New range without flags */
    +
    + new_range =
    + state_add_simple_pager_range(state_out,
    + prev_range,
    + PR_FLAGS_ABSOLUTE,
    + 0,0);
    +
    +
    + }
    +
    + /* Re-set pg_flags */
    + set_out_state_line_mode(state_out,inherit_pg_flags,
    + new_range ? new_range : prev_range,
    + 1 /* Newline */);
    +
    + state_putc('\n',state_out);
    +
    + }
    + break;
    +
    + case tfc_html_hr:
    + state_putc('\n',state_out);
    +
    + new_range =
    + state_add_simple_pager_range(
    + state_out,
    + prev_range, /* Not very good */
    + PR_CENTER_THIS|PR_FLAGS_ABSOLUTE,
    + 0 /* quote level */,
    + 0 /* indent */);
    +
    + /* Re-set pg_flags */
    + set_out_state_line_mode(state_out,inherit_pg_flags,
    + new_range,0 );
    +
    +
    + for (i = 0; i < 10; i++)
    + state_putc('-',state_out);
    +
    + break;
    +
    + case tfc_html_p:
    + state_putc('\n',state_out);
    +
    + new_range =
    + state_add_simple_pager_range(state_out,
    + prev_range,
    + PR_WORD_WRAP|PR_JOIN_LINES|
    + PR_ADD_SPACE,
    + 0 /* quote level */,
    + 0 /* indent */);
    +
    + /* Re-set pg_flags */
    + set_out_state_line_mode(state_out,inherit_pg_flags,
    + new_range,0 );
    + break;
    +
    + case tfc_html_pre: {
    + /* Calculate absolute range flags */
    + int range_flags = PR_FLAGS_ABSOLUTE;
    +
    + if (prev_range)
    + setit(range_flags,get_pager_range_flags(prev_range));
    + clearit(range_flags,PR_JOIN_LINES);
    + clearit(range_flags,PR_ADD_SPACE);
    + clearit(range_flags,PR_WORD_WRAP);
    + clearit(range_flags,PR_SAME_LINE);
    +
    + new_range = state_add_simple_pager_range(state_out,
    + prev_range,
    + range_flags,
    + 0,0);
    + /* Re-set pg_flags */
    + set_out_state_line_mode(state_out,inherit_pg_flags,
    + new_range,0 );
    +
    + }
    + break;
    + case tfc_html_q:
    + state_putc('"',state_out);
    + break;
    + case tfc_html_li:
    +
    + new_range = state_add_simple_pager_range(state_out,
    + prev_range,
    + 0,
    + 0,0);
    + set_out_state_line_mode(state_out,inherit_pg_flags,
    + new_range,0 );
    + break;
    +
    + }
    +
    + * text_visible_p = text_visible;
    +
    + return new_range;
    + }
    +
    + /* XXX Currently dummy -- parameters need check when used */
    + static void new_html_item_hlp2 P_((struct tagfilter_cmd * current_tag, + struct pager_range * new_range,
    + struct tagfilter_tag_state * tag_state,
    + struct out_state * state_out,
    + int text_visible,
    + struct tagfilter_selection * tagfilter,
    + struct tagfilter_stack_item * stack_item
    + ));
    + static void new_html_item_hlp2(current_tag,new_range,
    + tag_state,state_out,
    + text_visible,tagfilter,
    + stack_item)
    + struct tagfilter_cmd * current_tag;
    + struct pager_range * new_range;
    + struct tagfilter_tag_state * tag_state;
    + struct out_state * state_out;
    + int text_visible;
    + struct tagfilter_selection * tagfilter;
    + struct tagfilter_stack_item * stack_item;
    + {
    + if (TAGFILTER_CMD_magic != current_tag->magic)
    + mime_panic(__FILE__,__LINE__,
    + "new_html_item_hlp2",
    + "Bad magic number (tagfilter_cmd)");
    +
    + switch (current_tag->code.html) {
    + case tfc_html_unsupported:
    + case tfc_html_none: break;
    +
    +
    + case tfc_html_br: break;
    + case tfc_html_hr: break;
    +
    + case tfc_html_p: break;
    + case tfc_html_pre: break;
    + case tfc_html_q: break;
    + case tfc_html_li: break;
    +
    +
    + }
    +
    + }
    +
    +
    +
    + static struct tagfilter_stack_item * process_new_html_item2
    + P_((struct tagfilter_cmd * current_tag,
    + struct pager_range * prev_range,
    + struct tagfilter_tag_state * current_state,
    + struct out_state * state_out,
    + struct tagfilter_selection * tagfilter,
    + int is_last,
    + struct tagfilter_tags * used_tags,
    + int inherit_pg_flags,
    + int text_visible,
    + const struct decode_opts * decode_opt
    + ));
    + static struct tagfilter_stack_item *
    + process_new_html_item2(current_tag,prev_range,
    + current_state,
    + state_out,
    + tagfilter,is_last,
    + used_tags,
    + inherit_pg_flags,
    + text_visible,
    + decode_opt
    + )
    + struct tagfilter_cmd * current_tag;
    + struct pager_range * prev_range;
    + struct tagfilter_tag_state * current_state;
    + struct out_state * state_out;
    + struct tagfilter_selection * tagfilter;
    + int is_last;
    + struct tagfilter_tags * used_tags;
    + int inherit_pg_flags;
    + int text_visible;
    + const struct decode_opts * decode_opt;
    + {
    +
    + struct tagfilter_stack_item * ret = NULL;
    + struct pager_range * new_range = NULL;
    +
    + if (TAGFILTER_CMD_magic != current_tag->magic)
    + mime_panic(__FILE__,__LINE__,"process_new_html_item2",
    + "Bad magic number (tagfilter_cmd)");
    +
    + if (current_tag->ascii_command) {
    + DPRINT(Debug,21,(&Debug,
    + "process_new_html_item2: command %s%s\n",
    + current_tag->ascii_command,
    + is_last ? ", is last" : ""));
    + }
    +
    +
    + new_range = new_html_item_hlp1(current_tag,
    + prev_range,
    + state_out,
    + &text_visible,
    + inherit_pg_flags);
    +
    + if (!new_range &&
    + ison(current_tag->cmd_mode,TAGFLT_CMD_force_newline)) {
    +
    + DPRINT(Debug,21,(&Debug,
    + "process_new_html_item2: TAGFLT_CMD_force_newline set, forcing new range\n"));
    +
    + new_range = state_add_simple_pager_range(state_out,
    + prev_range,
    + 0,0,0);
    +
    + }
    +
    +
    + DPRINT(Debug,21,(&Debug,
    + "process_new_html_item2: pg_flags %d %s\n",
    + current_tag->pg_flags,
    + give_pg_flags(current_tag->pg_flags)));
    +
    +
    + ret = tagfilter_new_stack_item(new_range,
    + current_tag->pg_flags,
    + ison(current_tag->cmd_mode,
    + TAGFLT_CMD_inherit_nested_tags) ?
    + used_tags /* Transparent content model */ : + NULL /* Use current_tag */,
    + current_tag);
    +
    + if (TAGFILTER_STACK_ITEM_magic != ret->magic)
    + mime_panic(__FILE__,__LINE__,"process_new_html_item2",
    + "Bad magic number (tagfilter_stack_item)");
    +
    + ret->text_visible = text_visible;
    +
    + new_html_item_hlp2(current_tag,new_range,
    + current_state,state_out,text_visible,
    + tagfilter,ret);
    +
    + if (new_range)
    + free_pager_range(& new_range);
    +
    + return ret;
    + }
    +
    +
    + static struct tagfilter_tag_state * process_new_html_item
    + P_((struct tagfilter_cmd * current_tag,
    + struct pager_range * prev_range,
    + struct tagfilter_stack_item **new_item,
    + struct out_state * state_out,
    + struct tagfilter_global * counter,
    + struct tagfilter_selection * tagfilter,
    + struct tagfilter_tags * tags,
    + int push_current,
    + struct tagfilter_tags * used_tags,
    + int inherited_pg_flags,
    + int text_visible,
    + const struct decode_opts * decode_opt
    + ));
    + static struct tagfilter_tag_state *
    + process_new_html_item(current_tag,
    + prev_range,
    + new_item,
    + state_out,
    + counter,
    + tagfilter,tags,
    + push_current,
    + used_tags,
    + inherit_pg_flags,
    + text_visible,
    + decode_opt
    + )
    + struct tagfilter_cmd * current_tag;
    + struct pager_range * prev_range;
    + struct tagfilter_stack_item **new_item;
    + struct out_state * state_out;
    + struct tagfilter_global * counter;
    + struct tagfilter_selection * tagfilter;
    + struct tagfilter_tags * tags;
    + int push_current /* Do not generate new_item now */;
    + struct tagfilter_tags * used_tags;
    + int inherit_pg_flags;
    + int text_visible;
    + const struct decode_opts * decode_opt;
    + {
    +
    + struct pager_range * new_range = NULL;
    + struct tagfilter_tag_state *ret = NULL;
    +
    + if (TAGFILTER_CMD_magic != current_tag->magic)
    + mime_panic(__FILE__,__LINE__,
    + "process_new_html_item",
    + "Bad magic number (tagfilter_cmd)");
    +
    + if (current_tag->ascii_command) {
    + DPRINT(Debug,21,(&Debug,
    + "process_new_html_item: command %s%s\n",
    + current_tag->ascii_command,
    + push_current ? ", push current" : ""));
    + }
    +
    + new_range = new_html_item_hlp1(current_tag,
    + prev_range,
    + state_out,
    + &text_visible,
    + inherit_pg_flags);
    +
    + if (tfc_html_unsupported == current_tag->code.html) {
    + tagfilter_add_unknown_tag(counter,current_tag,
    + tagfilter);
    + } else if (tfc_html_li == current_tag->code.html) {
    + /* XXX still unsupported */
    +
    + tagfilter_add_unknown_tag(counter,current_tag,
    + tagfilter);
    +
    + }
    +
    + if (current_tag->code.html > tfc_html_none)
    + ret = tagfilter_new_tag_state(current_tag);
    +
    + if (!new_range &&
    + ison(current_tag->cmd_mode,TAGFLT_CMD_force_newline)) {
    +
    + DPRINT(Debug,21,(&Debug,
    + "process_new_html_item: TAGFLT_CMD_force_newline set, forcing new range\n"));
    +
    + new_range = state_add_simple_pager_range(state_out,
    + prev_range,
    + 0,0,0);
    +
    + }
    +
    + if (new_item && !push_current) {
    +
    + DPRINT(Debug,21,(&Debug,
    + "process_new_html_item: pg_flags %d %s\n",
    + current_tag->pg_flags,
    + give_pg_flags(current_tag->pg_flags)));
    +
    + *new_item = tagfilter_new_stack_item(new_range,
    + current_tag->pg_flags,
    + ison(current_tag->cmd_mode,
    + TAGFLT_CMD_inherit_nested_tags) ?
    + used_tags /* Transparent content model */ :
    + NULL /* Use current_tag */,
    + current_tag);
    +
    + if (TAGFILTER_STACK_ITEM_magic != (*new_item)->magic)
    + mime_panic(__FILE__,__LINE__,"process_new_html_item",
    + "Bad magic number (tagfilter_stack_item)");
    +
    + (*new_item)->text_visible = text_visible;
    +
    + } else if (push_current && ret) {
    + if (TAGFILTER_TAG_STATE_magic != ret->magic)
    + mime_panic(__FILE__,__LINE__,"process_new_html_item",
    + "Bad magic number (tagfilter_tag_state)");
    +
    +
    +
    + if (!ret->u.html)
    + ret->u.html = tagfilter_new_html_state();
    +
    + tagfilter_html_state_push_command(ret->u.html,
    + current_tag,
    + used_tags);
    +
    + }
    +
    + new_html_item_hlp2(current_tag,new_range,
    + ret,state_out,
    + text_visible,tagfilter,
    + new_item ? *new_item: NULL);
    +
    +
    + if (new_range)
    + free_pager_range(& new_range);
    +
    + return ret;
    + }
    +
    + struct tag_search_item {
    +
    + struct tagfilter_push_tag * cmd_list;
    + int cmd_list_len;
    +
    + struct tagfilter_tags * tags;
    + };
    +
    + /* Returns found item -- not refcounted */
    +
    + static struct tag_search_item * generate_search_list
    + P_((struct tagfilter_tags * tags,
    + struct tag_search_item ** search_xxx,
    + int * search_xxx_len,
    + struct string * tag_name,
    + struct tagfilter_selection * sel_backlink
    + ));
    + static struct tag_search_item * generate_search_list(tags,
    + search_xxx,
    + search_xxx_len,
    + tag_name,
    + sel_backlink)
    + struct tagfilter_tags * tags;
    + struct tag_search_item ** search_xxx;
    + int * search_xxx_len;
    + struct string * tag_name;
    + struct tagfilter_selection * sel_backlink;
    + {
    + struct tag_search_item * ret = NULL;
    + struct tag_search_item * search_list = * search_xxx;
    + int search_list_len = * search_xxx_len;
    + int i;
    +
    + for (i = -1; i < search_list_len; i++) {
    + struct tagfilter_tags * t = NULL;
    + struct tagfilter_cmd * c = NULL;
    +
    + struct tagfilter_push_tag * c_list = NULL;
    + int c_list_len = 0;
    +
    + int k;
    +
    + if (i < 0) {
    + t = tags;
    +
    + c_list = NULL;
    + c_list_len = 0;
    +
    + } else {
    + t = search_list[i].tags;
    +
    + c_list = search_list[i].cmd_list;
    + c_list_len = search_list[i].cmd_list_len;
    + }
    +
    + if (!t)
    + continue;
    +
    + if (TAGFILTER_TAGS_magic != t->magic)
    + mime_panic(__FILE__,__LINE__,"generate_search_list",
    + "Bad magic number (tagfilter_tags)");
    +
    + DPRINT(Debug,21,(&Debug,
    + "generate_search_list: %d: Checking %s for %S\n",
    + i,t->context,tag_name));
    +
    +
    + c = locate_command(t,tag_name,sel_backlink);
    +
    + if (c) {
    + int j;
    +
    + if (TAGFILTER_CMD_magic != c->magic)
    + mime_panic(__FILE__,__LINE__,"generate_search_list",
    + "Bad magic number (tagfilter_cmd)");
    +
    + search_list = safe_array_realloc(search_list,
    + search_list_len+1,
    + sizeof (search_list[0]));
    +
    + /* Not really needed */
    + search_list[search_list_len].tags = c->nesting;
    +
    + search_list[search_list_len].cmd_list =
    + safe_calloc(c_list_len+1,
    + sizeof (search_list[search_list_len].cmd_list[0])); +
    + for (j = 0; j < c_list_len; j++) {
    + search_list[search_list_len].cmd_list[j] = c_list[j];
    +
    + tagfilter_inc_cmd_refcount(search_list[search_list_len].
    + cmd_list[j].cmd);
    + }
    +
    + search_list[search_list_len].cmd_list[j].cmd = c;
    + search_list[search_list_len].cmd_list[j].used_tags = t;
    + tagfilter_inc_cmd_refcount(search_list[search_list_len].
    + cmd_list[j].cmd);
    + search_list[search_list_len].cmd_list_len = j+1;
    +
    + ret = & (search_list[search_list_len] );
    + search_list_len++;
    + goto done;
    + }
    +
    + for (k = 0; t->tags[k]; k++) {
    + int a;
    + int j;
    + struct tagfilter_cmd * C;
    +
    + if (TAGFILTER_CMD_magic != t->tags[k]->magic)
    + mime_panic(__FILE__,__LINE__,"generate_search_list",
    + "Bad magic number (tagfilter_cmd)");
    +
    + C = t->tags[k];
    +
    + if (! C->nesting)
    + continue;
    +
    +
    +
    + /* Only search nested if opening tag is optional */
    + if (isoff(C-> cmd_mode,TAGFLT_CMD_nested_search)) {
    +
    + if (C->ascii_command) {
    +
    + DPRINT(Debug,22,(&Debug,
    + "generate_search_list: %d: %d: %s on %s does not support nested search\n",
    + i,k,C->ascii_command,
    + t->context));
    +
    +
    + }
    +
    + continue;
    + }
    +
    +
    + for (a = 0; a < search_list_len; a++) {
    +
    + if (C->nesting == search_list[a].tags) {
    + goto found;
    + }
    + }
    +
    + if (C->ascii_command) {
    + DPRINT(Debug,21,(&Debug,
    + "generate_search_list: %d: %d: %s on %s -> added to search list %d\n",
    + i,k,C->ascii_command,
    + t->context,search_list_len));
    + }
    +
    + search_list = safe_array_realloc(search_list,
    + search_list_len+1,
    + sizeof (search_list[0]));
    +
    + search_list[search_list_len].tags = C->nesting;
    +
    + search_list[search_list_len].cmd_list =
    + safe_calloc(c_list_len+1,
    + sizeof (search_list[search_list_len].
    + cmd_list[0]));
    +
    + for (j = 0; j < c_list_len; j++) {
    + search_list[search_list_len].cmd_list[j] = c_list[j];
    +
    + tagfilter_inc_cmd_refcount(search_list[search_list_len].
    + cmd_list[j].cmd);
    + }
    +
    + search_list[search_list_len].cmd_list[j].cmd = C;
    + search_list[search_list_len].cmd_list[j].used_tags = t;
    + tagfilter_inc_cmd_refcount(search_list[search_list_len].
    + cmd_list[j].cmd);
    + search_list[search_list_len].cmd_list_len = j+1;
    +
    + search_list_len++;
    +
    + found:
    + ;
    + }
    + }
    +
    + done:
    +
    + * search_xxx = search_list;
    + * search_xxx_len = search_list_len;
    +
    + return ret;
    + }
    +
    + /* Invalidates also found item */
    +
    + static void free_search_list P_((struct tag_search_item ** search_xxx,
    + int * search_xxx_len));
    + static void free_search_list(search_xxx,
    + search_xxx_len)
    + struct tag_search_item ** search_xxx;
    + int * search_xxx_len;
    + {
    + struct tag_search_item * search_list = * search_xxx;
    + int search_list_len = * search_xxx_len;
    +
    + if (search_list) {
    + int i;
    +
    + for (i = 0; i < search_list_len; i++) {
    +
    + if (search_list[i].cmd_list) {
    + int j;
    +
    +
    + for (j = 0; j < search_list[i].cmd_list_len; j++) {
    + tagfilter_release_cmd(&
    + search_list[i].cmd_list[j].cmd);
    + search_list[i].cmd_list[j].used_tags = NULL;
    + }
    +
    + free (search_list[i].cmd_list);
    + search_list[i].cmd_list = NULL;
    + }
    + search_list[i].cmd_list_len = 0;
    +
    + }
    +
    + free(search_list);
    + search_list = NULL;
    + }
    + search_list_len = 0;
    +
    + * search_xxx = search_list;
    + * search_xxx_len = search_list_len;
    + }
    +
    +
    +
    + E_( give_stack_item_f give_item_text_html)
    + struct tagfilter_tag_state *
    + give_item_text_html P_((struct tagfilter_stack_item **new_item,
    + struct tagfilter_tags * tags,
    + struct string * tag_name,
    + struct tagfilter_stack_item **stack,
    + size_t stack_len,
    + size_t * stack_pos,
    + mime_t * body,
    + struct in_state * state_in,
    + struct out_state * state_out,
    + const struct decode_opts * decode_opt,
    + charset_t text_charset,
    + struct tagfilter_selection * tagfilter,
    + struct tagfilter_global * counter
    + ));
    + struct tagfilter_tag_state *give_item_text_html(new_item,tags,tag_name,
    + stack,stack_len,stack_pos,
    + body,state_in,state_out,
    + decode_opt,
    + text_charset, tagfilter,
    + counter)
    + struct tagfilter_stack_item **new_item;
    + struct tagfilter_tags * tags;
    + struct string * tag_name;
    + struct tagfilter_stack_item **stack;
    + size_t stack_len;
    + size_t * stack_pos;
    + mime_t * body;
    + struct in_state * state_in;
    + struct out_state * state_out;
    + const struct decode_opts * decode_opt;
    + charset_t text_charset;
    + struct tagfilter_selection * tagfilter;
    + struct tagfilter_global * counter;
    + {
    + int text_visible = 1;
    + struct tagfilter_tag_state * ret = NULL;
    + struct tagfilter_cmd * current_tag = NULL;
    +
    + size_t STACK_pos = stack_len;
    +
    + struct tagfilter_tags * used_tags = NULL;
    +
    + int push_current = 0;
    +
    +
    + /* Allocates new tagfilter_tag_state
    + (also NULL return possible) --
    + gives struct tagfilter_stack_item if
    + push_stack_item() needs not be used */
    +
    + if (TAGFILTER_SELECTION_magic != tagfilter->magic)
    + mime_panic(__FILE__,__LINE__,"give_item_text_html",
    + "Bad magic number (tagfilter_selection)");
    +
    + if (new_item && *new_item)
    + tagfilter_free_stack_item(new_item,tagfilter);
    +
    + * stack_pos = stack_len;
    +
    + if (!tags && tag_name) {
    + DPRINT(Debug,20,(&Debug,
    + "give_item_text_html: %S - no tags, stack_len=%zu\n", + tag_name,stack_len));
    + } else if (tags && tag_name) {
    + if (TAGFILTER_TAGS_magic != tags->magic)
    + mime_panic(__FILE__,__LINE__,"give_item_text_html",
    + "Bad magic number (tagfilter_tags)");
    +
    +
    + DPRINT(Debug,20,(&Debug,
    + "give_item_text_html: %S - for %s, stack_len=%zu\n",
    + tag_name,tags->context,stack_len));
    + }
    +
    + if (tag_name && stack && stack_len > 0) {
    + size_t i = stack_len;
    +
    + /* Check for auto close */
    +
    + while (i > 0) {
    + i--;
    +
    + if (stack[i]) {
    + if (TAGFILTER_STACK_ITEM_magic != stack[i]->magic)
    + mime_panic(__FILE__,__LINE__,
    + "give_item_text_html",
    + "Bad magic number (tagfilter_stack_item)");
    +
    + if (! stack[i]->current_tag)
    + continue;
    +
    + if (TAGFILTER_CMD_magic != stack[i]->current_tag->magic)
    + mime_panic(__FILE__,__LINE__,"give_item_text_html",
    + "Bad magic number (tagfilter_cmd)");
    +
    + if ( ! stack[i]->current_tag->auto_close)
    + break;
    +
    + current_tag = locate_command(stack[i]->current_tag->
    + auto_close,
    + tag_name,tagfilter);
    +
    + if (current_tag) {
    + used_tags = tags;
    + STACK_pos = i;
    +
    + /* Do not generate new_item now */
    + if (stack[i]->current_tag->code.base >= tfc_none)
    + push_current = 1;
    +
    + }
    +
    + break; /* End search anyway */
    + }
    + }
    + }
    +
    + if (tag_name && tags && !current_tag) {
    +
    + if (TAGFILTER_TAGS_magic != tags->magic)
    + mime_panic(__FILE__,__LINE__,"give_item_text_html",
    + "Bad magic number (tagfilter_tags)");
    +
    + /* locate_command() does not check nested */
    +
    + current_tag = locate_command(tags,tag_name,tagfilter);
    +
    + if (current_tag) {
    + used_tags = tags;
    + STACK_pos = stack_len;
    +
    + }
    + }
    +
    + if (tag_name && !current_tag) {
    +
    + /* Check upper on on tag */
    +
    + if (stack && stack_len > 0) {
    + size_t i = stack_len;
    +
    + int maybe_push_current = 0;
    +
    + while (i > 0) {
    + i--;
    +
    + if (stack[i]) {
    + if (TAGFILTER_STACK_ITEM_magic != stack[i]->magic)
    + mime_panic(__FILE__,__LINE__,
    + "give_item_text_html",
    + "Bad magic number (tagfilter_stack_item)"); +
    + if (! stack[i]->current_tag)
    + continue;
    +
    + if (TAGFILTER_CMD_magic !=
    + stack[i]->current_tag->magic)
    + mime_panic(__FILE__,__LINE__,
    + "give_item_text_html",
    + "Bad magic number (tagfilter_cmd)");
    +
    + /* Do not generate new_item now */
    + if (stack[i]->current_tag->code.base >= tfc_none)
    + maybe_push_current = 1;
    +
    +
    + if (stack[i]->nested_tags) {
    + current_tag = locate_command(stack[i]->
    + nested_tags,
    + tag_name,tagfilter);
    +
    + if (current_tag) {
    + /* Potentially replaces next tag on stack */
    +
    + STACK_pos = i+1;
    + used_tags = stack[i]->nested_tags;
    +
    + /* Do not generate new_item now */
    + if (maybe_push_current)
    + push_current = 1;
    +
    +
    + break;
    + }
    + }
    +
    + /* Stop searching if
    + TAGFLT_CMD_close_search
    + in not set */
    +
    + if (isoff(stack[i]->current_tag->cmd_mode,
    + TAGFLT_CMD_close_search))
    + break;
    + }
    + }
    + }
    + }
    +
    + if (tag_name && !current_tag) {
    + struct tag_search_item * search_list = NULL;
    + int search_list_len = 0;
    +
    + struct tag_search_item * found_xx
    + = generate_search_list(tags,
    + &search_list,&search_list_len,
    + tag_name,
    + tagfilter);
    +
    + if (found_xx &&
    + found_xx->cmd_list &&

    [continued in next message]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)