Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix style issues and improve vera++ rules. #896

Merged

Conversation

LaszloLango
Copy link
Contributor

JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]

@LaszloLango LaszloLango added minor style Related to coding style labels Feb 17, 2016
if {[regexp {\w\*\s\w+} $line]} {
if {[regexp {\w\*\s\w+} $line]
|| [regexp {\w\*\)} $line]
|| [regexp {\w\*$} $line]} {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got badly misled by the name of the rule. The first/old pattern matches something like x* abc (or, more realistically, the tail of void* p). The new ones match void*) and void*-at-end-of-line. If I'm not mistaken, none of these are pointer dereferences but pointer declarations.

As for the original pattern: why does \s have no + multiplier? And why does the second \w have one? Would changing these cause too many false positives?

If we are already touching this file, it would be good to get it right.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first check is for type* var_name
The second is for type casting for a pointer type (type*)
The third one is for return values of functions. They are usually in a separate line.
The plus for \w is not necessary, we can remove if it bothers you. \s+ may be a good idea.
About the name, my opinion is that the * symbol is the pointer dereference operator, but the expressions are really pointer declerations. I'd like to refer the * in the name of the rule not the expressions, but we can change the name of rule if it is misleading. Please suggest a proper rule name and message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made a terrible mistake. I've taken a look at the C99 standard :). Now I know that * is a punctuator, which is known as an operator, if (and only if) used in a context where it specifies an operation (6.4.6 p2). However, the first and the third checks are for declarators (6.7.5), while the second check is for the type-name part of a cast operator (6.5.4), which leads back again to declarations (6.7.6 p2).

Could jerry_pointer_declarator_space.tcl work as a filename, and "there should be a space between the referenced type and the pointer declarator" as a message work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akiss77, it convenient for me. I'll update the file name and the message.

JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
@LaszloLango
Copy link
Contributor Author

@akiss77, I've updated the PR.

@akosthekiss
Copy link
Member

LGTM (FWIW)

@zherczeg
Copy link
Member

LGTM

@LaszloLango LaszloLango merged commit a7715a5 into jerryscript-project:master Feb 18, 2016
@LaszloLango LaszloLango deleted the fix-style-issues branch February 19, 2016 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor style Related to coding style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants