X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/a57e5d9907d845d6f83d2cfdea55cd52efad793f..446ea5cdf294085b18e25abd39378f9d555dbda8:/uip/mhshowsbr.c diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index 61f04120..a9aa9c0b 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -135,7 +134,7 @@ show_single_message (CT ct, char *form, int concatsw, int textonly, { sigset_t set, oset; - int status; + int status = OK; /* Allow user executable bit so that temporary directories created by * the viewer (e.g., lynx) are going to be accessible */ @@ -329,7 +328,7 @@ show_content_aux (CT ct, int alternate, char *cp, char *cracked, struct format * { int fd; int xstdin = 0, xlist = 0; - char *file, buffer[BUFSIZ]; + char *file = NULL, buffer[BUFSIZ]; if (!ct->c_ceopenfnx) { if (!alternate) @@ -338,7 +337,6 @@ show_content_aux (CT ct, int alternate, char *cp, char *cracked, struct format * return NOTOK; } - file = NULL; if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK) return NOTOK; if (ct->c_showproc && !strcmp (ct->c_showproc, "true")) @@ -355,10 +353,12 @@ show_content_aux (CT ct, int alternate, char *cp, char *cracked, struct format * if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK) return NOTOK; } else { + char *charset = content_charset (ct); admonish (NULL, "unable to convert character set%s%s to %s", ct->c_partno ? " of part " : "", ct->c_partno ? ct->c_partno : "", - content_charset (ct)); + charset); + free (charset); } } @@ -425,7 +425,9 @@ show_content_aux2 (CT ct, int alternate, char *cracked, char *buffer, } while ((cc = read(fd, readbuf, sizeof(readbuf))) > 0) { - fwrite(readbuf, sizeof(char), cc, stdout); + if ((ssize_t) fwrite(readbuf, sizeof(char), cc, stdout) < cc) { + advise ("putline", "fwrite"); + } lastchar = readbuf[cc - 1]; } @@ -566,7 +568,7 @@ show_multi_internal (CT ct, int alternate, int concatsw, int textonly, int alternating, nowalternate, result; struct multipart *m = (struct multipart *) ct->c_ctparams; struct part *part; - int any_part_ok; + int request_matched; CT p; alternating = 0; @@ -577,13 +579,13 @@ show_multi_internal (CT ct, int alternate, int concatsw, int textonly, alternating = 1; } -/* - * alternate -> we are a part inside an multipart/alternative - * alternating -> we are a multipart/alternative - */ + /* + * alternate -> we are a part inside an multipart/alternative + * alternating -> we are a multipart/alternative + */ result = alternate ? NOTOK : OK; - any_part_ok = 0; + request_matched = 0; for (part = m->mp_parts; part; part = part->mp_next) { p = part->mp_part; @@ -591,7 +593,7 @@ show_multi_internal (CT ct, int alternate, int concatsw, int textonly, if (part_ok (p, 1) && type_ok (p, 1)) { int inneresult; - any_part_ok = 1; + request_matched = 1; inneresult = show_switch (p, nowalternate, concatsw, textonly, inlineonly, fmt); @@ -620,7 +622,7 @@ show_multi_internal (CT ct, int alternate, int concatsw, int textonly, } } - if (alternating && !part && any_part_ok) { + if (alternating && !part && request_matched) { if (!alternate) content_error (NULL, ct, "don't know how to display any of the contents"); result = NOTOK; @@ -628,7 +630,9 @@ show_multi_internal (CT ct, int alternate, int concatsw, int textonly, } out: - return result; + /* if no parts matched what was requested, there can't have been + * any display errors, so we report OK. */ + return request_matched ? result : OK; } @@ -643,7 +647,7 @@ show_multi_aux (CT ct, int alternate, char *cp, struct format *fmt) /* xstdin is only used in the call to parse_display_string(): its value is ignored in the function. */ int xstdin = 0, xlist = 0; - char *file, buffer[BUFSIZ]; + char *file = NULL, buffer[BUFSIZ]; struct multipart *m = (struct multipart *) ct->c_ctparams; struct part *part; CT p; @@ -658,7 +662,6 @@ show_multi_aux (CT ct, int alternate, char *cp, struct format *fmt) } if (p->c_storage == NULL) { - file = NULL; if ((*p->c_ceopenfnx) (p, &file) == NOTOK) return NOTOK; @@ -1037,6 +1040,7 @@ convert_charset (CT ct, char *dest_charset, int *message_mods) { if ((conv_desc = iconv_open (dest_charset, src_charset)) == (iconv_t) -1) { advise (NULL, "Can't convert %s to %s", src_charset, dest_charset); + free (src_charset); return NOTOK; } @@ -1177,6 +1181,7 @@ iconv_start: #endif /* ! HAVE_ICONV */ } + free (src_charset); return status; } @@ -1201,9 +1206,8 @@ convert_content_charset (CT ct, char **file) { } else { status = NOTOK; } - - free (charset); } + free (charset); #else /* ! HAVE_ICONV */ NMH_UNUSED (ct); NMH_UNUSED (file);