diff options
author | schnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2005-09-26 03:16:42 +0000 |
---|---|---|
committer | schnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2005-09-26 03:16:42 +0000 |
commit | f229ce08ca3956fd7ecbe2b9a83067eeb55d0afb (patch) | |
tree | 15ee1e1d2c05708018c35b9f52107c6a7950cfd8 /src/util | |
parent | 6088cd914c9e75fa2a2e88a463528594c50d710d (diff) |
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
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/Misc.c | 29 |
1 files changed, 19 insertions, 10 deletions
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; } |