Skip to content

Commit 2defaf5

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents a06e110 + c3c766e commit 2defaf5

40 files changed

+220
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ src/testdir/test.log
7878
src/testdir/dostmp/*
7979
src/testdir/messages
8080
src/testdir/viminfo
81+
src/testdir/opt_test.vim
8182
src/memfile_test
8283
src/json_test
8384
src/message_test

Filelist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ SRC_ALL = \
9797
src/tee/tee.c \
9898
src/xxd/xxd.c \
9999
src/main.aap \
100-
src/gen_opt_test.vim \
100+
src/testdir/gen_opt_test.vim \
101101
src/testdir/main.aap \
102102
src/testdir/README.txt \
103103
src/testdir/Make_all.mak \

runtime/doc/indent.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,21 @@ The examples below assume a 'shiftwidth' of 4.
324324
{ {
325325
void function(); void function();
326326
} }
327+
<
328+
*cino-E*
329+
EN Indent inside C++ linkage specifications (extern "C" or
330+
extern "C++") N characters extra compared to a normal block.
331+
(default 0).
332+
333+
cino= cino=E-s >
334+
extern "C" { extern "C" {
335+
void function(); void function();
336+
} }
337+
338+
extern "C" extern "C"
339+
{ {
340+
void function(); void function();
341+
} }
327342
<
328343
*cino-p*
329344
pN Parameter declarations for K&R-style function declarations will
@@ -554,7 +569,7 @@ The examples below assume a 'shiftwidth' of 4.
554569

555570

556571
The defaults, spelled out in full, are:
557-
cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,ps,ts,is,+s,
572+
cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,E0,ps,ts,is,+s,
558573
c3,C0,/0,(2s,us,U0,w0,W0,k0,m0,j0,J0,)20,*70,#0
559574

560575
Vim puts a line in column 1 if:

src/Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,6 @@ test check: scripttests unittests
20422042
#
20432043
scripttests:
20442044
$(MAKE) -f Makefile $(VIMTARGET)
2045-
$(MAKE) -f Makefile testdir/opt_test.vim
20462045
if test -n "$(MAKEMO)" -a -f $(PODIR)/Makefile; then \
20472046
cd $(PODIR); $(MAKE) -f Makefile check VIM=../$(VIMTARGET); \
20482047
fi
@@ -2051,9 +2050,6 @@ scripttests:
20512050
fi
20522051
cd testdir; $(MAKE) -f Makefile $(GUI_TESTTARGET) VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
20532052

2054-
testdir/opt_test.vim: option.c gen_opt_test.vim
2055-
./$(VIMTARGET) -u gen_opt_test.vim --noplugin --not-a-term
2056-
20572053
# Run the tests with the GUI. Assumes vim/gvim was already built
20582054
testgui:
20592055
cd testdir; $(MAKE) -f Makefile $(GUI_TESTTARGET) VIMPROG=../$(VIMTARGET) GUI_FLAG=-g $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
@@ -2791,7 +2787,7 @@ SHADOWDIR = shadow
27912787

27922788
shadow: runtime pixmaps
27932789
mkdir $(SHADOWDIR)
2794-
cd $(SHADOWDIR); ln -s ../*.[chm] ../*.in ../*.vim ../*.sh ../*.xs ../*.xbm ../gui_gtk_res.xml ../toolcheck ../proto ../vimtutor ../gvimtutor ../mkinstalldirs .
2790+
cd $(SHADOWDIR); ln -s ../*.[chm] ../*.in ../*.sh ../*.xs ../*.xbm ../gui_gtk_res.xml ../toolcheck ../proto ../vimtutor ../gvimtutor ../mkinstalldirs .
27952791
mkdir $(SHADOWDIR)/auto
27962792
cd $(SHADOWDIR)/auto; ln -s ../../auto/configure .
27972793
mkdir $(SHADOWDIR)/po

src/misc1.c

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5815,6 +5815,54 @@ cin_is_cpp_namespace(char_u *s)
58155815
return FALSE;
58165816
}
58175817

5818+
/*
5819+
* Recognize a `extern "C"` or `extern "C++"` linkage specifications.
5820+
*/
5821+
static int
5822+
cin_is_cpp_extern_c(char_u *s)
5823+
{
5824+
char_u *p;
5825+
int has_string_literal = FALSE;
5826+
5827+
s = cin_skipcomment(s);
5828+
if (STRNCMP(s, "extern", 6) == 0 && (s[6] == NUL || !vim_iswordc(s[6])))
5829+
{
5830+
p = cin_skipcomment(skipwhite(s + 6));
5831+
while (*p != NUL)
5832+
{
5833+
if (vim_iswhite(*p))
5834+
{
5835+
p = cin_skipcomment(skipwhite(p));
5836+
}
5837+
else if (*p == '{')
5838+
{
5839+
break;
5840+
}
5841+
else if (p[0] == '"' && p[1] == 'C' && p[2] == '"')
5842+
{
5843+
if (has_string_literal)
5844+
return FALSE;
5845+
has_string_literal = TRUE;
5846+
p += 3;
5847+
}
5848+
else if (p[0] == '"' && p[1] == 'C' && p[2] == '+' && p[3] == '+'
5849+
&& p[4] == '"')
5850+
{
5851+
if (has_string_literal)
5852+
return FALSE;
5853+
has_string_literal = TRUE;
5854+
p += 5;
5855+
}
5856+
else
5857+
{
5858+
return FALSE;
5859+
}
5860+
}
5861+
return has_string_literal ? TRUE : FALSE;
5862+
}
5863+
return FALSE;
5864+
}
5865+
58185866
/*
58195867
* Return a pointer to the first non-empty non-comment character after a ':'.
58205868
* Return NULL if not found.
@@ -6658,6 +6706,7 @@ cin_skip2pos(pos_T *trypos)
66586706
{
66596707
char_u *line;
66606708
char_u *p;
6709+
char_u *new_p;
66616710

66626711
p = line = ml_get(trypos->lnum);
66636712
while (*p && (colnr_T)(p - line) < trypos->col)
@@ -6666,8 +6715,11 @@ cin_skip2pos(pos_T *trypos)
66666715
p = cin_skipcomment(p);
66676716
else
66686717
{
6669-
p = skip_string(p);
6670-
++p;
6718+
new_p = skip_string(p);
6719+
if (new_p == p)
6720+
++p;
6721+
else
6722+
p = new_p;
66716723
}
66726724
}
66736725
return (int)(p - line);
@@ -6983,6 +7035,9 @@ parse_cino(buf_T *buf)
69837035
/* indentation for # comments */
69847036
buf->b_ind_hash_comment = 0;
69857037

7038+
/* Handle C++ extern "C" or "C++" */
7039+
buf->b_ind_cpp_extern_c = 0;
7040+
69867041
for (p = buf->b_p_cino; *p; )
69877042
{
69887043
l = p++;
@@ -7057,6 +7112,7 @@ parse_cino(buf_T *buf)
70577112
case '#': buf->b_ind_hash_comment = n; break;
70587113
case 'N': buf->b_ind_cpp_namespace = n; break;
70597114
case 'k': buf->b_ind_if_for_while = n; break;
7115+
case 'E': buf->b_ind_cpp_extern_c = n; break;
70607116
}
70617117
if (*p == ',')
70627118
++p;
@@ -7770,6 +7826,8 @@ get_c_indent(void)
77707826
l = skipwhite(ml_get_curline());
77717827
if (cin_is_cpp_namespace(l))
77727828
amount += curbuf->b_ind_cpp_namespace;
7829+
else if (cin_is_cpp_extern_c(l))
7830+
amount += curbuf->b_ind_cpp_extern_c;
77737831
}
77747832
else
77757833
{
@@ -7996,6 +8054,12 @@ get_c_indent(void)
79968054
- added_to_amount;
79978055
break;
79988056
}
8057+
else if (cin_is_cpp_extern_c(l))
8058+
{
8059+
amount += curbuf->b_ind_cpp_extern_c
8060+
- added_to_amount;
8061+
break;
8062+
}
79998063

80008064
if (cin_nocode(l))
80018065
continue;

src/structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,6 +2242,7 @@ struct file_buffer
22422242
int b_ind_hash_comment;
22432243
int b_ind_cpp_namespace;
22442244
int b_ind_if_for_while;
2245+
int b_ind_cpp_extern_c;
22452246
#endif
22462247

22472248
linenr_T b_no_eol_lnum; /* non-zero lnum when last line of next binary

src/testdir/Make_all.mak

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ NEW_TESTS = test_arabic.res \
181181
test_netbeans.res \
182182
test_normal.res \
183183
test_number.res \
184+
test_options.res \
184185
test_packadd.res \
185186
test_paste.res \
186187
test_perl.res \
@@ -221,3 +222,4 @@ test49.out: test49.vim
221222

222223
test60.out: test60.vim
223224

225+
test_options.res test_alot.res: opt_test.vim

src/testdir/Make_dos.mak

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ clean:
9494
-if exist test.log del test.log
9595
-if exist messages del messages
9696
-if exist benchmark.out del benchmark.out
97+
-if exist opt_test.vim del opt_test.vim
9798

9899
nolog:
99100
-if exist test.log del test.log
@@ -127,3 +128,6 @@ test_gui_init.res: test_gui_init.vim
127128
@echo "$(VIMPROG)" > vimcmd
128129
$(VIMPROG) -u NONE -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $*.vim
129130
@del vimcmd
131+
132+
opt_test.vim: ../option.c gen_opt_test.vim
133+
$(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../option.c

src/testdir/Make_ming.mak

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ clean:
8888
-@if exist viminfo $(DEL) viminfo
8989
-@if exist test.log $(DEL) test.log
9090
-@if exist messages $(DEL) messages
91+
-@if exist opt_test.vim $(DEL) opt_test.vim
9192

9293
.in.out:
9394
-@if exist $*.ok $(CP) $*.ok test.ok
@@ -131,3 +132,5 @@ test_gui_init.res: test_gui_init.vim
131132
$(VIMPROG) -u NONE -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
132133
@$(DEL) vimcmd
133134

135+
opt_test.vim: ../option.c gen_opt_test.vim
136+
$(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../option.c

src/testdir/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ RM_ON_START = tiny.vim small.vim mbyte.vim mzscheme.vim lua.vim test.ok benchmar
5555
RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim $(NO_INITS) -s dotest.in
5656

5757
clean:
58-
-rm -rf *.out *.failed *.res *.rej *.orig test.log messages $(RM_ON_RUN) $(RM_ON_START) valgrind.*
58+
-rm -rf *.out *.failed *.res *.rej *.orig opt_test.vim test.log messages $(RM_ON_RUN) $(RM_ON_START) valgrind.*
5959

6060
test1.out: test1.in
6161
-rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize
@@ -140,3 +140,6 @@ test_gui_init.res: test_gui_init.vim
140140
@echo "$(RUN_GVIMTEST_WITH_GVIMRC)" > vimcmd
141141
$(RUN_VIMTEST) -u NONE -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
142142
@rm vimcmd
143+
144+
opt_test.vim: ../option.c gen_opt_test.vim
145+
$(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../option.c

0 commit comments

Comments
 (0)