Skip to content

Conversation

IngoMeyer441
Copy link

I modified the c function parser to support coding styles that put the return value on the same line as the function name:

int main() {...

It is compatible with the old behavior of the plugin.

@IngoMeyer441 IngoMeyer441 force-pushed the support-more-c-styles branch from f3c02e2 to 811367d Compare May 1, 2016 09:41
@kana
Copy link
Owner

kana commented May 1, 2016

Thank you for the patch! But it doesn't work for code like the following:

/**
 * ... some description ...
 */
int foo(void)
{
  return 42;
}

vaf should select the last 4 lines, but the modified version selects also the third line (*/).

@IngoMeyer441
Copy link
Author

IngoMeyer441 commented May 1, 2016

Thanks for your fast reply. :) Maybe the following is more robust:

  1. Remove all comments from the first line (that was intended to contain the return type before)
  2. Strip leading and trailing white space
  3. Check if the reduced line ends with } or ;. If not assume that it contains a return type and select it. Otherwise, it is a comment, ending function or a statement and it does not belong to the selected function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants