Skip to content

Commit d1b15de

Browse files
committed
patch 7.4.893
Problem: C indenting is wrong below a "case (foo):" because it is recognized as a C++ base class construct. Issue #38. Solution: Check for the case keyword.
1 parent 9d6ca1c commit d1b15de

4 files changed

Lines changed: 64 additions & 1 deletion

File tree

src/misc1.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6555,7 +6555,7 @@ cin_is_cpp_baseclass(cached)
65556555

65566556
pos->lnum = lnum;
65576557
line = ml_get(lnum);
6558-
s = cin_skipcomment(line);
6558+
s = line;
65596559
for (;;)
65606560
{
65616561
if (*s == NUL)
@@ -6564,6 +6564,13 @@ cin_is_cpp_baseclass(cached)
65646564
break;
65656565
/* Continue in the cursor line. */
65666566
line = ml_get(++lnum);
6567+
s = line;
6568+
}
6569+
if (s == line)
6570+
{
6571+
/* don't recognize "case (foo):" as a baseclass */
6572+
if (cin_iscase(s, FALSE))
6573+
break;
65676574
s = cin_skipcomment(line);
65686575
if (*s == NUL)
65696576
continue;

src/testdir/test3.in

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,33 @@ if (1)
932932
a = 1;
933933
}
934934

935+
void func()
936+
{
937+
switch (foo)
938+
{
939+
case (bar):
940+
if (baz())
941+
quux();
942+
break;
943+
case (shmoo):
944+
if (!bar)
945+
{
946+
}
947+
case (foo1):
948+
switch (bar)
949+
{
950+
case baz:
951+
baz_f();
952+
break;
953+
}
954+
break;
955+
default:
956+
baz();
957+
baz();
958+
break;
959+
}
960+
}
961+
935962
/* end of AUTO */
936963

937964
STARTTEST

src/testdir/test3.ok

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,33 @@ void getstring() {
920920
a = 1;
921921
}
922922

923+
void func()
924+
{
925+
switch (foo)
926+
{
927+
case (bar):
928+
if (baz())
929+
quux();
930+
break;
931+
case (shmoo):
932+
if (!bar)
933+
{
934+
}
935+
case (foo1):
936+
switch (bar)
937+
{
938+
case baz:
939+
baz_f();
940+
break;
941+
}
942+
break;
943+
default:
944+
baz();
945+
baz();
946+
break;
947+
}
948+
}
949+
923950
/* end of AUTO */
924951

925952

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
893,
744746
/**/
745747
892,
746748
/**/

0 commit comments

Comments
 (0)