mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Add @deprecated directive
It emits a warning stating that the script is deprecated.
This commit is contained in:
parent
57a505b0e4
commit
a467d0c92d
4 changed files with 46 additions and 0 deletions
|
@ -27,6 +27,16 @@ executed. Directives are evaluated before script execution begins.
|
||||||
|
|
||||||
print "File:", @FILENAME;
|
print "File:", @FILENAME;
|
||||||
|
|
||||||
|
.. bro:keyword:: @deprecated
|
||||||
|
|
||||||
|
Marks the current script as deprecated. This can be placed anywhere in
|
||||||
|
the script, but a good convention is to put it as the first line.
|
||||||
|
You can also supply additional comments.
|
||||||
|
|
||||||
|
Example::
|
||||||
|
|
||||||
|
@deprecated "Use '@load foo' instead"
|
||||||
|
|
||||||
.. bro:keyword:: @load
|
.. bro:keyword:: @load
|
||||||
|
|
||||||
Loads the specified Bro script, specified as the relative pathname
|
Loads the specified Bro script, specified as the relative pathname
|
||||||
|
|
17
src/scan.l
17
src/scan.l
|
@ -315,6 +315,23 @@ when return TOK_WHEN;
|
||||||
return TOK_ATTR_SYNCHRONIZED;
|
return TOK_ATTR_SYNCHRONIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@deprecated.* {
|
||||||
|
auto num_files = file_stack.length();
|
||||||
|
auto comment = skip_whitespace(yytext + 11);
|
||||||
|
|
||||||
|
if ( num_files > 0 )
|
||||||
|
{
|
||||||
|
auto lf = file_stack[num_files - 1];
|
||||||
|
|
||||||
|
if ( lf->name )
|
||||||
|
reporter->Warning("deprecated script loaded from %s:%d %s",
|
||||||
|
lf->name, lf->line, comment);
|
||||||
|
else
|
||||||
|
reporter->Warning("deprecated script loaded from command line arguments %s", comment);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
reporter->Warning("deprecated script loaded %s", comment);
|
||||||
|
}
|
||||||
|
|
||||||
@DEBUG return TOK_DEBUG; // marks input for debugger
|
@DEBUG return TOK_DEBUG; // marks input for debugger
|
||||||
|
|
||||||
|
|
3
testing/btest/Baseline/language.at-deprecated/.stderr
Normal file
3
testing/btest/Baseline/language.at-deprecated/.stderr
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
warning in ./foo.bro, line 1: deprecated script loaded from command line arguments
|
||||||
|
warning in ./bar.bro, line 1: deprecated script loaded from ./foo.bro:2 "Use '@load qux.bro' instead"
|
||||||
|
warning in ./baz.bro, line 1: deprecated script loaded from ./foo.bro:3
|
16
testing/btest/language/at-deprecated.bro
Normal file
16
testing/btest/language/at-deprecated.bro
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# @TEST-EXEC: bro -b foo
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr
|
||||||
|
|
||||||
|
@TEST-START-FILE foo.bro
|
||||||
|
@deprecated
|
||||||
|
@load bar
|
||||||
|
@load baz
|
||||||
|
@TEST-END-FILE
|
||||||
|
|
||||||
|
@TEST-START-FILE bar.bro
|
||||||
|
@deprecated "Use '@load qux.bro' instead"
|
||||||
|
@TEST-END-FILE
|
||||||
|
|
||||||
|
@TEST-START-FILE baz.bro
|
||||||
|
@deprecated
|
||||||
|
@TEST-END-FILE
|
Loading…
Add table
Add a link
Reference in a new issue