- Fix nano crashing when searching/replacing an invalid
regex (try "^*"). Changed regexp_init() to return
1 or 0 based on regcomp()'s return value and search_init
- to exit with an error message (sorry Jordi!)
+ to exit with an error message (sorry Jordi!). Added
+ another check when using last_search instead of answer.
- Move regcomp into rcfile.c rather than each display refresh
of winio.c. New function rcfile.c:nregcomp().
This fixes much of nano's resource hogging behavior
int i = 0;
char *buf;
static char *backupstring = NULL;
+#ifdef HAVE_REGEX_H
+ const char *regex_error = _("Invalid regex \"%s\"");
+#endif /* HAVE_REGEX_H */
search_init_globals();
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP))
/* If answer is "", use last_search! */
- regexp_init(last_search);
+ if (regexp_init(last_search) == 0) {
+ statusbar(regex_error, last_search);
+ reset_cursor();
+ free(backupstring);
+ backupstring = NULL;
+ return -3;
+ }
#endif
break;
case 0: /* They entered something new */
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP))
if (regexp_init(answer) == 0) {
- statusbar(_("Invalid regex!"));
+ statusbar(regex_error, answer);
reset_cursor();
free(backupstring);
backupstring = NULL;