[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/6] warnings: refactoring
From: |
Theophile Ranquet |
Subject: |
[PATCH 5/6] warnings: refactoring |
Date: |
Mon, 1 Oct 2012 15:01:02 +0000 |
The code here was too confusing, this seems more natural.
* src/complain.c (error_message): Move the indentation check and the category
output to complains. Also, no longer take a 'warnings' argument.
(complains): Factor calls to error_message.
---
src/complain.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/src/complain.c b/src/complain.c
index 91bb528..4d3a085 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -84,7 +84,6 @@ void
error_message (const location *loc, warnings flags, const char *prefix,
const char *message, va_list args)
{
- (void) flags;
unsigned pos = 0;
if (loc)
@@ -95,6 +94,8 @@ error_message (const location *loc, warnings flags, const
char *prefix,
if (indent_ptr)
{
+ if (*indent_ptr)
+ prefix = NULL;
if (!*indent_ptr)
*indent_ptr = pos;
else if (*indent_ptr > pos)
@@ -125,21 +126,16 @@ complains (const location *loc, warnings flags, const
char *message,
va_list args)
{
+ const char* prefix =
+ flags & fatal ? _("fatal error")
+ : flags & (errors_flag | complaint) ? _("error")
+ : _("warning");
+
+ complaint_issued |= flags & (complaint | errors_flag);
+ if (flags & (warnings_flag | silent | fatal | complaint))
+ error_message (loc, flags, prefix, message, args);
if (flags & fatal)
- {
- error_message (loc, fatal, _("fatal error"), message, args);
- exit (EXIT_FAILURE);
- }
- else if (flags & (complaint | warnings_flag | silent))
- {
- const char* prefix =
- flags & (errors_flag | complaint) ? _("error") : _("warning");
- if (flags & (complaint | errors_flag))
- complaint_issued = true;
- error_message (loc, flags,
- indent_ptr && *indent_ptr ? NULL : prefix,
- message, args);
- }
+ exit (EXIT_FAILURE);
}
void
--
1.7.11.4
- [PATCH 0/6] minor code rework and spurious error suffix removed, Theophile Ranquet, 2012/10/01
- [PATCH 1/6] warnings: remove spurious suffixes on context, Theophile Ranquet, 2012/10/01
- [PATCH 4/6] formatting changes, Theophile Ranquet, 2012/10/01
- [PATCH 3/6] warnings: organize variadic complaints call, Theophile Ranquet, 2012/10/01
- [PATCH 5/6] warnings: refactoring,
Theophile Ranquet <=
- [PATCH 6/6] warnings: separate flags_argmatch, Theophile Ranquet, 2012/10/01
- [PATCH 2/6] warnings: fusion of complain and complain_at, Theophile Ranquet, 2012/10/01