[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/3] diagnostics: factor the deprecated directive message
From: |
Akim Demaille |
Subject: |
[PATCH 1/3] diagnostics: factor the deprecated directive message |
Date: |
Fri, 21 Dec 2012 16:13:46 +0100 |
* src/complain.h, src/complain.c (deprecated_directive): New.
* src/muscle-tab.c: Use it.
---
src/complain.c | 15 +++++++++++++++
src/complain.h | 4 ++++
src/scan-gram.l | 4 +---
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/complain.c b/src/complain.c
index 984b136..30d01bb 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -28,6 +28,7 @@
#include "complain.h"
#include "files.h"
#include "getargs.h"
+#include "quote.h"
warnings warnings_flag =
Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
@@ -188,4 +189,18 @@ complain_args (location const *loc, warnings w, unsigned
*indent,
complain (loc, fatal, "too many arguments for complains");
break;
}
+
+}
+
+void
+deprecated_directive (location const *loc, char const *old, char const *upd)
+{
+ if (feature_flag & feature_caret)
+ complain (loc, Wdeprecated,
+ _("deprecated directive, use %s"),
+ quote_n (1, upd));
+ else
+ complain (loc, Wdeprecated,
+ _("deprecated directive: %s, use %s"),
+ quote (old), quote_n (1, upd));
}
diff --git a/src/complain.h b/src/complain.h
index d715bb6..92d77b3 100644
--- a/src/complain.h
+++ b/src/complain.h
@@ -72,6 +72,10 @@ void complain_indent (location const *loc, warnings flags,
unsigned *indent,
__attribute__ ((__format__ (__printf__, 4, 5)));
+/** Report an obsolete syntax, suggest the updated one. */
+void deprecated_directive (location const *loc,
+ char const *obsolete, char const *updated);
+
/** Warnings treated as errors shouldn't stop the execution as regular errors
should (because due to their nature, it is safe to go on). Thus, there are
three possible execution statuses. */
diff --git a/src/scan-gram.l b/src/scan-gram.l
index d02b26b..4b7591b 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -77,9 +77,7 @@ static size_t no_cr_read (FILE *, char *, size_t);
#define DEPRECATED(Msg) \
do { \
size_t i; \
- complain (loc, Wdeprecated, \
- _("deprecated directive: %s, use %s"), \
- quote (yytext), quote_n (1, Msg)); \
+ deprecated_directive (loc, yytext, Msg); \
scanner_cursor.column -= mbsnwidth (Msg, strlen (Msg), 0); \
for (i = strlen (Msg); i != 0; --i) \
unput (Msg[i - 1]); \
--
1.8.0.2