• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

neomutt / neomutt / 20907551456

12 Jan 2026 03:29AM UTC coverage: 45.967% (+0.7%) from 45.271%
20907551456

push

github

flatcap
fuzz: fix build

11648 of 25340 relevant lines covered (45.97%)

489.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/pattern/functions.c
1
/**
2
 * @file
3
 * Pattern functions
4
 *
5
 * @authors
6
 * Copyright (C) 2022-2023 Richard Russon <rich@flatcap.org>
7
 *
8
 * @copyright
9
 * This program is free software: you can redistribute it and/or modify it under
10
 * the terms of the GNU General Public License as published by the Free Software
11
 * Foundation, either version 2 of the License, or (at your option) any later
12
 * version.
13
 *
14
 * This program is distributed in the hope that it will be useful, but WITHOUT
15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17
 * details.
18
 *
19
 * You should have received a copy of the GNU General Public License along with
20
 * this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22

23
/**
24
 * @page pattern_functions Pattern functions
25
 *
26
 * Pattern functions
27
 */
28

29
#include "config.h"
30
#include <stdbool.h>
31
#include <stdio.h>
32
#include "mutt/lib.h"
33
#include "core/lib.h"
34
#include "gui/lib.h"
35
#include "functions.h"
36
#include "menu/lib.h"
37
#include "pattern_data.h"
38

39
/**
40
 * op_generic_select_entry - Select the current entry - Implements ::pattern_function_t - @ingroup pattern_function_api
41
 */
42
static int op_generic_select_entry(struct PatternData *pd, int op)
×
43
{
44
  const int index = menu_get_index(pd->menu);
×
45
  struct PatternEntry *entry = ARRAY_GET(&pd->entries, index);
×
46

47
  if (entry)
×
48
    buf_strcpy(pd->buf, entry->tag);
×
49

50
  pd->done = true;
×
51
  pd->selection = true;
×
52
  return FR_SUCCESS;
×
53
}
54

55
/**
56
 * op_quit - Quit this menu - Implements ::pattern_function_t - @ingroup pattern_function_api
57
 */
58
static int op_quit(struct PatternData *pd, int op)
×
59
{
60
  pd->done = true;
×
61
  pd->selection = false;
×
62
  return FR_SUCCESS;
×
63
}
64

65
// -----------------------------------------------------------------------------
66

67
/**
68
 * PatternFunctions - All the NeoMutt functions that the Pattern supports
69
 */
70
static const struct PatternFunction PatternFunctions[] = {
71
  // clang-format off
72
  { OP_GENERIC_SELECT_ENTRY,   op_generic_select_entry },
73
  { OP_QUIT,                   op_quit },
74
  { OP_EXIT,                   op_quit },
75
  { 0, NULL },
76
  // clang-format on
77
};
78

79
/**
80
 * pattern_function_dispatcher - Perform a Pattern function - Implements ::function_dispatcher_t - @ingroup dispatcher_api
81
 */
82
int pattern_function_dispatcher(struct MuttWindow *win, int op)
×
83
{
84
  // The Dispatcher may be called on any Window in the Dialog
85
  struct MuttWindow *dlg = dialog_find(win);
×
86
  if (!dlg || !dlg->wdata)
×
87
    return FR_ERROR;
88

89
  struct Menu *menu = dlg->wdata;
90
  struct PatternData *pd = menu->mdata;
×
91

92
  int rc = FR_UNKNOWN;
93
  for (size_t i = 0; PatternFunctions[i].op != OP_NULL; i++)
×
94
  {
95
    const struct PatternFunction *fn = &PatternFunctions[i];
96
    if (fn->op == op)
×
97
    {
98
      rc = fn->function(pd, op);
×
99
      break;
×
100
    }
101
  }
102

103
  if (rc == FR_UNKNOWN) // Not our function
×
104
    return rc;
105

106
  const char *result = dispatcher_get_retval_name(rc);
×
107
  mutt_debug(LL_DEBUG1, "Handled %s (%d) -> %s\n", opcodes_get_name(op), op, NONULL(result));
×
108

109
  return rc;
×
110
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc