diff --git a/source/clientserver/nameValueSubstitution.cpp b/source/clientserver/nameValueSubstitution.cpp index 3c8ea122..79af60af 100644 --- a/source/clientserver/nameValueSubstitution.cpp +++ b/source/clientserver/nameValueSubstitution.cpp @@ -62,7 +62,6 @@ int name_value_substitution(NAMEVALUELIST* nameValueList, char* tpass) int* placeholderIndex = nullptr; int* tpassIndex = nullptr; int tpassPosition = 0; - unsigned short usedCount = 0; if (nameValueList->pairCount > 0) { // Identify and Count Placeholders do { @@ -135,7 +134,6 @@ int name_value_substitution(NAMEVALUELIST* nameValueList, char* tpass) free(nameValueList->nameValue[placeholderIndex[i]].value); nameValueList->nameValue[placeholderIndex[i]].value = newNameValueList.nameValue[tpassIndex[i]].value; newNameValueList.nameValue[tpassIndex[i]].value = nullptr; - usedCount++; UDA_LOG(UDA_LOG_DEBUG, "Placeholder: [%d][%d] %s, Substitution Value [%d] %s\n", i, placeholderIndex[i], nameValueList->nameValue[placeholderIndex[i]].name, diff --git a/source/clientserver/parseOperation.cpp b/source/clientserver/parseOperation.cpp index 37cfae11..c80f6b66 100755 --- a/source/clientserver/parseOperation.cpp +++ b/source/clientserver/parseOperation.cpp @@ -24,8 +24,6 @@ int parseOperation(SUBSET* sub) std::string operation = sub->operation[i]; - boost::starts_with(operation, "["); - boost::trim_left_if(operation, [](char c){ return c == '['; }); boost::trim_right_if(operation, [](char c){ return c == ']'; }); diff --git a/source/server/serverSubsetData.cpp b/source/server/serverSubsetData.cpp index ebe9c1f2..76ec4e48 100755 --- a/source/server/serverSubsetData.cpp +++ b/source/server/serverSubsetData.cpp @@ -82,6 +82,14 @@ int process_subset_operation(int ii, SUBSET subset, DATA_BLOCK* data_block, LOGM { int n_bound = subset.nbound; // the Number of operations in the set + // treat x[0] as a no-op when x is a scalar + if (n_bound == 1 + && (subset.lbindex[0].init && subset.lbindex[0].value == 0) + && (subset.ubindex[0].init && subset.ubindex[0].value == 1) + && data_block->rank == 0) { + return 0; + } + for (int j = 0; j < n_bound; j++) { // Process each operation separately double value = subset.bound[j]; diff --git a/test/plugins/test_testplugin.cpp b/test/plugins/test_testplugin.cpp index ea93bc1b..208d6f06 100755 --- a/test/plugins/test_testplugin.cpp +++ b/test/plugins/test_testplugin.cpp @@ -187,7 +187,7 @@ TEST_CASE( "Run test3 - pass string list as array of strings", "[plugins][TESTPL REQUIRE( data != nullptr ); REQUIRE( !data->isNull() ); - REQUIRE( data->type().name() == typeid(std::string).name() ); + REQUIRE( std::string(data->type().name()) == typeid(std::string).name() ); auto array = dynamic_cast(data); @@ -1818,6 +1818,30 @@ TEST_CASE( "Test array subsetting with argument with square brackets", "[plugins REQUIRE( vec[4] == Approx(4.0) ); } +TEST_CASE( "Test array subsetting - index scalar with [0]", "[plugins][TESTPLUGIN]" ) +{ +#include "setup.inc" + + uda::Client client; + + const uda::Result& result = client.get("TESTPLUGIN::test10()[0]", ""); + + REQUIRE( result.errorCode() == 0 ); + REQUIRE( result.errorMessage().empty() ); + + uda::Data* data = result.data(); + + REQUIRE( data != nullptr ); + REQUIRE( !data->isNull() ); + REQUIRE( data->type().name() == typeid(int).name() ); + + auto* value = dynamic_cast(data); + + REQUIRE( value != nullptr ); + + REQUIRE( value->as() == 7 ); +} + TEST_CASE( "Run call_plugin_test - return the result of calling a plugin", "[plugins][TESTPLUGIN]" ) { #include "setup.inc"