Allow access to global variables using GLOBAL:: namespace.

Addresses BIT-1758. Patch was contributed by François Pennaneach
<francois.pennaneach@free.fr>.
This commit is contained in:
Johanna Amann 2016-12-07 15:28:34 -08:00
parent ad345d7277
commit 8eddeed78f
3 changed files with 7 additions and 0 deletions

View file

@ -52,7 +52,12 @@ string make_full_var_name(const char* module_name, const char* var_name)
{
if ( ! module_name || streq(module_name, GLOBAL_MODULE_NAME) ||
strstr(var_name, "::") )
{
if ( streq(GLOBAL_MODULE_NAME, extract_module_name(var_name).c_str()) )
return extract_var_name(var_name);
return string(var_name);
}
string full_name = normalized_module_name(module_name);
full_name += "::";

View file

@ -1,4 +1,5 @@
function (PASS)
global variable (PASS)
fully qualified global variable (PASS)
const (PASS)
event (PASS)

View file

@ -27,6 +27,7 @@ event bro_init()
{
test_case( "function", T );
test_case( "global variable", num == 123 );
test_case( "fully qualified global variable", GLOBAL::num == 123 ); # test for BIT-1758 : GLOBAL scope ID discovery bug
test_case( "const", daysperyear == 365 );
event testevent( "foo" );
}