Skip to content

Commit

Permalink
C: Fix line continuation handling (#1370)
Browse files Browse the repository at this point in the history
Escaped newlines were properly handled inside preprocessor directives,
but not otherwise.

Seeing `continue` here suggests the code used to work a long time ago
but some loop refactoring broke it, as now it would not stay in the
loop unless in a preprocessor directive.  Or maybe it only ever worked
for preprocessor directives, and the `continue` was superfluous?

Fixes #1370.
  • Loading branch information
b4n authored and elextr committed Apr 20, 2017
1 parent 2707006 commit 6f69211
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ctags/main/lcpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,10 @@ extern int cppGetc (void)
int next = getcFromInputFile ();

if (next == NEWLINE)
continue;
{
c = getcFromInputFile ();
goto process;
}
else
ungetcToInputFile (next);
break;
Expand Down
1 change: 1 addition & 0 deletions tests/ctags/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ test_sources = \
array-spec.f90 \
attributes.cs \
auto.f \
backslashes.c \
bit_field.c \
block.f90 \
bracematch.js \
Expand Down
29 changes: 29 additions & 0 deletions tests/ctags/backslashes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
typedef int T;

int func1(\
int var1, int var2, ...);

int func2(int var1, \
int var2, ...);

int func3(T \
var1, T var2, ...);
int func4(T var1, \
T var2, ...);

int func5(int \
var1, int var2, ...);

// check continuations in macros are properly handled
#define MACRO1 \
(
int func6(void);
#define MACRO2(x) \
int x(void);
#define MACRO3(y) \
int \
y \
( \
void \
);
int func7(int a);
12 changes: 12 additions & 0 deletions tests/ctags/backslashes.c.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# format=tagmanager
MACRO1�65536�0
MACRO2�131072�(x)�0
MACRO3�131072�(y)�0
T�4096�0�int
func1�1024�(int var1, int var2, ...)�0�int
func2�1024�(int var1, int var2, ...)�0�int
func3�1024�(T var1, T var2, ...)�0�int
func4�1024�(T var1, T var2, ...)�0�int
func5�1024�(int var1, int var2, ...)�0�int
func6�1024�(void)�0�int
func7�1024�(int a)�0�int

0 comments on commit 6f69211

Please sign in to comment.