From 1307aae01a1f52f398a1abb93dbaa32153b5785d Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Fri, 7 Jan 2005 19:02:47 +0000 Subject: [PATCH] minor utility tweaks git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2240 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 7 +++++++ src/nano.h | 1 + src/utils.c | 6 ++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f54e2538..f440a72d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -141,6 +141,13 @@ CVS code - - Try to automatically detect whether UTF-8 support is needed by setting the NO_UTF8 flag if setlocale() returns a string that doesn't contain "UTF-8". (DLR) +- utils.c: + regexec_safe() + - Remove redundant regexec #define, and move the regexec #undef + to nano.h. (DLR) + is_blank_char() + - Rewrite to use ctype functions instead of checking directly + for spaces and tabs. (DLR) - winio.c: titlebar() - Rename some variables for consistency, make space an int diff --git a/src/nano.h b/src/nano.h index ca9d37ba..95ff80ed 100644 --- a/src/nano.h +++ b/src/nano.h @@ -47,6 +47,7 @@ #define charcpy(dest, src, n) memcpy(dest, src, (n) * sizeof(char)) #ifdef BROKEN_REGEXEC +#undef regexec #define regexec(preg, string, nmatch, pmatch, eflags) regexec_safe(preg, string, nmatch, pmatch, eflags) #endif diff --git a/src/utils.c b/src/utils.c index 8fd71186..4b3c918b 100644 --- a/src/utils.c +++ b/src/utils.c @@ -39,7 +39,6 @@ #ifdef HAVE_REGEX_H #ifdef BROKEN_REGEXEC -#undef regexec int regexec_safe(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags) { @@ -47,8 +46,7 @@ int regexec_safe(const regex_t *preg, const char *string, size_t nmatch, 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 /* BROKEN_REGEXEC */ +#endif int regexp_bol_or_eol(const regex_t *preg, const char *string) { @@ -62,7 +60,7 @@ int regexp_bol_or_eol(const regex_t *preg, const char *string) /* This function is equivalent to isblank(). */ int is_blank_char(int c) { - return (c == '\t' || c == ' '); + return isspace(c) && (!is_cntrl_char(c) || c == '\t'); } #endif