From 23e64c1409eb3cb64aec02181eda8ffcf13e4e0b Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 26 Aug 2016 13:39:54 +1200 Subject: [PATCH] Add caret for reentering existing survey warning --- src/commands.c | 19 ++++++++++++++----- tests/doubleinc.out | 3 ++- tests/reenterlots.out | 15 ++++++++++----- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/commands.c b/src/commands.c index b35195dd..b65f58be 100644 --- a/src/commands.c +++ b/src/commands.c @@ -563,16 +563,19 @@ cmd_set(void) } static void -check_reentry(prefix *survey) +check_reentry(prefix *survey, const filepos* fpos_ptr) { /* Don't try to check "*prefix \" or "*begin \" */ if (!survey->up) return; if (TSTBIT(survey->sflags, SFLAGS_PREFIX_ENTERED)) { static int reenter_depr_count = 0; + filepos fp_tmp; if (reenter_depr_count >= 5) return; + get_pos(&fp_tmp); + set_pos(fpos_ptr); /* TRANSLATORS: The first of two warnings given when a survey which has * already been completed is reentered. This example file crawl.svx: * @@ -590,7 +593,8 @@ check_reentry(prefix *survey) * * If you're unsure what "deprecated" means, see: * http://en.wikipedia.org/wiki/Deprecation */ - compile_diagnostic(DIAG_WARN, /*Reentering an existing survey is deprecated*/29); + compile_diagnostic(DIAG_WARN|DIAG_TOKEN, /*Reentering an existing survey is deprecated*/29); + set_pos(&fp_tmp); /* TRANSLATORS: The second of two warnings given when a survey which has * already been completed is reentered. This example file crawl.svx: * @@ -630,6 +634,7 @@ cmd_prefix(void) { static int prefix_depr_count = 0; prefix *survey; + filepos fp; /* Issue warning first, so "*prefix \" warns first that *prefix is * deprecated and then that ROOT is... */ @@ -640,9 +645,10 @@ cmd_prefix(void) if (++prefix_depr_count == 5) compile_diagnostic(DIAG_WARN, /*Further uses of this deprecated feature will not be reported*/95); } + get_pos(&fp); survey = read_prefix(PFX_SURVEY|PFX_ALLOW_ROOT); pcs->Prefix = survey; - check_reentry(survey); + check_reentry(survey, &fp); } #endif @@ -682,10 +688,13 @@ cmd_begin(void) skipblanks(); pcs->begin_survey = NULL; if (!isEol(ch) && !isComm(ch)) { - prefix *survey = read_prefix(PFX_SURVEY|PFX_ALLOW_ROOT|PFX_WARN_SEPARATOR); + filepos fp; + prefix *survey; + get_pos(&fp); + survey = read_prefix(PFX_SURVEY|PFX_ALLOW_ROOT|PFX_WARN_SEPARATOR); pcs->begin_survey = survey; pcs->Prefix = survey; - check_reentry(survey); + check_reentry(survey, &fp); f_export_ok = fTrue; } } diff --git a/tests/doubleinc.out b/tests/doubleinc.out index ecea9505..d0cf7ef6 100644 --- a/tests/doubleinc.out +++ b/tests/doubleinc.out @@ -1,6 +1,7 @@ In file included from ./doubleinc.svx:3: -./cmd_dummy.svx:2: warning: Reentering an existing survey is deprecated +./cmd_dummy.svx:2:8: warning: Reentering an existing survey is deprecated *begin it_all + ^~~~~~ ./cmd_dummy.svx:2: warning: Originally entered here ./cmd_dummy.svx:12: warning: Station already fixed at the same coordinates *fix no_warnings_please reference 0 0 0 diff --git a/tests/reenterlots.out b/tests/reenterlots.out index db0a00c4..72a25d32 100644 --- a/tests/reenterlots.out +++ b/tests/reenterlots.out @@ -1,17 +1,22 @@ -./reenterlots.svx:7: warning: Reentering an existing survey is deprecated +./reenterlots.svx:7:8: warning: Reentering an existing survey is deprecated *begin svy + ^~~ ./reenterlots.svx:3: warning: Originally entered here -./reenterlots.svx:10: warning: Reentering an existing survey is deprecated +./reenterlots.svx:10:8: warning: Reentering an existing survey is deprecated *begin svy + ^~~ ./reenterlots.svx:3: warning: Originally entered here -./reenterlots.svx:13: warning: Reentering an existing survey is deprecated +./reenterlots.svx:13:8: warning: Reentering an existing survey is deprecated *begin svy + ^~~ ./reenterlots.svx:3: warning: Originally entered here -./reenterlots.svx:16: warning: Reentering an existing survey is deprecated +./reenterlots.svx:16:8: warning: Reentering an existing survey is deprecated *begin svy + ^~~ ./reenterlots.svx:3: warning: Originally entered here -./reenterlots.svx:19: warning: Reentering an existing survey is deprecated +./reenterlots.svx:19:8: warning: Reentering an existing survey is deprecated *begin svy + ^~~ ./reenterlots.svx:3: warning: Originally entered here ./reenterlots.svx:19: warning: Further uses of this deprecated feature will not be reported *begin svy -- 2.11.4.GIT