From 1dc927a7d4ff75a134da32b3ed2a7c4e181f06a4 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 15 Dec 2012 21:54:17 +0100 Subject: [PATCH] diagnostics: factor the deprecated directive message * 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 984b1361..30d01bb2 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 b0a1a293..2222aca2 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 d02b26bb..4b7591bb 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]); \ -- 2.45.2