Skip to content

Commit 261f346

Browse files
committed
patch 8.1.2001: some source files are too big
Problem: Some source files are too big. Solution: Move buffer and window related functions to evalbuffer.c and evalwindow.c. (Yegappan Lakshmanan, closes vim#4898)
1 parent a3a1246 commit 261f346

20 files changed

+2118
-2037
lines changed

Filelist

+4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ SRC_ALL = \
3434
src/digraph.c \
3535
src/edit.c \
3636
src/eval.c \
37+
src/evalbuffer.c \
3738
src/evalfunc.c \
3839
src/evalvars.c \
40+
src/evalwindow.c \
3941
src/ex_cmdidxs.h \
4042
src/ex_cmds.c \
4143
src/ex_cmds.h \
@@ -189,8 +191,10 @@ SRC_ALL = \
189191
src/proto/digraph.pro \
190192
src/proto/edit.pro \
191193
src/proto/eval.pro \
194+
src/proto/evalbuffer.pro \
192195
src/proto/evalfunc.pro \
193196
src/proto/evalvars.pro \
197+
src/proto/evalwindow.pro \
194198
src/proto/ex_cmds.pro \
195199
src/proto/ex_cmds2.pro \
196200
src/proto/ex_docmd.pro \

src/Make_cyg_ming.mak

+2
Original file line numberDiff line numberDiff line change
@@ -721,8 +721,10 @@ OBJ = \
721721
$(OUTDIR)/digraph.o \
722722
$(OUTDIR)/edit.o \
723723
$(OUTDIR)/eval.o \
724+
$(OUTDIR)/evalbuffer.o \
724725
$(OUTDIR)/evalfunc.o \
725726
$(OUTDIR)/evalvars.o \
727+
$(OUTDIR)/evalwindow.o \
726728
$(OUTDIR)/ex_cmds.o \
727729
$(OUTDIR)/ex_cmds2.o \
728730
$(OUTDIR)/ex_docmd.o \

src/Make_morph.mak

+2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ SRC = arabic.c \
4141
digraph.c \
4242
edit.c \
4343
eval.c \
44+
evalbuffer.c \
4445
evalfunc.c \
4546
evalvars.c \
47+
evalwindow.c \
4648
ex_cmds.c \
4749
ex_cmds2.c \
4850
ex_docmd.c \

src/Make_mvc.mak

+8
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,10 @@ OBJ = \
728728
$(OUTDIR)\digraph.obj \
729729
$(OUTDIR)\edit.obj \
730730
$(OUTDIR)\eval.obj \
731+
$(OUTDIR)\evalbuffer.obj \
731732
$(OUTDIR)\evalfunc.obj \
732733
$(OUTDIR)\evalvars.obj \
734+
$(OUTDIR)\evalwindow.obj \
733735
$(OUTDIR)\ex_cmds.obj \
734736
$(OUTDIR)\ex_cmds2.obj \
735737
$(OUTDIR)\ex_docmd.obj \
@@ -1485,10 +1487,14 @@ $(OUTDIR)/edit.obj: $(OUTDIR) edit.c $(INCL)
14851487

14861488
$(OUTDIR)/eval.obj: $(OUTDIR) eval.c $(INCL)
14871489

1490+
$(OUTDIR)/evalbuffer.obj: $(OUTDIR) evalbuffer.c $(INCL)
1491+
14881492
$(OUTDIR)/evalfunc.obj: $(OUTDIR) evalfunc.c $(INCL)
14891493

14901494
$(OUTDIR)/evalvars.obj: $(OUTDIR) evalvars.c $(INCL)
14911495

1496+
$(OUTDIR)/evalwindow.obj: $(OUTDIR) evalwindow.c $(INCL)
1497+
14921498
$(OUTDIR)/ex_cmds.obj: $(OUTDIR) ex_cmds.c $(INCL)
14931499

14941500
$(OUTDIR)/ex_cmds2.obj: $(OUTDIR) ex_cmds2.c $(INCL)
@@ -1775,8 +1781,10 @@ proto.h: \
17751781
proto/digraph.pro \
17761782
proto/edit.pro \
17771783
proto/eval.pro \
1784+
proto/evalbuffer.pro \
17781785
proto/evalfunc.pro \
17791786
proto/evalvars.pro \
1787+
proto/evalwindow.pro \
17801788
proto/ex_cmds.pro \
17811789
proto/ex_cmds2.pro \
17821790
proto/ex_docmd.pro \

src/Make_vms.mms

+14-3
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,10 @@ ALL_LIBS = $(LIBS) $(GUI_LIB_DIR) $(GUI_LIB) \
309309

310310
SRC = arabic.c arglist.c autocmd.c beval.c blob.c blowfish.c buffer.c \
311311
change.c charset.c cmdexpand.c cmdhist.c crypt.c crypt_zip.c \
312-
debugger.c dict.c diff.c digraph.c edit.c eval.c evalfunc.c \
313-
evalvars.c ex_cmds.c ex_cmds2.c ex_docmd.c ex_eval.c ex_getln.c \
312+
debugger.c dict.c diff.c digraph.c edit.c eval.c evalbuffer.c \
313+
evalfunc.c \
314+
evalvars.c evalwindow.c ex_cmds.c ex_cmds2.c ex_docmd.c ex_eval.c \
315+
ex_getln.c \
314316
if_cscope.c if_xcmdsrv.c fileio.c filepath.c, findfile.c fold.c \
315317
getchar.c hardcopy.c hashtab.c highlight.c \
316318
indent.c insexpand.c json.c list.c main.c map.c mark.c menu.c mbyte.c \
@@ -327,7 +329,8 @@ SRC = arabic.c arglist.c autocmd.c beval.c blob.c blowfish.c buffer.c \
327329
OBJ = arabic.obj arglist.obj autocmd.obj beval.obj blob.obj blowfish.obj \
328330
buffer.obj change.obj charset.obj cmdexpand.obj cmdhist.obj \
329331
crypt.obj crypt_zip.obj debugger.obj dict.obj diff.obj digraph.obj \
330-
edit.obj eval.obj evalfunc.obj evalvars.obj ex_cmds.obj ex_cmds2.obj \
332+
edit.obj eval.obj evalbuffer.obj evalfunc.obj evalvars.obj \
333+
evalwindow.obj ex_cmds.obj ex_cmds2.obj \
331334
ex_docmd.obj ex_eval.obj ex_getln.obj if_cscope.obj if_xcmdsrv.obj \
332335
fileio.obj filepath.obj \
333336
findfile.obj fold.obj getchar.obj hardcopy.obj hashtab.obj \
@@ -567,6 +570,10 @@ eval.obj : eval.c vim.h [.auto]config.h feature.h os_unix.h \
567570
ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \
568571
[.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \
569572
version.h
573+
evalbuffer.obj : evalbuffer.c vim.h [.auto]config.h feature.h os_unix.h \
574+
ascii.h keymap.h term.h macros.h option.h structs.h \
575+
regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
576+
proto.h globals.h version.h
570577
evalfunc.obj : evalfunc.c vim.h [.auto]config.h feature.h os_unix.h \
571578
ascii.h keymap.h term.h macros.h option.h structs.h \
572579
regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
@@ -575,6 +582,10 @@ evalvars.obj : evalvars.c vim.h [.auto]config.h feature.h os_unix.h \
575582
ascii.h keymap.h term.h macros.h option.h structs.h \
576583
regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
577584
proto.h globals.h version.h
585+
evalwindow.obj : evalwindow.c vim.h [.auto]config.h feature.h os_unix.h \
586+
ascii.h keymap.h term.h macros.h option.h structs.h \
587+
regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
588+
proto.h globals.h version.h
578589
ex_cmds.obj : ex_cmds.c vim.h [.auto]config.h feature.h os_unix.h \
579590
ascii.h keymap.h term.h macros.h structs.h regexp.h \
580591
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \

src/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -1595,8 +1595,10 @@ BASIC_SRC = \
15951595
digraph.c \
15961596
edit.c \
15971597
eval.c \
1598+
evalbuffer.c \
15981599
evalfunc.c \
15991600
evalvars.c \
1601+
evalwindow.c \
16001602
ex_cmds.c \
16011603
ex_cmds2.c \
16021604
ex_docmd.c \
@@ -1726,8 +1728,10 @@ OBJ_COMMON = \
17261728
objects/digraph.o \
17271729
objects/edit.o \
17281730
objects/eval.o \
1731+
objects/evalbuffer.o \
17291732
objects/evalfunc.o \
17301733
objects/evalvars.o \
1734+
objects/evalwindow.o \
17311735
objects/ex_cmds.o \
17321736
objects/ex_cmds2.o \
17331737
objects/ex_docmd.o \
@@ -1870,8 +1874,10 @@ PRO_AUTO = \
18701874
digraph.pro \
18711875
edit.pro \
18721876
eval.pro \
1877+
evalbuffer.pro \
18731878
evalfunc.pro \
18741879
evalvars.pro \
1880+
evalwindow.pro \
18751881
ex_cmds.pro \
18761882
ex_cmds2.pro \
18771883
ex_docmd.pro \
@@ -3080,12 +3086,18 @@ objects/edit.o: edit.c
30803086
objects/eval.o: eval.c
30813087
$(CCC) -o $@ eval.c
30823088

3089+
objects/evalbuffer.o: evalbuffer.c
3090+
$(CCC) -o $@ evalbuffer.c
3091+
30833092
objects/evalfunc.o: evalfunc.c
30843093
$(CCC) -o $@ evalfunc.c
30853094

30863095
objects/evalvars.o: evalvars.c
30873096
$(CCC) -o $@ evalvars.c
30883097

3098+
objects/evalwindow.o: evalwindow.c
3099+
$(CCC) -o $@ evalwindow.c
3100+
30893101
objects/ex_cmds.o: ex_cmds.c
30903102
$(CCC) -o $@ ex_cmds.c
30913103

@@ -3603,6 +3615,10 @@ objects/eval.o: eval.c vim.h protodef.h auto/config.h feature.h os_unix.h \
36033615
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
36043616
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
36053617
proto.h globals.h version.h
3618+
objects/evalbuffer.o: evalbuffer.c vim.h protodef.h auto/config.h feature.h os_unix.h \
3619+
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
3620+
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
3621+
proto.h globals.h version.h
36063622
objects/evalfunc.o: evalfunc.c vim.h protodef.h auto/config.h feature.h os_unix.h \
36073623
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
36083624
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
@@ -3611,6 +3627,10 @@ objects/evalvars.o: evalvars.c vim.h protodef.h auto/config.h feature.h \
36113627
os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
36123628
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
36133629
proto.h globals.h
3630+
objects/evalwindow.o: evalwindow.c vim.h protodef.h auto/config.h feature.h \
3631+
os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
3632+
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
3633+
proto.h globals.h
36143634
objects/ex_cmds.o: ex_cmds.c vim.h protodef.h auto/config.h feature.h os_unix.h \
36153635
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
36163636
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \

src/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ cmdhist.c | command-line history
3333
debugger.c | vim script debugger
3434
diff.c | diff mode (vimdiff)
3535
eval.c | expression evaluation
36+
evalbuffer.c | buffer related built-in functions
3637
evalfunc.c | built-in functions
3738
evalvars.c | vim variables
39+
evalwindow.c | window related built-in functions
3840
fileio.c | reading and writing files
3941
filepath.c | dealing with file names and paths
4042
findfile.c | search for files in 'path'

src/buffer.c

-105
Original file line numberDiff line numberDiff line change
@@ -5450,66 +5450,6 @@ buf_spname(buf_T *buf)
54505450
return NULL;
54515451
}
54525452

5453-
#if defined(FEAT_JOB_CHANNEL) \
5454-
|| defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \
5455-
|| defined(PROTO)
5456-
/*
5457-
* Find a window for buffer "buf".
5458-
* If found OK is returned and "wp" and "tp" are set to the window and tabpage.
5459-
* If not found FAIL is returned.
5460-
*/
5461-
static int
5462-
find_win_for_buf(
5463-
buf_T *buf,
5464-
win_T **wp,
5465-
tabpage_T **tp)
5466-
{
5467-
FOR_ALL_TAB_WINDOWS(*tp, *wp)
5468-
if ((*wp)->w_buffer == buf)
5469-
goto win_found;
5470-
return FAIL;
5471-
win_found:
5472-
return OK;
5473-
}
5474-
5475-
/*
5476-
* Find a window that contains "buf" and switch to it.
5477-
* If there is no such window, use the current window and change "curbuf".
5478-
* Caller must initialize save_curbuf to NULL.
5479-
* restore_win_for_buf() MUST be called later!
5480-
*/
5481-
void
5482-
switch_to_win_for_buf(
5483-
buf_T *buf,
5484-
win_T **save_curwinp,
5485-
tabpage_T **save_curtabp,
5486-
bufref_T *save_curbuf)
5487-
{
5488-
win_T *wp;
5489-
tabpage_T *tp;
5490-
5491-
if (find_win_for_buf(buf, &wp, &tp) == FAIL)
5492-
switch_buffer(save_curbuf, buf);
5493-
else if (switch_win(save_curwinp, save_curtabp, wp, tp, TRUE) == FAIL)
5494-
{
5495-
restore_win(*save_curwinp, *save_curtabp, TRUE);
5496-
switch_buffer(save_curbuf, buf);
5497-
}
5498-
}
5499-
5500-
void
5501-
restore_win_for_buf(
5502-
win_T *save_curwin,
5503-
tabpage_T *save_curtab,
5504-
bufref_T *save_curbuf)
5505-
{
5506-
if (save_curbuf->br_buf == NULL)
5507-
restore_win(save_curwin, save_curtab, TRUE);
5508-
else
5509-
restore_buffer(save_curbuf);
5510-
}
5511-
#endif
5512-
55135453
/*
55145454
* Set 'buflisted' for curbuf to "on" and trigger autocommands if it changed.
55155455
*/
@@ -5603,48 +5543,3 @@ wipe_buffer(
56035543
if (!aucmd)
56045544
unblock_autocmds();
56055545
}
5606-
5607-
#if defined(FEAT_EVAL) || defined(PROTO)
5608-
/*
5609-
* Mark references in functions of buffers.
5610-
*/
5611-
int
5612-
set_ref_in_buffers(int copyID)
5613-
{
5614-
int abort = FALSE;
5615-
buf_T *bp;
5616-
5617-
FOR_ALL_BUFFERS(bp)
5618-
{
5619-
listener_T *lnr;
5620-
typval_T tv;
5621-
5622-
for (lnr = bp->b_listener; !abort && lnr != NULL; lnr = lnr->lr_next)
5623-
{
5624-
if (lnr->lr_callback.cb_partial != NULL)
5625-
{
5626-
tv.v_type = VAR_PARTIAL;
5627-
tv.vval.v_partial = lnr->lr_callback.cb_partial;
5628-
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
5629-
}
5630-
}
5631-
# ifdef FEAT_JOB_CHANNEL
5632-
if (!abort && bp->b_prompt_callback.cb_partial != NULL)
5633-
{
5634-
tv.v_type = VAR_PARTIAL;
5635-
tv.vval.v_partial = bp->b_prompt_callback.cb_partial;
5636-
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
5637-
}
5638-
if (!abort && bp->b_prompt_interrupt.cb_partial != NULL)
5639-
{
5640-
tv.v_type = VAR_PARTIAL;
5641-
tv.vval.v_partial = bp->b_prompt_interrupt.cb_partial;
5642-
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
5643-
}
5644-
# endif
5645-
if (abort)
5646-
break;
5647-
}
5648-
return abort;
5649-
}
5650-
#endif

src/channel.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ prepare_buffer(buf_T *buf)
10361036
* Returns NULL if there is something very wrong (error already reported).
10371037
*/
10381038
static buf_T *
1039-
find_buffer(char_u *name, int err, int msg)
1039+
channel_find_buffer(char_u *name, int err, int msg)
10401040
{
10411041
buf_T *buf = NULL;
10421042
buf_T *save_curbuf = curbuf;
@@ -1126,7 +1126,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
11261126

11271127
if (opt->jo_set2 & JO2_OUT_MSG)
11281128
msg = opt->jo_message[PART_OUT];
1129-
buf = find_buffer(opt->jo_io_name[PART_OUT], FALSE, msg);
1129+
buf = channel_find_buffer(opt->jo_io_name[PART_OUT], FALSE, msg);
11301130
}
11311131
if (buf != NULL)
11321132
{
@@ -1173,7 +1173,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
11731173

11741174
if (opt->jo_set2 & JO2_ERR_MSG)
11751175
msg = opt->jo_message[PART_ERR];
1176-
buf = find_buffer(opt->jo_io_name[PART_ERR], TRUE, msg);
1176+
buf = channel_find_buffer(opt->jo_io_name[PART_ERR], TRUE, msg);
11771177
}
11781178
if (buf != NULL)
11791179
{

0 commit comments

Comments
 (0)