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/main/WarnLevel.c | |
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/main/WarnLevel.c')
-rw-r--r-- | src/main/WarnLevel.c | 85 |
1 files changed, 58 insertions, 27 deletions
diff --git a/src/main/WarnLevel.c b/src/main/WarnLevel.c index f5baeab7..c3db295e 100644 --- a/src/main/WarnLevel.c +++ b/src/main/WarnLevel.c @@ -389,7 +389,8 @@ int CCTK_VWarn (int level, const char *format, ...) { - const CCTK_INT *cctk_full_warnings, *highlight_warning_messages; + const CCTK_INT *cctk_full_warnings_ptr, *highlight_warning_messages_ptr; + CCTK_INT cctk_full_warnings, highlight_warning_messages; int param_type; int myproc; va_list ap, aq; @@ -399,10 +400,17 @@ int CCTK_VWarn (int level, myproc = CCTK_MyProc(NULL); - cctk_full_warnings = + cctk_full_warnings_ptr = CCTK_ParameterGet ("cctk_full_warnings", "Cactus", ¶m_type); - highlight_warning_messages = + // Default to yes + cctk_full_warnings = + cctk_full_warnings_ptr && *cctk_full_warnings_ptr; + + highlight_warning_messages_ptr = CCTK_ParameterGet ("highlight_warning_messages", "Cactus", ¶m_type); + // Default to no + highlight_warning_messages = + ! highlight_warning_messages_ptr || *highlight_warning_messages_ptr; va_start (ap, format); #ifdef HAVE_VA_COPY @@ -415,7 +423,7 @@ int CCTK_VWarn (int level, if (level <= warning_level) { - if (*highlight_warning_messages) + if (highlight_warning_messages) { fprintf (stderr, BOLD_ON); } @@ -433,7 +441,7 @@ int CCTK_VWarn (int level, level, myproc, thorn); } - if (*highlight_warning_messages) + if (highlight_warning_messages) { fprintf (stderr, BOLD_OFF); } @@ -448,7 +456,7 @@ int CCTK_VWarn (int level, if (level <= logging_level || (myproc && level <= warning_level)) { - if (*highlight_warning_messages) + if (highlight_warning_messages) { fprintf (stdout, BOLD_ON); } @@ -466,7 +474,7 @@ int CCTK_VWarn (int level, level, myproc, thorn); } - if (*highlight_warning_messages) + if (highlight_warning_messages) { fprintf (stdout, BOLD_OFF); } @@ -537,22 +545,31 @@ int CCTK_ParameterLevel (void) @@*/ int CCTK_ParamWarn (const char *thorn, const char *message) { - const CCTK_INT *cctk_strong_param_check, *highlight_warning_messages; + const CCTK_INT *cctk_strong_param_check_ptr, *highlight_warning_messages_ptr; + CCTK_INT cctk_strong_param_check, highlight_warning_messages; int param_type; - cctk_strong_param_check = CCTK_ParameterGet ("cctk_strong_param_check", - "Cactus", ¶m_type); - highlight_warning_messages = CCTK_ParameterGet ("highlight_warning_messages", - "Cactus", ¶m_type); - if (*highlight_warning_messages) + cctk_strong_param_check_ptr = + CCTK_ParameterGet ("cctk_strong_param_check", "Cactus", ¶m_type); + // Default to yes + cctk_strong_param_check = + cctk_strong_param_check_ptr && *cctk_strong_param_check_ptr; + + highlight_warning_messages_ptr = + CCTK_ParameterGet ("highlight_warning_messages", "Cactus", ¶m_type); + // Default to no + highlight_warning_messages = + ! highlight_warning_messages_ptr || *highlight_warning_messages_ptr; + + if (highlight_warning_messages) { fprintf (stderr, BOLD_ON "PARAM %s (%s):" BOLD_OFF " %s\n", - *cctk_strong_param_check ? "ERROR" : "WARNING", thorn, message); + cctk_strong_param_check ? "ERROR" : "WARNING", thorn, message); } else { fprintf (stderr, "PARAM %s (%s): %s\n", - *cctk_strong_param_check ? "ERROR" : "WARNING", thorn, message); + cctk_strong_param_check ? "ERROR" : "WARNING", thorn, message); } param_errors++; @@ -605,22 +622,31 @@ int CCTK_VParamWarn (const char *thorn, ...) { va_list ap; - const CCTK_INT *cctk_strong_param_check, *highlight_warning_messages; + const CCTK_INT *cctk_strong_param_check_ptr, *highlight_warning_messages_ptr; + CCTK_INT cctk_strong_param_check, highlight_warning_messages; int param_type; - cctk_strong_param_check = CCTK_ParameterGet ("cctk_strong_param_check", - "Cactus", ¶m_type); - highlight_warning_messages = CCTK_ParameterGet ("highlight_warning_messages", - "Cactus", ¶m_type); - if (*highlight_warning_messages) + cctk_strong_param_check_ptr = + CCTK_ParameterGet ("cctk_strong_param_check", "Cactus", ¶m_type); + // Default to yes + cctk_strong_param_check = + cctk_strong_param_check_ptr && *cctk_strong_param_check_ptr; + + highlight_warning_messages_ptr = + CCTK_ParameterGet ("highlight_warning_messages", "Cactus", ¶m_type); + // Default to no + highlight_warning_messages = + ! highlight_warning_messages_ptr || *highlight_warning_messages_ptr; + + if (highlight_warning_messages) { fprintf (stderr, BOLD_ON "PARAM %s (%s)" BOLD_OFF ": ", - *cctk_strong_param_check ? "ERROR" : "WARNING", thorn); + cctk_strong_param_check ? "ERROR" : "WARNING", thorn); } else { fprintf (stderr, "PARAM %s (%s): ", - *cctk_strong_param_check ? "ERROR" : "WARNING", thorn); + cctk_strong_param_check ? "ERROR" : "WARNING", thorn); } va_start (ap, format); @@ -877,14 +903,19 @@ int CCTKi_SetErrorLevel (int level) void CCTKi_FinaliseParamWarn (void) { int param_type; - const CCTK_INT *cctk_strong_param_check; + const CCTK_INT *cctk_strong_param_check_ptr; + CCTK_INT cctk_strong_param_check; if (param_errors) { - cctk_strong_param_check = CCTK_ParameterGet ("cctk_strong_param_check", - "Cactus", ¶m_type); - if (*cctk_strong_param_check) + cctk_strong_param_check_ptr = + CCTK_ParameterGet ("cctk_strong_param_check", "Cactus", ¶m_type); + // Default to yes + cctk_strong_param_check = + cctk_strong_param_check_ptr && *cctk_strong_param_check_ptr; + + if (cctk_strong_param_check) { fprintf (stderr, "\nFailed parameter check (%d errors)\n\n", param_errors); CCTK_Abort (NULL, 99); |