/* not reached */
}
-int mutt_change_flag (HEADER * h, int bf)
+int mutt_change_flag(HEADER * h, int bf)
{
- int i, flag;
- event_t event;
-
- mvprintw (LINES - 1, 0, "%s? (D/N/O/r/*/!): ",
- bf ? _("Set flag") : _("Clear flag"));
- clrtoeol ();
+ static char const actions[] = {
+ ['d'] = M_DELETE, ['D'] = M_DELETE,
+ ['n'] = M_NEW, ['N'] = M_NEW,
+ ['o'] = M_OLD, ['O'] = M_OLD,
+ ['r'] = M_REPLIED, ['R'] = M_REPLIED,
+ ['*'] = M_TAG,
+ ['!'] = M_FLAG,
+ };
+
+ int c;
+
+ mvprintw(LINES - 1, 0, "%s? (D/N/O/r/*/!): ",
+ bf ? _("Set flag") : _("Clear flag"));
+ clrtoeol();
+
+ c = mutt_getch().ch;
+ if (c == -1) {
+ CLEARLINE (LINES - 1);
+ return (-1);
+ }
- event = mutt_getch ();
- i = event.ch;
- if (i == -1) {
CLEARLINE (LINES - 1);
- return (-1);
- }
-
- CLEARLINE (LINES - 1);
-
- switch (i) {
- case 'd':
- case 'D':
- flag = M_DELETE;
- break;
-
- case 'N':
- case 'n':
- flag = M_NEW;
- break;
-
- case 'o':
- case 'O':
- if (h)
- mutt_set_flag (Context, h, M_READ, !bf);
- else
- mutt_tag_set_flag (M_READ, !bf);
- flag = M_OLD;
- break;
- case 'r':
- case 'R':
- flag = M_REPLIED;
- break;
-
- case '*':
- flag = M_TAG;
- break;
-
- case '!':
- flag = M_FLAG;
- break;
+ if (c < 0 || c > countof(actions) || !actions[c]) {
+ BEEP();
+ return -1;
+ }
- default:
- BEEP ();
- return (-1);
- }
+ if (actions[c] == M_OLD) {
+ if (h) {
+ mutt_set_flag(Context, h, M_READ, !bf);
+ } else {
+ mutt_tag_set_flag(M_READ, !bf);
+ }
+ }
- if (h)
- mutt_set_flag (Context, h, flag, bf);
- else
- mutt_tag_set_flag (flag, bf);
+ if (h) {
+ mutt_set_flag(Context, h, actions[c], bf);
+ } else {
+ mutt_tag_set_flag(actions[c], bf);
+ }
- return 0;
+ return 0;
}