From: Eduardo Ramos Testillano Date: Mon, 6 Apr 2015 03:39:59 +0000 (+0200) Subject: Non strict validation. Activate git add in pre-commit hook after astyle. X-Git-Tag: REFACTORING_TESTING_LIBRARY~184 X-Git-Url: https://git.teslayout.com/public/public/public/?a=commitdiff_plain;h=3fd99ed14e449e1e221d689db34c3b65b533a882;p=anna.git Non strict validation. Activate git add in pre-commit hook after astyle. --- diff --git a/example/diameter/pcapDecoder/main.cpp b/example/diameter/pcapDecoder/main.cpp index 30d9cba..80278e4 100644 --- a/example/diameter/pcapDecoder/main.cpp +++ b/example/diameter/pcapDecoder/main.cpp @@ -334,9 +334,10 @@ int main(int argc, char **argv) { //check command line arguments if(argc < 3) { std::string msg = "Usage: "; msg += exec; - msg += " [--ignore-flags: non-strict validation]\n\n"; - msg += " dictionaries: list of comma-separated xml dictionaries (one or more can be provided).\n"; - msg += " Input file: normally a pcap file, but hexadecimal content (colons allowed) can also be decoded (use '.hex' extension)."; + msg += " [--non-strict-validation]\n\n"; + msg += " dictionaries: list of comma-separated xml dictionaries (one or more can be provided).\n"; + msg += " Input file: normally a pcap file, but hexadecimal content (colons allowed) can also be decoded (use '.hex' extension).\n"; + msg += " --non-strict-validation: no validation is performed, and wrong flags regarding dictionary are ignored in xml representation."; _exit(msg); } @@ -346,11 +347,10 @@ int main(int argc, char **argv) { bool isHex = (inputFile.substr(inputFile.find_last_of(".") + 1) == "hex"); std::string outputFile = inputFile; // extension will be added later std::string optional = argv[3] ? argv[3] : ""; - bool ignoreFlags = ((argc == 4) && (optional == "--ignore-flags")); + bool non_strict_validation = ((argc == 4) && (optional == "--non-strict-validation")); std::cout << "Dictionary(ies) provided: " << dictionaries << std::endl; std::cout << "Input file provided: " << inputFile << std::endl; - std::cout << "Validation kindness: " - << (ignoreFlags ? "non strict" : "strict") << std::endl; + std::cout << "Validation kindness: " << (non_strict_validation ? "non strict" : "strict") << std::endl; // Logger and engines: Logger::setLevel(Logger::Debug); Logger::initialize(execBN.c_str(), new TraceWriter(filetrace.c_str(), 2048000)); @@ -395,7 +395,11 @@ int main(int argc, char **argv) { _exit(ex.asString()); } - codecEngine->ignoreFlagsOnValidation(ignoreFlags); + if(non_strict_validation) { + codecEngine->setValidationMode(anna::diameter::codec::EngineImpl::ValidationMode::Never); + codecEngine->ignoreFlagsOnValidation(true); + } + // Tracing: //if (cl.exists("trace")) // anna::Logger::setLevel(anna::Logger::asLevel(cl.getValue("trace"))); diff --git a/include/anna/core/util/MultiRangeExpression.hpp b/include/anna/core/util/MultiRangeExpression.hpp index a391bb5..15b949c 100644 --- a/include/anna/core/util/MultiRangeExpression.hpp +++ b/include/anna/core/util/MultiRangeExpression.hpp @@ -113,7 +113,9 @@ public: * @param l Literal to be added */ void addLiteral(const char * l) throw() { - if(l) { + if(!l) return; + + if(std::string(l) != "") { a_literal += ","; a_literal += l; } diff --git a/scr/git/pre-commit.sh b/scr/git/pre-commit.sh index e9ded58..5d1a980 100755 --- a/scr/git/pre-commit.sh +++ b/scr/git/pre-commit.sh @@ -115,7 +115,7 @@ for file in $files; do x=`echo $file |grep -E '(\.cpp|\.hpp)'` if test "x$x" != "x"; then test_style $file - #git add $file + git add $file fi done