nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] problem with mhshow after mhfixmsg

2014-11-20 14:48:22
i think the fix might be a simple extension of a previous fix i made
(c9794733) in show_multi_internal().

the crux is that no one should be reporting NOTOK for failure to
display parts that weren't actually requested.  failure should be
reserved for parts that we really attempted to display.  (i think the
default result value of NOTOK gets in the way of this, by making it
too easy to return NOTOK.  changing that default might be a path to
simplification that i haven't looked at.)

your workaround ('mhshow -part 1.1.2 -part 1.3') works because
it prevents the inner level from reporting failure, since something
has been displayed successfully.

if my thinking is correct (and it could certainly use review!), here's
a possible patch.  the only substantive change is the last stanza. 
(i've also renamed the "any_part_ok" variable to better match its
semantics.  it confused me, even though i named it in the first
place).

with this change, my original failure case now works, and "make check"
passes, but i don't know that that says enough.

paul


diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c
index b76a588..ee7dc75 100644
--- a/uip/mhshowsbr.c
+++ b/uip/mhshowsbr.c
@@ -569,7 +569,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;
@@ -586,7 +586,7 @@ show_multi_internal (CT ct, int alternate, int concatsw, 
int textonly,
  */
 
     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;
@@ -594,7 +594,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);
@@ -623,7 +623,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;
@@ -631,7 +631,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;
 }
 
 

=----------------------
 paul fox, pgf(_at_)foxharp(_dot_)boston(_dot_)ma(_dot_)us (arlington, ma, 
where it's 40.3 degrees)

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>