diff -u nano/nano.h nano-regexec/nano.h --- nano/nano.h Thu Feb 20 14:38:13 2003 +++ nano-regexec/nano.h Thu Feb 20 14:34:08 2003 @@ -35,6 +35,9 @@ /* Define charalloc as a macro rather than duplicating code */ #define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char)) #define charealloc(ptr, howmuch) (char *)nrealloc(ptr, (howmuch) * sizeof(char)) +#ifdef BROKEN_REGEXEC +#define regexec(preg, string, nmatch, pmatch, eflags) regexec_safe(preg, string, nmatch, pmatch, eflags) +#endif #ifndef NANO_SMALL /* For the backup file copy ... */ diff -u nano/proto.h nano-regexec/proto.h --- nano/proto.h Thu Feb 20 14:38:13 2003 +++ nano-regexec/proto.h Thu Feb 20 14:34:11 2003 @@ -391,6 +391,10 @@ #endif /* Public functions in utils.c */ +#ifdef BROKEN_REGEXEC +int regexec_safe(const regex_t *preg, const char *string, size_t nmatch, + regmatch_t pmatch[], int eflags); +#endif int is_cntrl_char(int c); int num_of_digits(int n); void align(char **strp); diff -u nano/utils.c nano-regexec/utils.c --- nano/utils.c Thu Feb 20 14:38:13 2003 +++ nano-regexec/utils.c Thu Feb 20 14:34:06 2003 @@ -30,6 +30,18 @@ #include "proto.h" #include "nano.h" +#ifdef BROKEN_REGEXEC +#undef regexec +int regexec_safe(const regex_t *preg, const char *string, size_t nmatch, + regmatch_t pmatch[], int eflags) +{ + if (string != NULL && *string != '\0') + return regexec(preg, string, nmatch, pmatch, eflags); + return REG_NOMATCH; +} +#define regexec(preg, string, nmatch, pmatch, eflags) regexec_safe(preg, string, nmatch, pmatch, eflags) +#endif + int is_cntrl_char(int c) { return (-128 <= c && c < -96) || (0 <= c && c < 32) ||