0
0
mirror of https://github.com/vim/vim.git synced 2025-10-02 05:04:20 -04:00

patch 8.1.2094: the fileio.c file is too big

Problem:    The fileio.c file is too big.
Solution:   Move buf_write() to bufwrite.c. (Yegappan Lakshmanan,
            closes #4990)
This commit is contained in:
Bram Moolenaar
2019-09-28 16:30:04 +02:00
parent 9be0e0b9d3
commit 473952e852
15 changed files with 2849 additions and 2799 deletions

View File

@@ -21,6 +21,7 @@ SRC_ALL = \
src/blob.c \ src/blob.c \
src/blowfish.c \ src/blowfish.c \
src/buffer.c \ src/buffer.c \
src/bufwrite.c \
src/change.c \ src/change.c \
src/channel.c \ src/channel.c \
src/charset.c \ src/charset.c \
@@ -186,6 +187,7 @@ SRC_ALL = \
src/proto/blob.pro \ src/proto/blob.pro \
src/proto/blowfish.pro \ src/proto/blowfish.pro \
src/proto/buffer.pro \ src/proto/buffer.pro \
src/proto/bufwrite.pro \
src/proto/change.pro \ src/proto/change.pro \
src/proto/channel.pro \ src/proto/channel.pro \
src/proto/charset.pro \ src/proto/charset.pro \

View File

@@ -709,6 +709,7 @@ OBJ = \
$(OUTDIR)/blob.o \ $(OUTDIR)/blob.o \
$(OUTDIR)/blowfish.o \ $(OUTDIR)/blowfish.o \
$(OUTDIR)/buffer.o \ $(OUTDIR)/buffer.o \
$(OUTDIR)/bufwrite.o \
$(OUTDIR)/change.o \ $(OUTDIR)/change.o \
$(OUTDIR)/charset.o \ $(OUTDIR)/charset.o \
$(OUTDIR)/cmdexpand.o \ $(OUTDIR)/cmdexpand.o \

View File

@@ -29,6 +29,7 @@ SRC = arabic.c \
autocmd.c \ autocmd.c \
blowfish.c \ blowfish.c \
buffer.c \ buffer.c \
bufwrite.c \
change.c \ change.c \
charset.c \ charset.c \
cmdexpand.c \ cmdexpand.c \

View File

@@ -716,6 +716,7 @@ OBJ = \
$(OUTDIR)\blob.obj \ $(OUTDIR)\blob.obj \
$(OUTDIR)\blowfish.obj \ $(OUTDIR)\blowfish.obj \
$(OUTDIR)\buffer.obj \ $(OUTDIR)\buffer.obj \
$(OUTDIR)\bufwrite.obj \
$(OUTDIR)\change.obj \ $(OUTDIR)\change.obj \
$(OUTDIR)\charset.obj \ $(OUTDIR)\charset.obj \
$(OUTDIR)\cmdexpand.obj \ $(OUTDIR)\cmdexpand.obj \
@@ -1457,6 +1458,8 @@ $(OUTDIR)/blowfish.obj: $(OUTDIR) blowfish.c $(INCL)
$(OUTDIR)/buffer.obj: $(OUTDIR) buffer.c $(INCL) $(OUTDIR)/buffer.obj: $(OUTDIR) buffer.c $(INCL)
$(OUTDIR)/bufwrite.obj: $(OUTDIR) bufwrite.c $(INCL)
$(OUTDIR)/change.obj: $(OUTDIR) change.c $(INCL) $(OUTDIR)/change.obj: $(OUTDIR) change.c $(INCL)
$(OUTDIR)/charset.obj: $(OUTDIR) charset.c $(INCL) $(OUTDIR)/charset.obj: $(OUTDIR) charset.c $(INCL)
@@ -1788,6 +1791,7 @@ proto.h: \
proto/blob.pro \ proto/blob.pro \
proto/blowfish.pro \ proto/blowfish.pro \
proto/buffer.pro \ proto/buffer.pro \
proto/bufwrite.pro \
proto/change.pro \ proto/change.pro \
proto/charset.pro \ proto/charset.pro \
proto/cmdexpand.pro \ proto/cmdexpand.pro \

View File

@@ -2,7 +2,7 @@
# Makefile for Vim on OpenVMS # Makefile for Vim on OpenVMS
# #
# Maintainer: Zoltan Arpadffy <arpadffy@polarhome.com> # Maintainer: Zoltan Arpadffy <arpadffy@polarhome.com>
# Last change: 2019 Sep 27 # Last change: 2019 Sep 28
# #
# This has script been tested on VMS 6.2 to 8.2 on DEC Alpha, VAX and IA64 # This has script been tested on VMS 6.2 to 8.2 on DEC Alpha, VAX and IA64
# with MMS and MMK # with MMS and MMK
@@ -307,48 +307,210 @@ ALL_CFLAGS_VER = /def=($(MODEL_DEF)$(DEFS)$(DEBUG_DEF)$(PERL_DEF)$(PYTHON_DEF) -
ALL_LIBS = $(LIBS) $(GUI_LIB_DIR) $(GUI_LIB) \ ALL_LIBS = $(LIBS) $(GUI_LIB_DIR) $(GUI_LIB) \
$(PERL_LIB) $(PYTHON_LIB) $(TCL_LIB) $(RUBY_LIB) $(PERL_LIB) $(PYTHON_LIB) $(TCL_LIB) $(RUBY_LIB)
SRC = arabic.c arglist.c autocmd.c beval.c blob.c blowfish.c buffer.c \ SRC = \
change.c charset.c cmdexpand.c cmdhist.c crypt.c crypt_zip.c \ arabic.c \
debugger.c dict.c diff.c digraph.c drawline.c drawscreen.c edit.c \ arglist.c \
eval.c evalbuffer.c evalfunc.c \ autocmd.c \
evalvars.c evalwindow.c ex_cmds.c ex_cmds2.c ex_docmd.c ex_eval.c \ beval.c \
blob.c \
blowfish.c \
buffer.c \
bufwrite.c \
change.c \
charset.c \
cmdexpand.c \
cmdhist.c \
crypt.c \
crypt_zip.c \
debugger.c \
dict.c \
diff.c \
digraph.c \
drawline.c \
drawscreen.c \
edit.c \
eval.c \
evalbuffer.c \
evalfunc.c \
evalvars.c \
evalwindow.c \
ex_cmds.c \
ex_cmds2.c \
ex_docmd.c \
ex_eval.c \
ex_getln.c \ ex_getln.c \
if_cscope.c if_xcmdsrv.c fileio.c filepath.c, findfile.c fold.c \ fileio.c \
getchar.c hardcopy.c hashtab.c highlight.c \ filepath.c, \
indent.c insexpand.c json.c list.c main.c map.c mark.c menu.c mbyte.c \ findfile.c \
memfile.c memline.c message.c misc1.c misc2.c mouse.c move.c normal.c \ fold.c \
getchar.c \
hardcopy.c \
hashtab.c \
highlight.c \
if_cscope.c \
if_xcmdsrv.c \
indent.c \
insexpand.c \
json.c \
list.c \
main.c \
map.c \
mark.c \
mbyte.c \
memfile.c \
memline.c \
menu.c \
message.c \
misc1.c \
misc2.c \
mouse.c \
move.c \
normal.c \
ops.c \ ops.c \
option.c optionstr.c popupmenu.c popupwin.c profiler.c quickfix.c \ option.c \
regexp.c register.c scriptfile.c \ optionstr.c \
search.c session.c sha256.c sign.c spell.c spellfile.c spellsuggest.c \ os_unix.c \
syntax.c tag.c \ os_vms.c \
term.c termlib.c testing.c textprop.c ui.c undo.c usercmd.c \
userfunc.c version.c viminfo.c screen.c window.c os_unix.c os_vms.c \
pathdef.c \ pathdef.c \
$(GUI_SRC) $(PERL_SRC) $(PYTHON_SRC) $(TCL_SRC) \ popupmenu.c \
$(RUBY_SRC) $(HANGULIN_SRC) $(MZSCH_SRC) $(XDIFF_SRC) popupwin.c \
profiler.c \
quickfix.c \
regexp.c \
register.c \
screen.c \
scriptfile.c \
search.c \
session.c \
sha256.c \
sign.c \
spell.c \
spellfile.c \
spellsuggest.c \
syntax.c \
tag.c \
term.c \
termlib.c \
testing.c \
textprop.c \
ui.c \
undo.c \
usercmd.c \
userfunc.c \
version.c \
viminfo.c \
window.c \
$(GUI_SRC) \
$(PERL_SRC) \
$(PYTHON_SRC) \
$(TCL_SRC) \
$(RUBY_SRC) \
$(HANGULIN_SRC) \
$(MZSCH_SRC) \
$(XDIFF_SRC)
OBJ = arabic.obj arglist.obj autocmd.obj beval.obj blob.obj blowfish.obj \ OBJ = \
buffer.obj change.obj charset.obj cmdexpand.obj cmdhist.obj \ arabic.obj \
crypt.obj crypt_zip.obj debugger.obj dict.obj diff.obj digraph.obj \ arglist.obj \
drawline.obj drawscreen.obj edit.obj eval.obj evalbuffer.obj \ autocmd.obj \
evalfunc.obj evalvars.obj evalwindow.obj ex_cmds.obj ex_cmds2.obj \ beval.obj \
ex_docmd.obj ex_eval.obj ex_getln.obj if_cscope.obj if_xcmdsrv.obj \ blob.obj \
fileio.obj filepath.obj \ blowfish.obj \
findfile.obj fold.obj getchar.obj hardcopy.obj hashtab.obj \ buffer.obj \
highlight.obj indent.obj insexpand.obj json.obj list.obj main.obj \ bufwrite.obj \
map.obj mark.obj menu.obj memfile.obj memline.obj message.obj \ change.obj \
misc1.obj misc2.obj mouse.obj move.obj mbyte.obj normal.obj ops.obj \ charset.obj \
cmdexpand.obj \
cmdhist.obj \
crypt.obj \
crypt_zip.obj \
debugger.obj \
dict.obj \
diff.obj \
digraph.obj \
drawline.obj \
drawscreen.obj \
edit.obj \
eval.obj \
evalbuffer.obj \
evalfunc.obj \
evalvars.obj \
evalwindow.obj \
ex_cmds.obj \
ex_cmds2.obj \
ex_docmd.obj \
ex_eval.obj \
ex_getln.obj \
fileio.obj \
filepath.obj \
findfile.obj \
fold.obj \
getchar.obj \
hardcopy.obj \
hashtab.obj \
highlight.obj \
if_cscope.obj \
if_mzsch.obj \
if_xcmdsrv.obj \
indent.obj \
insexpand.obj \
json.obj \
list.obj \
main.obj \
map.obj \
mark.obj \
mbyte.obj \
memfile.obj \
memline.obj \
menu.obj \
message.obj \
misc1.obj \
misc2.obj \
mouse.obj \
move.obj \
normal.obj \
ops.obj \
option.obj \ option.obj \
optionstr.obj popupmenu.obj popupwin.obj profiler.obj quickfix.obj \ optionstr.obj \
regexp.obj register.obj scriptfile.obj \ os_unix.obj \
search.obj session.obj sha256.obj sign.obj spell.obj spellfile.obj \ os_vms.obj \
spellsuggest.obj syntax.obj tag.obj term.obj termlib.obj testing.obj \ pathdef.obj \
popupmenu.obj \
popupwin.obj \
profiler.obj \
quickfix.obj \
regexp.obj \
register.obj \
screen.obj \
scriptfile.obj \
search.obj \
session.obj \
sha256.obj \
sign.obj \
spell.obj \
spellfile.obj \
spellsuggest.obj \
syntax.obj \
tag.obj \
term.obj \
termlib.obj \
testing.obj \
textprop.obj \ textprop.obj \
ui.obj undo.obj usercmd.obj userfunc.obj screen.obj version.obj \ ui.obj \
viminfo.obj window.obj os_unix.obj os_vms.obj pathdef.obj if_mzsch.obj \ undo.obj \
$(GUI_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(TCL_OBJ) \ usercmd.obj \
$(RUBY_OBJ) $(HANGULIN_OBJ) $(MZSCH_OBJ) $(XDIFF_OBJ) userfunc.obj \
version.obj \
viminfo.obj \
window.obj \
$(GUI_OBJ) \
$(PERL_OBJ) \
$(PYTHON_OBJ) \
$(TCL_OBJ) \
$(RUBY_OBJ) \
$(HANGULIN_OBJ) \
$(MZSCH_OBJ) \
$(XDIFF_OBJ)
# Default target is making the executable # Default target is making the executable
all : [.auto]config.h mmk_compat motif_env gtk_env perl_env python_env tcl_env ruby_env $(TARGET) all : [.auto]config.h mmk_compat motif_env gtk_env perl_env python_env tcl_env ruby_env $(TARGET)
@@ -526,6 +688,10 @@ buffer.obj : buffer.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
globals.h version.h globals.h version.h
bufwrite.obj : bufwrite.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h \
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
globals.h version.h
change.obj : change.c vim.h [.auto]config.h feature.h os_unix.h \ change.obj : change.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h \
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \

View File

@@ -1668,6 +1668,7 @@ BASIC_SRC = \
version.c \ version.c \
viminfo.c \ viminfo.c \
window.c \ window.c \
bufwrite.c \
$(OS_EXTRA_SRC) $(OS_EXTRA_SRC)
SRC = $(BASIC_SRC) \ SRC = $(BASIC_SRC) \
@@ -1804,6 +1805,7 @@ OBJ_COMMON = \
objects/version.o \ objects/version.o \
objects/viminfo.o \ objects/viminfo.o \
objects/window.o \ objects/window.o \
objects/bufwrite.o \
$(GUI_OBJ) \ $(GUI_OBJ) \
$(TERM_OBJ) \ $(TERM_OBJ) \
$(LUA_OBJ) \ $(LUA_OBJ) \
@@ -1966,6 +1968,7 @@ PRO_AUTO = \
version.pro \ version.pro \
viminfo.pro \ viminfo.pro \
window.pro \ window.pro \
bufwrite.pro \
beval.pro \ beval.pro \
gui_beval.pro \ gui_beval.pro \
netbeans.pro \ netbeans.pro \
@@ -3432,6 +3435,9 @@ objects/viminfo.o: viminfo.c
objects/window.o: window.c objects/window.o: window.c
$(CCC) -o $@ window.c $(CCC) -o $@ window.c
objects/bufwrite.o: bufwrite.c
$(CCC) -o $@ bufwrite.c
objects/netbeans.o: netbeans.c objects/netbeans.o: netbeans.c
$(CCC) -o $@ netbeans.c $(CCC) -o $@ netbeans.c
@@ -3949,6 +3955,10 @@ objects/window.o: window.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h proto.h globals.h
objects/bufwrite.o: bufwrite.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h
objects/gui.o: gui.c vim.h protodef.h auto/config.h feature.h os_unix.h \ objects/gui.o: gui.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \

View File

@@ -27,6 +27,7 @@ arglist.c | handling argument list
autocmd.c | autocommands autocmd.c | autocommands
blob.c | blob data type blob.c | blob data type
buffer.c | manipulating buffers (loaded files) buffer.c | manipulating buffers (loaded files)
bufwrite.c | writing a buffer to file
change.c | handling changes to text change.c | handling changes to text
cmdexpand.c | command-line completion cmdexpand.c | command-line completion
cmdhist.c | command-line history cmdhist.c | command-line history

2559
src/bufwrite.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -5530,7 +5530,7 @@ win_copy_options(win_T *wp_from, win_T *wp_to)
* After copying window options: update variables depending on options. * After copying window options: update variables depending on options.
*/ */
void void
after_copy_winopt(win_T *wp) after_copy_winopt(win_T *wp UNUSED)
{ {
#ifdef FEAT_LINEBREAK #ifdef FEAT_LINEBREAK
briopt_check(wp); briopt_check(wp);
@@ -5852,6 +5852,8 @@ buf_copy_options(buf_T *buf, int flags)
#endif #endif
buf->b_p_fo = vim_strsave(p_fo); buf->b_p_fo = vim_strsave(p_fo);
buf->b_p_flp = vim_strsave(p_flp); buf->b_p_flp = vim_strsave(p_flp);
// NOTE: Valgrind may report a bogus memory leak for 'nrformats'
// when it is set to 8 bytes in defaults.vim.
buf->b_p_nf = vim_strsave(p_nf); buf->b_p_nf = vim_strsave(p_nf);
buf->b_p_mps = vim_strsave(p_mps); buf->b_p_mps = vim_strsave(p_mps);
#ifdef FEAT_SMARTINDENT #ifdef FEAT_SMARTINDENT

View File

@@ -64,6 +64,7 @@ extern int _stricoll(char *a, char *b);
# include "arglist.pro" # include "arglist.pro"
# include "autocmd.pro" # include "autocmd.pro"
# include "buffer.pro" # include "buffer.pro"
# include "bufwrite.pro"
# include "change.pro" # include "change.pro"
# include "charset.pro" # include "charset.pro"
# include "cmdexpand.pro" # include "cmdexpand.pro"

4
src/proto/bufwrite.pro Normal file
View File

@@ -0,0 +1,4 @@
/* bufwrite.c */
int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_T end, exarg_T *eap, int append, int forceit, int reset_changed, int filtering);
/* vim: set ft=c : */

View File

@@ -1,14 +1,22 @@
/* fileio.c */ /* fileio.c */
void filemess(buf_T *buf, char_u *name, char_u *s, int attr);
int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_skip, linenr_T lines_to_read, exarg_T *eap, int flags); int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_skip, linenr_T lines_to_read, exarg_T *eap, int flags);
int is_dev_fd_file(char_u *fname); int is_dev_fd_file(char_u *fname);
int prep_exarg(exarg_T *eap, buf_T *buf); int prep_exarg(exarg_T *eap, buf_T *buf);
void set_file_options(int set_options, exarg_T *eap); void set_file_options(int set_options, exarg_T *eap);
void set_forced_fenc(exarg_T *eap); void set_forced_fenc(exarg_T *eap);
int check_file_readonly(char_u *fname, int perm); int check_file_readonly(char_u *fname, int perm);
int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_T end, exarg_T *eap, int append, int forceit, int reset_changed, int filtering);
int vim_fsync(int fd); int vim_fsync(int fd);
int set_rw_fname(char_u *fname, char_u *sfname);
void msg_add_fname(buf_T *buf, char_u *fname); void msg_add_fname(buf_T *buf, char_u *fname);
int msg_add_fileformat(int eol_type);
void msg_add_lines(int insert_space, long lnum, off_T nchars); void msg_add_lines(int insert_space, long lnum, off_T nchars);
void msg_add_eol(void);
int time_differs(long t1, long t2);
int need_conversion(char_u *fenc);
int get_fio_flags(char_u *ptr);
int get_win_fio_flags(char_u *ptr);
int get_mac_fio_flags(char_u *ptr);
char_u *shorten_fname1(char_u *full_path); char_u *shorten_fname1(char_u *full_path);
char_u *shorten_fname(char_u *full_path, char_u *dir_name); char_u *shorten_fname(char_u *full_path, char_u *dir_name);
void shorten_buf_fname(buf_T *buf, char_u *dirname, int force); void shorten_buf_fname(buf_T *buf, char_u *dirname, int force);

View File

@@ -3882,3 +3882,32 @@ typedef struct spat
int no_scs; // no smartcase for this pattern int no_scs; // no smartcase for this pattern
soffset_T off; soffset_T off;
} spat_T; } spat_T;
#define WRITEBUFSIZE 8192 // size of normal write buffer
#define FIO_LATIN1 0x01 // convert Latin1
#define FIO_UTF8 0x02 // convert UTF-8
#define FIO_UCS2 0x04 // convert UCS-2
#define FIO_UCS4 0x08 // convert UCS-4
#define FIO_UTF16 0x10 // convert UTF-16
#ifdef MSWIN
# define FIO_CODEPAGE 0x20 // convert MS-Windows codepage
# define FIO_PUT_CP(x) (((x) & 0xffff) << 16) // put codepage in top word
# define FIO_GET_CP(x) (((x)>>16) & 0xffff) // get codepage from top word
#endif
#ifdef MACOS_CONVERT
# define FIO_MACROMAN 0x20 // convert MacRoman
#endif
#define FIO_ENDIAN_L 0x80 // little endian
#define FIO_ENCRYPTED 0x1000 // encrypt written bytes
#define FIO_NOCONVERT 0x2000 // skip encoding conversion
#define FIO_UCSBOM 0x4000 // check for BOM at start of file
#define FIO_ALL -1 // allow all formats
// When converting, a read() or write() may leave some bytes to be converted
// for the next call. The value is guessed...
#define CONV_RESTLEN 30
// We have to guess how much a sequence of bytes may expand when converting
// with iconv() to be able to allocate a buffer.
#define ICONV_MULT 8

View File

@@ -757,6 +757,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2094,
/**/ /**/
2093, 2093,
/**/ /**/