Function List not displaying found strings correct for Unicode files (fixed)

Function List not displaying found strings correct for Unicode files (fixed)

3
NewbieNewbie
3

    Sep 06, 2011#1

    Hi,

    I want to edit a cpp file with UE.

    But function list displays functions wrong.

    UE 17.10 and 17.20 produce same result in the view.

    1) function name wrong (yellow highlight)

    void CRobot::MotorInit() -> oid CRobot::Motor
    void CRobot::Stop -> oid CRobot::


    2) false function name (cyan highlight)

    ex) printf("---> C
    (This is not a function)

    Please check this problem with attached *.cpp file (already deleted).

    Thanks.

    ue.jpg (108.06KiB)

    6,682583
    Grand MasterGrand Master
    6,682583

      Sep 06, 2011#2

      The regular expression string in c_cplusplus.uew to find C++ functions is:

      /TGFindStr = "[ ^t]++^([a-z_][a-z_0-9]++::[a-z_^~][a-z_0-9]++^)[ ^t^p]++([^p*&:, ^t^[^]/*^-'=:&a-z_0-9./(!]++)[~;]"

      This regular expression means simplified:
      • Find a string starting at beginning of a line or anywhere else after a space or tab character,
      • which begins with a letter or an underscore (first character of class name),
      • consists further of only letters, digits and underscores (other characters of class name),
      • then :: must follow,
      • the next character must be a letter or an underscore or ~ (first character of function name or destructor operator),
      • consists further of only letters, digits and underscores (other characters of function name),
      • and zero or more spaces, tabs or line terminators follow the function name,
      • then an opening and closing round bracket must be found with lots of possible characters inside (function parameters and block comments),
      • and the next character after the closing round bracket must not be a semicolon.
      All these requirements are fulfilled by CRobot::Drive() inside the string printed with printf function. The expression does not evaluate what is left the class name. This is important for example for CRobot::CRobot() where nothing is left the function definition. Other functions have a return type which should be ignored for finding the function definitions. Also what is right after closing round bracket and the following character is not analyzed further because many programmers write comments there which can contain everything.

      You could use following 2 lines instead of the single line above:

      /TGFindStr = "%[ ^t]++^([a-z_][a-z_0-9]++::[a-z_^~][a-z_0-9]++^)[ ^t^p]++([^p*&:, ^t^[^]/*^-'=:&a-z_0-9./(!]++)[~;]"
      /TGFindStr = "%[a-z0-9_*&]+[ ^t]+^([a-z_][a-z_0-9]++::[a-z_^~][a-z_0-9]++^)[ ^t^p]++([^p*&:, ^t^[^]/*^-'=:&a-z_0-9./(!]++)[~;]"


      Now only ClassName::FunctionName at begining of a line after optional preceding whitespaces (first expression) or after a return type consisting only of letters, digits, underscores, asterisk or ampersand are found (second expression). That excludes the ClassName::FunctionName string inside the printf function. But something like

      int * ClassName::FunctionName1()

      is now also excluded while

      int* ClassName::FunctionName2()

      is found and displayed in the function list view. To find also ClassName::FunctionName1 one more regular expression string is needed:

      /TGFindStr = "%[a-z0-9_]+[ ^t]+^*[ ^t]+^([a-z_][a-z_0-9]++::[a-z_^~][a-z_0-9]++^)[ ^t^p]++([^p*&:, ^t^[^]/*^-'=:&a-z_0-9./(!]++)[~;]"

      You see, there is no single regular expression which works for everyone for every C/C++ file. The function definition variants are too much. It is good practice to adapt all the regular expression strings in the wordfile to personal coding style with as less regular expression strings as possible.

      3
      NewbieNewbie
      3

        Sep 06, 2011#3

        I solved the problem.

        I changed U8-UNIX into UNIX.

        (copy all text -> new File -> paste)

        Now, Function list showed correct function names.

        Thanks for your help Mofi.

        ue1.jpg (34.21KiB)

        6,682583
        Grand MasterGrand Master
        6,682583

          Sep 06, 2011#4

          Converting the file from UTF-8 to ASCII (respectively ANSI) solves the problem with the truncated strings. This is definitely a problem of UltraEdit program code because the function string feature should work also for Unicode files. I have reported this problem to IDM by email.

          But the conversion to ASCII/ANSI does not solve the problem listing CRobot::Drive() within the printf() string as function in the function list view. It would be necessary to adapt the wordfile c_cplusplus.uew best opened directly from Advanced - Configuration - Editor Display - Syntax Highlighting as I posted. Alternatively you can right click into the function list view, left click on Configuration, modify the second regular expression in group Function to my first expression and add the second (and third) expression too.

            Feb 12, 2017#5

            The issue with function list not working as expected for this UTF-8 encoded file was fixed with UltraEdit for Windows v24.00 and UEStudio v17.00.
            Best regards from an UC/UE/UES for Windows user from Austria