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

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

    + "[ %s/%s is unsupported, filtering tags. ]\n"),
    + get_major_type_name(body->TYPE),
    + get_subtype_name(body->TYPE));
    +
    + }
    +
    +
    + top_item = tagfilter->give_top_item(body,state_in,state_out,
    + decode_opt,
    + text_charset,tagfilter);
    + if (top_item) {
    + params.stack = safe_malloc(sizeof (params.stack[0]));
    +
    + params.stack[0] = top_item;
    + params.stack_len = 1;
    +
    + }
    +
    + if (current_token_len >= 0 && tagfilter->doctype_name &&
    + tf_doctype_start == current_token.token_class) {
    +
    + current_token_len =
    + tagfilter_handle_doctype(&params,current_token_len);
    +
    + }
    +
    + errors3 = print_in_errors(state_in,state_out,decode_opt);
    +
    + if (errors3 > 0) {
    +
    + DPRINT(Debug,10,(&Debug,
    + "tagfilter_decoder: %d errors, current token len = %d, class = %d %s\n",
    + errors3,current_token_len,current_token.token_class,
    + token_class_string(current_token.token_class)));
    +
    + /* Retry after errors */
    + if (current_token_len < 0)
    + current_token_len =
    + get_new_tagfilter_token(&current_token,
    + tagfilter,state_in);
    + }
    +
    + while (current_token_len >= 0) {
    + int errors;
    +
    + DPRINT(Debug,15,(&Debug,
    + "tagfilter_decoder: current token len = %d, class = %d %s\n",
    + current_token_len,current_token.token_class,
    + token_class_string(current_token.token_class)));
    + if (current_token.sbuffer) {
    + DEBUG_PRINT_STRING(Debug,19,
    + "tagfilter_decoder: current token = ",
    + "tagfilter_decoder: current token > ",
    + current_token.sbuffer);
    + }
    +
    +
    + switch (current_token.token_class) {
    + default:
    + if (current_token.token_class < tf_body /* 0 */) {
    + case tf_doctype_error /* -7 */:
    + case tf_tag_atrvalue_error /* -6 */:
    + case tf_tag_param_error /* -5 */:
    + case tf_comment_error /* -4 */:
    + case tf_bcomment_error /* -3 */:
    + case tf_tag_error /* -2 */:
    + case tf_entity_error /* -1 */:
    +
    + current_token_len =
    + tagfilter_handle_error(&params,current_token_len);
    +
    + } else {
    + case tf_bcomment_chunk:
    + case tf_bcomment_end:
    + case tf_comment_chunk:
    + case tf_comment_end:
    + case tf_tag_space:
    + case tf_tag_atrname:
    + case tf_tag_selfclosed_end:
    + case tf_tag_end:
    + case tf_tag_atrequal:
    + case tf_tag_atrvalue_start:
    + case tf_tag_atrvalue_segment:
    + case tf_tag_atrvalue_end:
    + case tf_doctype_start:
    + case tf_doctype_segment:
    + case tf_doctype_space:
    + case tf_doctype_end:
    + case tf_doctype_item:
    + goto unhandled_token;
    +
    + }
    + break;
    +
    + case tf_entity:
    + case tf_numeric_entity:
    + if (ts_init != current_token.tag_state)
    + goto unhandled_token;
    + /* FALLTHRU */
    + case tf_double_smaller:
    + /* text/enriched */
    + case tf_body:
    + current_token_len =
    + tagfilter_handle_body(&params,current_token_len);
    + break;
    +
    + case tf_start_tag:
    + case tf_whole_tag:
    + case tf_selfclosed_tag:
    + case tf_start_endtag:
    + case tf_whole_endtag:
    + current_token_len =
    + tagfilter_handle_tag(&params,current_token_len);
    + break;
    +
    + case tf_bcomment_start:
    + /* Bocus comment */
    +
    + current_token_len =
    + tagfilter_handle_bcomment(&params,current_token_len);
    + break;
    +
    + case tf_span_nl:
    + /* text/enriched */
    +
    + current_token_len =
    + tagfilter_handle_span_nl(&params,current_token_len);
    + break;
    +
    + case tf_comment_start:
    + case tf_whole_comment:
    + /* Real comment */
    +
    + current_token_len =
    + tagfilter_handle_comment(&params,current_token_len);
    + break;
    + }
    +
    +
    + if (ison(current_token.tag_flags,TFLAG_unhandled_class)) {
    + int inherit_pg_flags;
    + struct pager_range * inherit;
    +
    + unhandled_token:
    +
    + inherit_pg_flags = tagfilter_inherited_pg_flags(&params);
    + inherit = tagfilter_inherited_pager_range(&params);
    +
    +
    + if (current_token.error)
    + params.error = 1;
    +
    + set_out_state_line_mode(state_out,pg_UNDERLINE,inherit,0 );
    +
    + /* unhandled -- dump it directly */
    + tagfilter_dump_token(&params,0);
    +
    + if (current_token.have_nl)
    + state_putc('\n',state_out);
    +
    + /* Should not cause newline */
    + set_out_state_line_mode(state_out,inherit_pg_flags,inherit,0 );
    +
    + current_token_len =
    + get_new_tagfilter_token(&current_token,
    + tagfilter,state_in);
    +
    + } else {
    + setit(current_token.tag_flags,TFLAG_unhandled_class);
    + }
    +
    + if (!error && params.error) {
    + int inherit_pg_flags = tagfilter_inherited_pg_flags(&params);
    + struct pager_range *inherit = tagfilter_inherited_pager_range(&params);
    +
    + const char * text_charset_MIME_name = get_charset_MIME_name(text_charset);
    +
    + struct pager_range *title_range =
    + state_add_simple_pager_range(state_out,inherit,PR_MAX_WIDTH,0, + 0);
    +
    + /* \n resets this */
    + set_out_state_line_mode(state_out,pg_BOLD,title_range,1 /* Newline */);
    +
    + state_printf(state_out,
    + CATGETS(elm_msg_cat, MeSet,
    + MeTagFErrorCharacterFlag,
    + "[ %/%s format have NUL characters or have some bytes, which can't be interpreted as characters of charset %s. ]\n"),
    + get_major_type_name(body->TYPE),
    + get_subtype_name(body->TYPE),
    + text_charset_MIME_name);
    +
    + free_pager_range(&title_range);
    + error = 1;
    + params.error = 0;
    +
    + /* Should not cause newline */
    + set_out_state_line_mode(state_out,inherit_pg_flags,inherit,0 );
    + }
    +
    + errors = print_in_errors(state_in,state_out,decode_opt);
    +
    + if (errors > 0) {
    + int inherit_pg_flags = tagfilter_inherited_pg_flags(&params);
    + struct pager_range *inherit = tagfilter_inherited_pager_range(&params);
    +
    + /* Should not cause newline */
    + set_out_state_line_mode(state_out,inherit_pg_flags,
    + inherit,0 );
    +
    + DPRINT(Debug,10,(&Debug,
    + "tagfilter_decoder: %d errors, current token len = %d, class = %d %s\n",
    + errors,current_token_len,current_token.token_class,
    + token_class_string(current_token.token_class)));
    +
    +
    +
    + /* Retry after errors */
    + if (current_token_len < 0)
    + current_token_len =
    + get_new_tagfilter_token(&current_token,
    + tagfilter,state_in);
    + }
    + }
    +
    + if (current_token_len < 0) {
    +
    + if (in_state_ferror(state_in)) {
    + struct pager_range *inherit
    + = tagfilter_inherited_pager_range(&params);
    +
    + struct pager_range *title_range =
    + state_add_simple_pager_range(state_out,inherit,PR_MAX_WIDTH,0, + 0);
    +
    + state_printf(state_out,
    + CATGETS(elm_msg_cat, MeSet,
    + MeTagFErrorReadCont,
    + "[ Error when reading %s/%s content. ]\n"),
    + get_major_type_name(body->TYPE),
    + get_subtype_name(body->TYPE));
    +
    + free_pager_range(&title_range);
    + error = 1;
    + }
    +
    + if (! in_state_feof(state_in)) {
    + struct pager_range *inherit
    + = tagfilter_inherited_pager_range(&params);
    +
    + struct pager_range *title_range =
    + state_add_simple_pager_range(state_out,inherit,PR_MAX_WIDTH,0, + 0);
    +
    + state_printf(state_out,
    + CATGETS(elm_msg_cat, MeSet,
    + MeTagFIncomplteRead,
    + "[ All %s/%s content is not readed. ]\n"),
    + get_major_type_name(body->TYPE),
    + get_subtype_name(body->TYPE));
    +
    + free_pager_range(&title_range);
    + }
    + }
    +
    + if (!error && params.error) {
    + const char * text_charset_MIME_name = get_charset_MIME_name(text_charset);
    + struct pager_range *inherit
    + = tagfilter_inherited_pager_range(&params);
    +
    + struct pager_range *title_range =
    + state_add_simple_pager_range(state_out,inherit,PR_MAX_WIDTH,0,
    + 0);
    +
    + /* \n resets this */
    + set_out_state_line_mode(state_out,pg_BOLD,title_range,1 /* Newline */); +
    + state_printf(state_out,
    + CATGETS(elm_msg_cat, MeSet,
    + MeTagFErrorCharacterFlag,
    + "[ %/%s format have NUL characters or have some bytes, which can't be interpreted as characters of charset %s. ]\n"),
    + get_major_type_name(body->TYPE),
    + get_subtype_name(body->TYPE),
    + text_charset_MIME_name);
    +
    + free_pager_range(&title_range);
    + error = 1;
    + params.error = 0;
    + }
    +
    + if (params.stack) {
    + size_t i;
    +
    + for (i = 0; i < params.stack_len; i++) {
    + if (params.stack[i])
    + tagfilter_free_stack_item(& (params.stack[i]),
    + tagfilter);
    +
    + }
    + free(params.stack);
    + params.stack = NULL;
    + }
    + params.stack_len = 0;
    +
    + tagfilter_token_dest(&current_token);
    +
    + if (counter.unsupported_tags) {
    + struct string ** list =
    + tagfilter_list_tags(counter.unsupported_tags);
    +
    + if (list) {
    +
    + size_t i;
    +
    + struct string * filter_list
    + = new_string(display_charset);
    +
    + for (i = 0; list[i]; i++) {
    +
    + if (i > 0) {
    + if (counter.have_other || list[i+1]) {
    + elm_append_message(&filter_list,
    + CATGETS(elm_msg_cat, MeSet,
    + MeTagFiltListComma,
    + ", "));
    +
    + } else if (1 == i) {
    + elm_append_message(&filter_list,
    + CATGETS(elm_msg_cat, MeSet,
    + MeTagFiltListAnd,
    + " and "));
    + } else {
    + elm_append_message(&filter_list,
    + CATGETS(elm_msg_cat, MeSet,
    + MeTagFiltListComAnd,
    + ", and "));
    + }
    + }
    +
    + elm_append_message(&filter_list,
    + CATGETS(elm_msg_cat, MeSet,
    + MeTagFiltListTag,
    + "<%S>"),
    + list[i]);
    + free_string(& list[i]);
    + }
    +
    + if (counter.have_other) {
    + elm_append_message(&filter_list,
    + CATGETS(elm_msg_cat, MeSet,
    + MeTagFiltListCAndOther,
    + ", and other"));
    + }
    +
    + if (i > 1 || counter.have_other) {
    + elm_append_message(&filter_list,
    + CATGETS(elm_msg_cat, MeSet,
    + MeTagFiltListTagsUnsupported,
    + " tags are unsupported."));
    + } else {
    + elm_append_message(&filter_list,
    + CATGETS(elm_msg_cat, MeSet,
    + MeTagFiltListTagUnsupported,
    + " tag is unsupported."));
    + }
    +
    +
    +
    + if (filter_message_range) {
    +
    + struct string * text =
    + format_string(CATGETS(elm_msg_cat, MeSet,
    + MeTagFUnsupTagsFilterList,
    + "[ %s/%s is unsupported, filtering tags: %S ]\n"),
    + get_major_type_name(body->TYPE),
    + get_subtype_name(body->TYPE),
    + filter_list);
    +
    + state_pager_add_param_text(state_out,filter_message_range,
    + pp_opcode_builtin /* show in builtin + pager */,
    + text);
    +
    + free_string(&text);
    +
    + } else {
    +
    + /* Should not needed */
    +
    + struct pager_range *inherit
    + = tagfilter_inherited_pager_range(&params);
    +
    + struct pager_range *title_range =
    + state_add_simple_pager_range(state_out,inherit,
    + PR_MAX_WIDTH|PR_WORD_WRAP,
    + 0,0);
    +
    + /* \n resets this */
    + set_out_state_line_mode(state_out,pg_BOLD,title_range,1 /* Newline */);
    +
    + state_printf(state_out,
    + CATGETS(elm_msg_cat, MeSet,
    + MeTagFilteredTags,
    + "[ Tags filtered from %s/%s format: %S ]\n"),
    + get_major_type_name(body->TYPE),
    + get_subtype_name(body->TYPE),
    + filter_list);
    +
    + free_pager_range(&title_range);
    + }
    +
    + free_string(&filter_list);
    +
    + free(list);
    + }
    + } else {
    + DPRINT(Debug,10,(&Debug,
    + "tagfilter_decoder: No unsupported tags\n"));
    + }
    +
    + tagfilter_global_dest(&counter);
    +
    + errors2 = print_in_errors(state_in,state_out,decode_opt);
    +
    + if (filter_message_range)
    + free_pager_range(& filter_message_range);
    +
    + DPRINT(Debug,10,(&Debug,
    + "tagfilter_decoder: %d errors on end\n",errors2));
    + }
    +
    +
    + /*
    + * Local Variables:
    + * mode:c
    + * c-basic-offset:4
    + * buffer-file-coding-system: iso-8859-1
    + * End:
    + */

    --
    / Kari Hurtta

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