summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0fb3b99)
previously, "mhshow -part 1 -part 1.3" would show 1.1 but not 1.3.
* prototypes
*/
int part_ok (CT);
* prototypes
*/
int part_ok (CT);
int type_ok (CT, int);
void content_error (char *, CT, char *, ...);
void flush_errors (void);
int type_ok (CT, int);
void content_error (char *, CT, char *, ...);
void flush_errors (void);
+int
+part_exact(CT ct)
+{
+ char **ap;
+
+ if (!ct->c_partno)
+ return 0;
+
+ for (ap = parts; *ap; ap++) {
+ if (!strcmp (*ap, ct->c_partno)) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
int
type_ok (CT ct, int sP)
int
type_ok (CT ct, int sP)
/* mhmisc.c */
int part_ok (CT);
/* mhmisc.c */
int part_ok (CT);
int type_ok (CT, int);
void content_error (char *, CT, char *, ...);
void flush_errors (void);
int type_ok (CT, int);
void content_error (char *, CT, char *, ...);
void flush_errors (void);
struct part *part;
int request_matched;
int display_success;
struct part *part;
int request_matched;
int display_success;
* alternating -> we are a multipart/alternative
*/
* alternating -> we are a multipart/alternative
*/
- result = alternate ? NOTOK : OK;
request_matched = 0;
display_success = 0;
request_matched = 0;
display_success = 0;
for (part = m->mp_parts; part; part = part->mp_next) {
p = part->mp_part;
for (part = m->mp_parts; part; part = part->mp_next) {
p = part->mp_part;
- if (part_ok (p) && type_ok (p, 1)) {
- int inneresult;
+ /* while looking for the right displayable alternative, we
+ * use a looser search criterion than we do after finding it.
+ * specifically, while still looking, part_ok() will match
+ * "parent" parts (e.g. "-part 2" where 2 is a high-level
+ * multipart). after finding it, we use part_exact() to only
+ * choose a part that was requested explicitly.
+ */
+ if ((part_exact(p) && type_ok(p, 1)) ||
+ (!mult_alt_done && part_ok (p) && type_ok (p, 1))) {
inneresult = show_switch (p, nowalternate, concatsw, textonly,
inlineonly, fmt);
inneresult = show_switch (p, nowalternate, concatsw, textonly,
inlineonly, fmt);
case OK: /* display successful */
request_matched = 1;
display_success = 1;
case OK: /* display successful */
request_matched = 1;
display_success = 1;
+ result = OK;
+
+ /* if we got success on a sub-part of
+ * multipart/alternative, we're done, unless
+ * there's a chance an explicit part should be
+ * matched later in the alternatives. */
- break;
- }
- if (alternate) {
+ mult_alt_done = 1;
+ } else if (alternate) {
alternate = nowalternate = 0;
alternate = nowalternate = 0;
- if (result == NOTOK)
- result = inneresult;
}
/* we're supposed to be displaying at least something from a
}
/* we're supposed to be displaying at least something from a
- * multipart. if we've had parts to consider, and we've had no
- * success, then we should complain. we shouldn't complain if
- * none of the parts matched any -part option or -type option.
+ * multipart/alternative. if we've had parts to consider, and
+ * we've had no success, then we should complain. we shouldn't
+ * complain if none of the parts matched any -part or -type option.
*/
if (alternating && request_matched && !display_success) {
*/
if (alternating && request_matched && !display_success) {
+ /* if we're ourselves an alternate. don't complain yet. */
if (!alternate)
content_error (NULL, ct, "don't know how to display any of the contents");
result = NOTOK;
if (!alternate)
content_error (NULL, ct, "don't know how to display any of the contents");
result = NOTOK;