From f229ce08ca3956fd7ecbe2b9a83067eeb55d0afb Mon Sep 17 00:00:00 2001 From: schnetter Date: Mon, 26 Sep 2005 03:16:42 +0000 Subject: Print run time warnings while setting parameters with CCTK_WARN instead of with fprintf (stderr, ...). Correct critical error in looking at the values of cctk_full_warnings, highlight_warning_messages, and cctk_strong_param_check. Handle the empty regular expression specially in CCTK_RegexMatch, since regcomp may treat it as illegal expression. In Cactus, an empty regular expression matches everything. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4150 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/util/Misc.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'src/util') diff --git a/src/util/Misc.c b/src/util/Misc.c index 9d92a447..f4418799 100644 --- a/src/util/Misc.c +++ b/src/util/Misc.c @@ -1151,23 +1151,32 @@ int CCTK_RegexMatch(const char *string, int status; regex_t re; - if (regcomp(&re, pattern, REG_EXTENDED) == 0) + /* BSD says: an empty string is not a legal regular expression. + Handle this case specially. */ + if (strcmp(pattern, "") == 0) { - status = regexec(&re, string, (size_t)nmatch, pmatch, 0); - regfree(&re); - if (status != 0) + retval = 1; /* report success */ + } + else + { + if (regcomp(&re, pattern, REG_EXTENDED) == 0) { - retval = 0; /* report error */ + status = regexec(&re, string, (size_t)nmatch, pmatch, 0); + regfree(&re); + if (status != 0) + { + retval = 0; /* report error */ + } + else + { + retval = 1; + } } else { - retval = 1; + retval = 0; } } - else - { - retval = 0; - } return retval; } -- cgit v1.2.3