Skip to content

Do not insert prototypes in the middle of a line. #8

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

Merged
merged 2 commits into from
Dec 26, 2017
Merged

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Dec 22, 2017

The insertion point of prototypes may be detected to be in the middle of a line for example in the following sketch:

int a; int b=forwardDeclared();
void setup() {}
void loop() {}
int forwardDeclared() { return 0; }

the insertion point is determined to be between int a; and int b=.. since the latter declaration use a forward-declared function to initialize variable.
Before this patch this resulted in a stray #line directive inserted in the middle of a line:

int a; #line 1 ......     <- added prototype line
int forwardDeclared();    <- added prototype
#line 2.....              <- other prototypes....
......

This patch avoids the situation above by inserting a newline just before the first #line directive if the insertion point happens to be in the middle of a line.

Fix #7

The insertion point of prototypes may be detected to be in the middle
of a line for example in the following sketch:

   int a; int b=forwardDeclared();
   void setup() {}
   void loop() {}
   int forwardDeclared() { return 0; }

the insertion point is determined to be between `int a;` and `int b=..`
since the latter declaration use a forward-declared function to
initialize variable.
Before this patch this resulted in a stray `#line` directive inserted in
the middle of a line:

   int a; #line 1 ......     <- added prototype line
   int forwardDeclared();    <- added prototype
   #line 2.....              <- other prototypes....
   ......

This patch avoids the situation above by inserting a newline just before
the first `#line` directive if the insertion point happens to be in the
middle of a line.

Fix #7
@cmaglie cmaglie merged commit fb0dfb5 into master Dec 26, 2017
@cmaglie cmaglie deleted the fix-issue-7 branch December 26, 2017 16:53
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.

1 participant