patch 8.2.1597: the channel source file is too big

Problem:    The channel source file is too big.
Solution:   Move job related code to a new source file.
This commit is contained in:
Bram Moolenaar
2020-09-05 15:48:51 +02:00
parent 7dfc5ce7cf
commit 8b5866ded6
15 changed files with 2002 additions and 1960 deletions

View File

@ -75,6 +75,7 @@ SRC_ALL = \
src/highlight.c \
src/indent.c \
src/insexpand.c \
src/job.c \
src/json.c \
src/json_test.c \
src/kword_test.c \
@ -250,6 +251,7 @@ SRC_ALL = \
src/proto/highlight.pro \
src/proto/indent.pro \
src/proto/insexpand.pro \
src/proto/job.pro \
src/proto/json.pro \
src/proto/list.pro \
src/proto/locale.pro \

View File

@ -870,7 +870,7 @@ OBJ += $(OUTDIR)/netbeans.o
endif
ifeq ($(CHANNEL),yes)
OBJ += $(OUTDIR)/channel.o
OBJ += $(OUTDIR)/job.o $(OUTDIR)/channel.o
LIB += -lwsock32 -lws2_32
endif

View File

@ -471,8 +471,8 @@ SOUND_LIB = winmm.lib
!endif
!if "$(CHANNEL)" == "yes"
CHANNEL_PRO = proto/channel.pro
CHANNEL_OBJ = $(OBJDIR)/channel.obj
CHANNEL_PRO = proto/job.pro proto/channel.pro
CHANNEL_OBJ = $(OBJDIR)/job.obj $(OBJDIR)/channel.obj
CHANNEL_DEFS = -DFEAT_JOB_CHANNEL -DFEAT_IPV6
! if $(WINVER) >= 0x600
CHANNEL_DEFS = $(CHANNEL_DEFS) -DHAVE_INET_NTOP
@ -1673,6 +1673,8 @@ $(OUTDIR)/if_tcl.obj: $(OUTDIR) if_tcl.c $(INCL)
$(OUTDIR)/iscygpty.obj: $(OUTDIR) iscygpty.c $(CUI_INCL)
$(CC) $(CFLAGS_OUTDIR) iscygpty.c -D_WIN32_WINNT=0x0600 -DUSE_DYNFILEID -DENABLE_STUB_IMPL
$(OUTDIR)/job.obj: $(OUTDIR) job.c $(INCL)
$(OUTDIR)/json.obj: $(OUTDIR) json.c $(INCL)
$(OUTDIR)/list.obj: $(OUTDIR) list.c $(INCL)
@ -1703,11 +1705,11 @@ $(OUTDIR)/mouse.obj: $(OUTDIR) mouse.c $(INCL)
$(OUTDIR)/move.obj: $(OUTDIR) move.c $(INCL)
$(OUTDIR)/mbyte.obj: $(OUTDIR) mbyte.c $(INCL)
$(OUTDIR)/mbyte.obj: $(OUTDIR) mbyte.c $(INCL)
$(OUTDIR)/netbeans.obj: $(OUTDIR) netbeans.c $(NBDEBUG_SRC) $(INCL) version.h
$(OUTDIR)/netbeans.obj: $(OUTDIR) netbeans.c $(NBDEBUG_SRC) $(INCL) version.h
$(OUTDIR)/channel.obj: $(OUTDIR) channel.c $(INCL)
$(OUTDIR)/channel.obj: $(OUTDIR) channel.c $(INCL)
$(OUTDIR)/normal.obj: $(OUTDIR) normal.c $(INCL)

View File

@ -1708,7 +1708,7 @@ SRC = $(BASIC_SRC) \
EXTRA_SRC = if_lua.c if_mzsch.c auto/if_perl.c if_perlsfio.c \
if_python.c if_python3.c if_tcl.c if_ruby.c \
gui_beval.c netbeans.c channel.c \
gui_beval.c netbeans.c job.c channel.c \
$(GRESOURCE_SRC)
# Unittest files
@ -1962,6 +1962,7 @@ PRO_AUTO = \
if_xcmdsrv.pro \
indent.pro \
insexpand.pro \
job.pro \
json.pro \
list.pro \
locale.pro \
@ -3352,6 +3353,9 @@ objects/indent.o: indent.c
objects/insexpand.o: insexpand.c
$(CCC) -o $@ insexpand.c
objects/job.o: job.c
$(CCC) -o $@ job.c
objects/json.o: json.c
$(CCC) -o $@ json.c
@ -4200,6 +4204,10 @@ objects/gui_at_fs.o: gui_at_fs.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 errors.h globals.h gui_at_sb.h
objects/job.o: job.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 errors.h globals.h
objects/json_test.o: json_test.c main.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 \

4
src/auto/configure vendored
View File

@ -8006,9 +8006,9 @@ fi
if test "$enable_channel" = "yes"; then
$as_echo "#define FEAT_JOB_CHANNEL 1" >>confdefs.h
CHANNEL_SRC="channel.c"
CHANNEL_SRC="job.c channel.c"
CHANNEL_OBJ="objects/channel.o"
CHANNEL_OBJ="objects/job.o objects/channel.o"
fi

File diff suppressed because it is too large Load Diff

View File

@ -2143,9 +2143,9 @@ if test "$enable_netbeans" = "yes"; then
fi
if test "$enable_channel" = "yes"; then
AC_DEFINE(FEAT_JOB_CHANNEL)
CHANNEL_SRC="channel.c"
CHANNEL_SRC="job.c channel.c"
AC_SUBST(CHANNEL_SRC)
CHANNEL_OBJ="objects/channel.o"
CHANNEL_OBJ="objects/job.o objects/channel.o"
AC_SUBST(CHANNEL_OBJ)
fi

View File

@ -24,9 +24,6 @@ static int compl_busy = FALSE;
static void ins_ctrl_v(void);
#ifdef FEAT_JOB_CHANNEL
static void init_prompt(int cmdchar_todo);
#endif
static void insert_special(int, int, int);
static void redo_literal(int c);
static void start_arrow_common(pos_T *end_insert_pos, int change);
@ -1683,83 +1680,20 @@ edit_putchar(int c, int highlight)
}
}
#if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
/*
* Return the effective prompt for the specified buffer.
* Set the insert start position for when using a prompt buffer.
*/
char_u *
buf_prompt_text(buf_T* buf)
void
set_insstart(linenr_T lnum, int col)
{
if (buf->b_prompt_text == NULL)
return (char_u *)"% ";
return buf->b_prompt_text;
Insstart.lnum = lnum;
Insstart.col = col;
Insstart_orig = Insstart;
Insstart_textlen = Insstart.col;
Insstart_blank_vcol = MAXCOL;
arrow_used = FALSE;
}
/*
* Return the effective prompt for the current buffer.
*/
char_u *
prompt_text(void)
{
return buf_prompt_text(curbuf);
}
/*
* Prepare for prompt mode: Make sure the last line has the prompt text.
* Move the cursor to this line.
*/
static void
init_prompt(int cmdchar_todo)
{
char_u *prompt = prompt_text();
char_u *text;
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
text = ml_get_curline();
if (STRNCMP(text, prompt, STRLEN(prompt)) != 0)
{
// prompt is missing, insert it or append a line with it
if (*text == NUL)
ml_replace(curbuf->b_ml.ml_line_count, prompt, TRUE);
else
ml_append(curbuf->b_ml.ml_line_count, prompt, 0, FALSE);
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
coladvance((colnr_T)MAXCOL);
changed_bytes(curbuf->b_ml.ml_line_count, 0);
}
// Insert always starts after the prompt, allow editing text after it.
if (Insstart_orig.lnum != curwin->w_cursor.lnum
|| Insstart_orig.col != (int)STRLEN(prompt))
{
Insstart.lnum = curwin->w_cursor.lnum;
Insstart.col = (int)STRLEN(prompt);
Insstart_orig = Insstart;
Insstart_textlen = Insstart.col;
Insstart_blank_vcol = MAXCOL;
arrow_used = FALSE;
}
if (cmdchar_todo == 'A')
coladvance((colnr_T)MAXCOL);
if (cmdchar_todo == 'I' || curwin->w_cursor.col <= (int)STRLEN(prompt))
curwin->w_cursor.col = (int)STRLEN(prompt);
// Make sure the cursor is in a valid position.
check_cursor();
}
/*
* Return TRUE if the cursor is in the editable position of the prompt line.
*/
int
prompt_curpos_editable()
{
return curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count
&& curwin->w_cursor.col >= (int)STRLEN(prompt_text());
}
#endif
/*
* Undo the previous edit_putchar().
*/

View File

@ -1902,6 +1902,9 @@ EXTERN int did_repeated_msg INIT(= 0);
// out_flush() when characters have been written.
EXTERN int ch_log_output INIT(= FALSE);
// Whether a redraw is needed for appending a line to a buffer.
EXTERN int channel_need_redraw INIT(= FALSE);
#define FOR_ALL_CHANNELS(ch) \
for ((ch) = first_channel; (ch) != NULL; (ch) = (ch)->ch_next)
#define FOR_ALL_JOBS(job) \

1918
src/job.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -278,6 +278,7 @@ void mbyte_im_set_active(int active_arg);
# include "netbeans.pro"
# endif
# ifdef FEAT_JOB_CHANNEL
# include "job.pro"
# include "channel.pro"
// Not generated automatically, to add extra attribute.

View File

@ -3,13 +3,17 @@ void ch_logfile(char_u *fname, char_u *opt);
int ch_log_active(void);
channel_T *add_channel(void);
int has_any_channel(void);
int channel_still_useful(channel_T *channel);
int channel_can_close(channel_T *channel);
int channel_unref(channel_T *channel);
int free_unused_channels_contents(int copyID, int mask);
void free_unused_channels(int copyID, int mask);
void channel_gui_register_all(void);
channel_T *channel_open(const char *hostname, int port, int waittime, void (*nb_close_cb)(void));
void ch_close_part(channel_T *channel, ch_part_T part);
void channel_set_pipes(channel_T *channel, sock_T in, sock_T out, sock_T err);
void channel_set_job(channel_T *channel, job_T *job, jobopt_T *options);
void channel_write_in(channel_T *channel);
void channel_buffer_free(buf_T *buf);
void channel_write_any_lines(void);
void channel_write_new_lines(buf_T *buf);
@ -36,30 +40,6 @@ int channel_select_check(int ret_in, void *rfds_in, void *wfds_in);
int channel_parse_messages(void);
int channel_any_readahead(void);
int set_ref_in_channel(int copyID);
void clear_job_options(jobopt_T *opt);
int get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2);
void job_free_all(void);
int job_any_running(void);
int win32_build_cmd(list_T *l, garray_T *gap);
void job_cleanup(job_T *job);
int set_ref_in_job(int copyID);
void job_unref(job_T *job);
int free_unused_jobs_contents(int copyID, int mask);
void free_unused_jobs(int copyID, int mask);
job_T *job_alloc(void);
void job_set_options(job_T *job, jobopt_T *opt);
void job_stop_on_exit(void);
int has_pending_job(void);
int job_check_ended(void);
job_T *job_start(typval_T *argvars, char **argv_arg, jobopt_T *opt_arg, job_T **term_job);
char *job_status(job_T *job);
int job_stop(job_T *job, typval_T *argvars, char *type);
void invoke_prompt_callback(void);
int invoke_prompt_interrupt(void);
void f_prompt_getprompt(typval_T *argvars, typval_T *rettv);
void f_prompt_setcallback(typval_T *argvars, typval_T *rettv);
void f_prompt_setinterrupt(typval_T *argvars, typval_T *rettv);
void f_prompt_setprompt(typval_T *argvars, typval_T *rettv);
void f_ch_canread(typval_T *argvars, typval_T *rettv);
void f_ch_close(typval_T *argvars, typval_T *rettv);
void f_ch_close_in(typval_T *argvars, typval_T *rettv);
@ -78,10 +58,4 @@ void f_ch_evalraw(typval_T *argvars, typval_T *rettv);
void f_ch_sendraw(typval_T *argvars, typval_T *rettv);
void f_ch_setoptions(typval_T *argvars, typval_T *rettv);
void f_ch_status(typval_T *argvars, typval_T *rettv);
void f_job_getchannel(typval_T *argvars, typval_T *rettv);
void f_job_info(typval_T *argvars, typval_T *rettv);
void f_job_setoptions(typval_T *argvars, typval_T *rettv);
void f_job_start(typval_T *argvars, typval_T *rettv);
void f_job_status(typval_T *argvars, typval_T *rettv);
void f_job_stop(typval_T *argvars, typval_T *rettv);
/* vim: set ft=c : */

View File

@ -4,9 +4,7 @@ int ins_need_undo_get(void);
void ins_redraw(int ready);
int decodeModifyOtherKeys(int c);
void edit_putchar(int c, int highlight);
char_u *buf_prompt_text(buf_T* buf);
char_u *prompt_text(void);
int prompt_curpos_editable(void);
void set_insstart(linenr_T lnum, int col);
void edit_unputchar(void);
void display_dollar(colnr_T col);
void undisplay_dollar(void);

37
src/proto/job.pro Normal file
View File

@ -0,0 +1,37 @@
/* job.c */
void clear_job_options(jobopt_T *opt);
void free_job_options(jobopt_T *opt);
int get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2);
void job_free_all(void);
int job_any_running(void);
int win32_build_cmd(list_T *l, garray_T *gap);
void job_cleanup(job_T *job);
int set_ref_in_job(int copyID);
void job_unref(job_T *job);
int free_unused_jobs_contents(int copyID, int mask);
void free_unused_jobs(int copyID, int mask);
job_T *job_alloc(void);
void job_set_options(job_T *job, jobopt_T *opt);
void job_stop_on_exit(void);
int has_pending_job(void);
int job_check_ended(void);
job_T *job_start(typval_T *argvars, char **argv_arg, jobopt_T *opt_arg, job_T **term_job);
char *job_status(job_T *job);
int job_stop(job_T *job, typval_T *argvars, char *type);
void invoke_prompt_callback(void);
int invoke_prompt_interrupt(void);
char_u *buf_prompt_text(buf_T *buf);
char_u *prompt_text(void);
void init_prompt(int cmdchar_todo);
int prompt_curpos_editable(void);
void f_prompt_setcallback(typval_T *argvars, typval_T *rettv);
void f_prompt_setinterrupt(typval_T *argvars, typval_T *rettv);
void f_prompt_getprompt(typval_T *argvars, typval_T *rettv);
void f_prompt_setprompt(typval_T *argvars, typval_T *rettv);
void f_job_getchannel(typval_T *argvars, typval_T *rettv);
void f_job_info(typval_T *argvars, typval_T *rettv);
void f_job_setoptions(typval_T *argvars, typval_T *rettv);
void f_job_start(typval_T *argvars, typval_T *rettv);
void f_job_status(typval_T *argvars, typval_T *rettv);
void f_job_stop(typval_T *argvars, typval_T *rettv);
/* vim: set ft=c : */

View File

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