patch 8.1.2077: the ops.c file is too big

Problem:    The ops.c file is too big.
Solution:   Move code for dealing with registers to a new file. (Yegappan
            Lakshmanan, closes #4982)
This commit is contained in:
Bram Moolenaar
2019-09-25 22:37:17 +02:00
parent e0d749a496
commit 4aea03eb87
14 changed files with 3153 additions and 3180 deletions

View File

@ -100,6 +100,7 @@ SRC_ALL = \
src/regexp_bt.c \
src/regexp_nfa.c \
src/regexp.h \
src/register.c \
src/scriptfile.c \
src/screen.c \
src/search.c \
@ -244,6 +245,7 @@ SRC_ALL = \
src/proto/profiler.pro \
src/proto/quickfix.pro \
src/proto/regexp.pro \
src/proto/register.pro \
src/proto/scriptfile.pro \
src/proto/screen.pro \
src/proto/search.pro \

View File

@ -769,6 +769,7 @@ OBJ = \
$(OUTDIR)/profiler.o \
$(OUTDIR)/quickfix.o \
$(OUTDIR)/regexp.o \
$(OUTDIR)/register.o \
$(OUTDIR)/scriptfile.o \
$(OUTDIR)/screen.o \
$(OUTDIR)/search.o \
@ -1186,6 +1187,9 @@ $(OUTDIR)/os_win32.o: os_win32.c $(INCL) $(MZSCHEME_INCL)
$(OUTDIR)/regexp.o: regexp.c regexp_bt.c regexp_nfa.c $(INCL)
$(CC) -c $(CFLAGS) regexp.c -o $@
$(OUTDIR)/register.o: register.c $(INCL)
$(CC) -c $(CFLAGS) register.c -o $@
$(OUTDIR)/terminal.o: terminal.c $(INCL) $(TERM_DEPS)
$(CC) -c $(CFLAGS) terminal.c -o $@

View File

@ -85,6 +85,7 @@ SRC = arabic.c \
profiler.c \
quickfix.c \
regexp.c \
register.c \
scriptfile.c \
screen.c \
search.c \

View File

@ -776,6 +776,7 @@ OBJ = \
$(OUTDIR)\profiler.obj \
$(OUTDIR)\quickfix.obj \
$(OUTDIR)\regexp.obj \
$(OUTDIR)\register.obj \
$(OUTDIR)\scriptfile.obj \
$(OUTDIR)\screen.obj \
$(OUTDIR)\search.obj \
@ -1651,6 +1652,8 @@ $(OUTDIR)/quickfix.obj: $(OUTDIR) quickfix.c $(INCL)
$(OUTDIR)/regexp.obj: $(OUTDIR) regexp.c regexp_bt.c regexp_nfa.c $(INCL)
$(OUTDIR)/register.obj: $(OUTDIR) register.c $(INCL)
$(OUTDIR)/scriptfile.obj: $(OUTDIR) scriptfile.c $(INCL)
$(OUTDIR)/screen.obj: $(OUTDIR) screen.c $(INCL)
@ -1840,6 +1843,7 @@ proto.h: \
proto/profiler.pro \
proto/quickfix.pro \
proto/regexp.pro \
proto/register.pro \
proto/scriptfile.pro \
proto/screen.pro \
proto/search.pro \

View File

@ -319,7 +319,7 @@ SRC = arabic.c arglist.c autocmd.c beval.c blob.c blowfish.c buffer.c \
memfile.c memline.c message.c misc1.c misc2.c mouse.c move.c normal.c \
ops.c \
option.c optionstr.c popupmnu.c popupwin.c profiler.c quickfix.c \
regexp.c scriptfile.c \
regexp.c register.c scriptfile.c \
search.c session.c sha256.c sign.c spell.c spellfile.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 screen.c window.c os_unix.c os_vms.c \
@ -340,7 +340,7 @@ OBJ = arabic.obj arglist.obj autocmd.obj beval.obj blob.obj blowfish.obj \
misc1.obj misc2.obj mouse.obj move.obj mbyte.obj normal.obj ops.obj \
option.obj \
optionstr.obj popupmnu.obj popupwin.obj profiler.obj quickfix.obj \
regexp.obj scriptfile.obj \
regexp.obj register.obj scriptfile.obj \
search.obj session.obj sha256.obj sign.obj spell.obj spellfile.obj \
syntax.obj tag.obj term.obj termlib.obj testing.obj textprop.obj \
ui.obj undo.obj usercmd.obj userfunc.obj screen.obj version.obj \
@ -755,6 +755,10 @@ regexp.obj : regexp.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
register.obj : register.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
scriptfile.obj : scriptfile.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 \

View File

@ -1644,6 +1644,7 @@ BASIC_SRC = \
pty.c \
quickfix.c \
regexp.c \
register.c \
scriptfile.c \
screen.c \
search.c \
@ -1778,6 +1779,7 @@ OBJ_COMMON = \
objects/pty.o \
objects/quickfix.o \
objects/regexp.o \
objects/register.o \
objects/scriptfile.o \
objects/screen.o \
objects/search.o \
@ -1937,6 +1939,7 @@ PRO_AUTO = \
pty.pro \
quickfix.pro \
regexp.pro \
register.pro \
scriptfile.pro \
screen.pro \
search.pro \
@ -3353,6 +3356,9 @@ objects/quickfix.o: quickfix.c
objects/regexp.o: regexp.c regexp_bt.c regexp_nfa.c
$(CCC) -o $@ regexp.c
objects/register.o: register.c
$(CCC) -o $@ register.c
objects/scriptfile.o: scriptfile.c
$(CCC) -o $@ scriptfile.c
@ -3835,6 +3841,10 @@ objects/regexp.o: regexp.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 regexp_bt.c regexp_nfa.c
objects/register.o: register.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/scriptfile.o: scriptfile.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 \

View File

@ -63,6 +63,7 @@ popupwin.c | popup window
profiler.c | vim script profiler
quickfix.c | quickfix commands (":make", ":cn")
regexp.c | pattern matching
register.c | handling registers
scriptfile.c | runtime directory handling and sourcing scripts
screen.c | lower level screen functions
search.c | pattern searching

3097
src/ops.c

File diff suppressed because it is too large Load Diff

View File

@ -188,6 +188,7 @@ void qsort(void *base, size_t elm_count, size_t elm_size, int (*cmp)(const void
# endif
# include "quickfix.pro"
# include "regexp.pro"
# include "register.pro"
# include "scriptfile.pro"
# include "screen.pro"
# include "session.pro"

View File

@ -1,8 +1,4 @@
/* ops.c */
yankreg_T *get_y_regs(void);
yankreg_T *get_y_current(void);
yankreg_T *get_y_previous(void);
void set_y_previous(yankreg_T *yreg);
int get_op_type(int char1, int char2);
int op_on_lines(int op);
int op_is_change(int op);
@ -11,38 +7,15 @@ int get_extra_op_char(int optype);
void op_shift(oparg_T *oap, int curs_top, int amount);
void shift_line(int left, int round, int amount, int call_changed_bytes);
void op_reindent(oparg_T *oap, int (*how)(void));
int get_expr_register(void);
void set_expr_line(char_u *new_line);
char_u *get_expr_line(void);
int valid_yank_reg(int regname, int writing);
int get_yank_register(int regname, int writing);
int may_get_selection(int regname);
void *get_register(int name, int copy);
void put_register(int name, void *reg);
void free_register(void *reg);
int yank_register_mline(int regname);
int do_record(int c);
int get_execreg_lastc(void);
void set_execreg_lastc(int lastc);
int do_execreg(int regname, int colon, int addcr, int silent);
int insert_reg(int regname, int literally_arg);
int get_spec_reg(int regname, char_u **argp, int *allocated, int errmsg);
int cmdline_paste_reg(int regname, int literally_arg, int remcr);
void adjust_clip_reg(int *rp);
void shift_delete_registers(void);
void stuffescaped(char_u *arg, int literally);
int op_delete(oparg_T *oap);
int op_replace(oparg_T *oap, int c);
void op_tilde(oparg_T *oap);
int swapchar(int op_type, pos_T *pos);
void op_insert(oparg_T *oap, long count1);
int op_change(oparg_T *oap);
void init_yank(void);
void clear_registers(void);
int op_yank(oparg_T *oap, int deleting, int mess);
void do_put(int regname, int dir, long count, int flags);
void adjust_cursor_eol(void);
int get_register_name(int num);
void ex_display(exarg_T *eap);
int preprocs_left(void);
char_u *skip_comment(char_u *line, int process, int include_space, int *is_comment);
int do_join(long count, int insert_space, int save_undo, int use_formatoptions, int setmark);
void op_format(oparg_T *oap, int keep_cursor);
@ -50,18 +23,9 @@ void op_formatexpr(oparg_T *oap);
int fex_format(linenr_T lnum, long count, int c);
void format_lines(linenr_T line_count, int avoid_fex);
int paragraph_start(linenr_T lnum);
void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, int is_del);
void op_addsub(oparg_T *oap, linenr_T Prenum1, int g_cmd);
void x11_export_final_selection(void);
void clip_free_selection(Clipboard_T *cbd);
void clip_get_selection(Clipboard_T *cbd);
void clip_yank_selection(int type, char_u *str, long len, Clipboard_T *cbd);
int clip_convert_selection(char_u **str, long_u *len, Clipboard_T *cbd);
void dnd_yank_drag_data(char_u *str, long len);
char_u get_reg_type(int regname, long *reglen);
char_u *get_reg_contents(int regname, int flags);
void write_reg_contents(int name, char_u *str, int maxlen, int must_append);
void write_reg_contents_lst(int name, char_u **strings, int maxlen, int must_append, int yank_type, long block_len);
void write_reg_contents_ex(int name, char_u *str, int maxlen, int must_append, int yank_type, long block_len);
void clear_oparg(oparg_T *oap);
void cursor_pos_info(dict_T *dict);
/* vim: set ft=c : */

42
src/proto/register.pro Normal file
View File

@ -0,0 +1,42 @@
/* register.c */
yankreg_T *get_y_regs(void);
yankreg_T *get_y_current(void);
yankreg_T *get_y_previous(void);
void set_y_previous(yankreg_T *yreg);
int get_expr_register(void);
void set_expr_line(char_u *new_line);
char_u *get_expr_line(void);
int valid_yank_reg(int regname, int writing);
int get_yank_register(int regname, int writing);
int may_get_selection(int regname);
void *get_register(int name, int copy);
void put_register(int name, void *reg);
void free_register(void *reg);
int yank_register_mline(int regname);
int do_record(int c);
int get_execreg_lastc(void);
void set_execreg_lastc(int lastc);
int do_execreg(int regname, int colon, int addcr, int silent);
int insert_reg(int regname, int literally_arg);
int get_spec_reg(int regname, char_u **argp, int *allocated, int errmsg);
int cmdline_paste_reg(int regname, int literally_arg, int remcr);
void adjust_clip_reg(int *rp);
void shift_delete_registers(void);
void yank_do_autocmd(oparg_T *oap, yankreg_T *reg);
void init_yank(void);
void clear_registers(void);
int op_yank(oparg_T *oap, int deleting, int mess);
void do_put(int regname, int dir, long count, int flags);
int get_register_name(int num);
void ex_display(exarg_T *eap);
void clip_free_selection(Clipboard_T *cbd);
void clip_get_selection(Clipboard_T *cbd);
void clip_yank_selection(int type, char_u *str, long len, Clipboard_T *cbd);
int clip_convert_selection(char_u **str, long_u *len, Clipboard_T *cbd);
void dnd_yank_drag_data(char_u *str, long len);
char_u get_reg_type(int regname, long *reglen);
char_u *get_reg_contents(int regname, int flags);
void write_reg_contents(int name, char_u *str, int maxlen, int must_append);
void write_reg_contents_lst(int name, char_u **strings, int maxlen, int must_append, int yank_type, long block_len);
void write_reg_contents_ex(int name, char_u *str, int maxlen, int must_append, int yank_type, long block_len);
/* vim: set ft=c : */

3007
src/register.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -587,23 +587,23 @@ typedef struct expand
*/
typedef struct
{
char_u *cmdbuff; /* pointer to command line buffer */
int cmdbufflen; /* length of cmdbuff */
int cmdlen; /* number of chars in command line */
int cmdpos; /* current cursor position */
int cmdspos; /* cursor column on screen */
int cmdfirstc; /* ':', '/', '?', '=', '>' or NUL */
int cmdindent; /* number of spaces before cmdline */
char_u *cmdprompt; /* message in front of cmdline */
int cmdattr; /* attributes for prompt */
int overstrike; /* Typing mode on the command line. Shared by
getcmdline() and put_on_cmdline(). */
expand_T *xpc; /* struct being used for expansion, xp_pattern
may point into cmdbuff */
int xp_context; /* type of expansion */
char_u *cmdbuff; // pointer to command line buffer
int cmdbufflen; // length of cmdbuff
int cmdlen; // number of chars in command line
int cmdpos; // current cursor position
int cmdspos; // cursor column on screen
int cmdfirstc; // ':', '/', '?', '=', '>' or NUL
int cmdindent; // number of spaces before cmdline
char_u *cmdprompt; // message in front of cmdline
int cmdattr; // attributes for prompt
int overstrike; // Typing mode on the command line. Shared by
// getcmdline() and put_on_cmdline().
expand_T *xpc; // struct being used for expansion, xp_pattern
// may point into cmdbuff
int xp_context; // type of expansion
# ifdef FEAT_EVAL
char_u *xp_arg; /* user-defined expansion arg */
int input_fn; /* when TRUE Invoked for input() function */
char_u *xp_arg; // user-defined expansion arg
int input_fn; // when TRUE Invoked for input() function
# endif
} cmdline_info_T;
@ -1150,10 +1150,10 @@ typedef struct
*/
typedef struct hist_entry
{
int hisnum; /* identifying number */
int viminfo; /* when TRUE hisstr comes from viminfo */
char_u *hisstr; /* actual entry, separator char after the NUL */
time_t time_set; /* when it was typed, zero if unknown */
int hisnum; // identifying number
int viminfo; // when TRUE hisstr comes from viminfo
char_u *hisstr; // actual entry, separator char after the NUL
time_t time_set; // when it was typed, zero if unknown
} histentry_T;
#define CONV_NONE 0
@ -1579,23 +1579,23 @@ typedef struct scriptitem_S
ino_t sn_ino;
# endif
# ifdef FEAT_PROFILE
int sn_prof_on; /* TRUE when script is/was profiled */
int sn_pr_force; /* forceit: profile functions in this script */
proftime_T sn_pr_child; /* time set when going into first child */
int sn_pr_nest; /* nesting for sn_pr_child */
/* profiling the script as a whole */
int sn_pr_count; /* nr of times sourced */
proftime_T sn_pr_total; /* time spent in script + children */
proftime_T sn_pr_self; /* time spent in script itself */
proftime_T sn_pr_start; /* time at script start */
proftime_T sn_pr_children; /* time in children after script start */
/* profiling the script per line */
garray_T sn_prl_ga; /* things stored for every line */
proftime_T sn_prl_start; /* start time for current line */
proftime_T sn_prl_children; /* time spent in children for this line */
proftime_T sn_prl_wait; /* wait start time for current line */
int sn_prl_idx; /* index of line being timed; -1 if none */
int sn_prl_execed; /* line being timed was executed */
int sn_prof_on; // TRUE when script is/was profiled
int sn_pr_force; // forceit: profile functions in this script
proftime_T sn_pr_child; // time set when going into first child
int sn_pr_nest; // nesting for sn_pr_child
// profiling the script as a whole
int sn_pr_count; // nr of times sourced
proftime_T sn_pr_total; // time spent in script + children
proftime_T sn_pr_self; // time spent in script itself
proftime_T sn_pr_start; // time at script start
proftime_T sn_pr_children; // time in children after script start
// profiling the script per line
garray_T sn_prl_ga; // things stored for every line
proftime_T sn_prl_start; // start time for current line
proftime_T sn_prl_children; // time spent in children for this line
proftime_T sn_prl_wait; // wait start time for current line
int sn_prl_idx; // index of line being timed; -1 if none
int sn_prl_execed; // line being timed was executed
# endif
} scriptitem_T;
@ -1603,9 +1603,9 @@ typedef struct scriptitem_S
/* Struct used in sn_prl_ga for every line of a script. */
typedef struct sn_prl_S
{
int snp_count; /* nr of times line was executed */
proftime_T sn_prl_total; /* time spent in a line + children */
proftime_T sn_prl_self; /* time spent in a line itself */
int snp_count; // nr of times line was executed
proftime_T sn_prl_total; // time spent in a line + children
proftime_T sn_prl_self; // time spent in a line itself
} sn_prl_T;
# define PRL_ITEM(si, idx) (((sn_prl_T *)(si)->sn_prl_ga.ga_data)[(idx)])
@ -2345,7 +2345,7 @@ struct file_buffer
garray_T b_ucmds;
// start and end of an operator, also used for '[ and ']
pos_T b_op_start;
pos_T b_op_start_orig; /* used for Insstart_orig */
pos_T b_op_start_orig; // used for Insstart_orig
pos_T b_op_end;
#ifdef FEAT_VIMINFO
@ -3223,8 +3223,8 @@ struct window_S
long w_scbind_pos;
#ifdef FEAT_EVAL
dictitem_T w_winvar; /* variable for "w:" Dictionary */
dict_T *w_vars; /* internal variables, local to window */
dictitem_T w_winvar; // variable for "w:" Dictionary
dict_T *w_vars; // internal variables, local to window
#endif
/*
@ -3793,9 +3793,9 @@ typedef enum {
// Variable flavor
typedef enum
{
VAR_FLAVOUR_DEFAULT, /* doesn't start with uppercase */
VAR_FLAVOUR_SESSION, /* starts with uppercase, some lower */
VAR_FLAVOUR_VIMINFO /* all uppercase */
VAR_FLAVOUR_DEFAULT, // doesn't start with uppercase
VAR_FLAVOUR_SESSION, // starts with uppercase, some lower
VAR_FLAVOUR_VIMINFO // all uppercase
} var_flavour_T;
// argument for mouse_find_win()
@ -3829,6 +3829,26 @@ typedef enum {
# define NUM_REGISTERS 37
#endif
// structure used by block_prep, op_delete and op_yank for blockwise operators
// also op_change, op_shift, op_insert, op_replace - AKelly
struct block_def
{
int startspaces; // 'extra' cols before first char
int endspaces; // 'extra' cols after last char
int textlen; // chars in block
char_u *textstart; // pointer to 1st char (partially) in block
colnr_T textcol; // index of chars (partially) in block
colnr_T start_vcol; // start col of 1st char wholly inside block
colnr_T end_vcol; // start col of 1st char wholly after block
int is_short; // TRUE if line is too short to fit in block
int is_MAX; // TRUE if curswant==MAXCOL when starting
int is_oneChar; // TRUE if block within one character
int pre_whitesp; // screen cols of ws before block
int pre_whitesp_c; // chars of ws before block
colnr_T end_char_vcols; // number of vcols of post-block char
colnr_T start_char_vcols; // number of vcols of pre-block char
};
// Each yank register has an array of pointers to lines.
typedef struct
{

View File

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