char* searchBuf = menu->menu >= 0 && menu->menu < MENU_MAX ?
SearchBuffers[menu->menu] : NULL;
- if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE)
+ if (!(searchBuf && *searchBuf) ||
+ (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE))
{
- strfcpy (buf, searchBuf ? searchBuf : "", sizeof (buf));
- if (mutt_get_field ((op == OP_SEARCH) ? _("Search for: ") :
- _("Reverse search for: "),
- buf, sizeof (buf), M_CLEAR) != 0 || !buf[0])
+ strfcpy (buf, searchBuf && *searchBuf ? searchBuf : "", sizeof (buf));
+ if (mutt_get_field ((op == OP_SEARCH || op == OP_SEARCH_NEXT)
+ ? _("Search for: ") : _("Reverse search for: "),
+ buf, sizeof (buf), M_CLEAR) != 0 || !buf[0])
return (-1);
if (menu->menu >= 0 && menu->menu < MENU_MAX)
{
mutt_str_replace (&SearchBuffers[menu->menu], buf);
searchBuf = SearchBuffers[menu->menu];
}
- menu->searchDir = (op == OP_SEARCH) ? M_SEARCH_DOWN : M_SEARCH_UP;
- }
- else
- {
- if (!searchBuf || !*searchBuf)
- {
- mutt_error _("No search pattern.");
- return (-1);
- }
+ menu->searchDir = (op == OP_SEARCH || op == OP_SEARCH_NEXT) ?
+ M_SEARCH_DOWN : M_SEARCH_UP;
}
searchDir = (menu->searchDir == M_SEARCH_UP) ? -1 : 1;
int
mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
{
- static char searchbuf[STRING];
+ static char searchbuf[STRING] = "";
char buffer[LONG_STRING];
char helpstr[SHORT_STRING*2];
char tmphelp[SHORT_STRING*2];
progress_t progress;
const char* msg = NULL;
- if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE)
+ if (!(LastSearch && *LastSearch) ||
+ (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE))
{
- strfcpy (buf, LastSearch, sizeof (buf));
- if (mutt_get_field ((op == OP_SEARCH) ? _("Search for: ") :
- _("Reverse search for: "), buf, sizeof (buf),
+ strfcpy (buf, LastSearch && *LastSearch ? LastSearch : "", sizeof (buf));
+ if (mutt_get_field ((op == OP_SEARCH || op == OP_SEARCH_NEXT) ?
+ _("Search for: ") : _("Reverse search for: "),
+ buf, sizeof (buf),
M_CLEAR | M_PATTERN) != 0 || !buf[0])
return (-1);
- if (op == OP_SEARCH)
+ if (op == OP_SEARCH || op == OP_SEARCH_NEXT)
unset_option (OPTSEARCHREVERSE);
else
set_option (OPTSEARCHREVERSE);
mutt_check_simple (temp, sizeof (temp), NONULL (SimpleSearch));
if (!SearchPattern || mutt_strcmp (temp, LastSearchExpn))
- {
+ {
set_option (OPTSEARCHINVALID);
strfcpy (LastSearch, buf, sizeof (LastSearch));
mutt_message _("Compiling search pattern...");
err.data = error;
err.dsize = sizeof (error);
if ((SearchPattern = mutt_pattern_comp (temp, M_FULL_MSG, &err)) == NULL)
- {
+ {
mutt_error ("%s", error);
return (-1);
}
mutt_clear_error ();
}
}
- else if (!SearchPattern)
- {
- mutt_error _("No search pattern.");
- return (-1);
- }
if (option (OPTSEARCHINVALID))
{