Revision: 48
Author: maka82
Date: Mon Aug 17 10:13:50 2009
Log: Regular expressions in CPPHeuristicChecker have been modified so that they match better functions which look like this:

int OpenCVImage::getHeight() const {
                something
        }

and like this:

char * OpenCVImage::getPixels(){
                something
        }
http://code.google.com/p/apache-rat-pd/source/detail?r=48

Modified:
/trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CPPFunctionHeuristicChecker.java

=======================================
--- /trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CPPFunctionHeuristicChecker.java Sun Aug 16 16:43:54 2009 +++ /trunk/src/main/java/org/apache/rat/pd/heuristic/functions/CPPFunctionHeuristicChecker.java Mon Aug 17 10:13:50 2009
@@ -38,8 +38,7 @@
        /**
         * This regular expression match functions in C++.
         */
- private static final String CPP_FUNCTION_REGEX_1 = "^[\t ]*([(\\w+)]| (\\s+))+\\s+(\\w+) *\\([^()]*\\)(\\s)*"
-                       + "\\{[\\s\\S]*\\}[\n\r]*";
+ private static final String CPP_FUNCTION_REGEX_1 = "\\w+\\s+[*&]?\\s*\\w+ *\\([^()]*?\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";

        /**
* This regular expression match functions in C++ which have mark "::". For
@@ -48,8 +47,7 @@
         * MyType MyType::Add(const MyType & rhs) { return MyType(itsVal+
         * rhs.GetItsVal()); }
         */
- private static final String CPP_FUNCTION_REGEX_2 = "^[\t ]*(\\w+ *){1,2}\\:\\:\\w+\\s*\\([^()]*\\)(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
-
+ private static final String CPP_FUNCTION_REGEX_2 = "^[\t ]*[\\w+ \\*&]+\\s*\\:\\:\\s*[*&~]?\\s*\\w+ *\\([^()]*?\\)( *const *)?(\\s)*\\{[\\s\\S]*\\}[\n\r]*";
        // TODO add regular expression which will match functions with a 
reference
        // to a string as a returning type for example.
private static final String CPP_FUNCTION_REGEX = "(" + CPP_FUNCTION_REGEX_1

Reply via email to