Compare commits

..

4 Commits

Author SHA1 Message Date
620ca2da37 patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Problem:    ch_readraw() waits for NL if channel mode is NL.
Solution:   Pass a "raw" flag to channel_read_block(). (Yasuhiro Matsumoto)
2017-12-09 19:13:13 +01:00
05684310a5 patch 8.0.1380: using "vim -r swapfile" the hit-enter prompt is misplaced.
Problem:    When recovering a file with "vim -r swapfile" the hit-enter prompt
            is at the top of the window.
Solution:   Invalidate the cursor position.
2017-12-09 15:11:24 +01:00
e4b78e2a42 patch 8.0.1379: configure check for selinux does not check for header file
Problem:    Configure check for selinux does not check for header file.
Solution:   Add an AC_CHECK_HEADER(). (Benny Siegert)
2017-12-07 22:29:11 +01:00
3388d33457 patch 8.0.1378: autoload script sources itself when defining function
Problem:    Autoload script sources itself when defining function.
Solution:   Pass TFN_NO_AUTOLOAD to trans_function_name(). (Yasuhiro
            Matsumoto, closes #2423)
2017-12-07 22:23:04 +01:00
11 changed files with 81 additions and 15 deletions

7
src/auto/configure vendored
View File

@ -4781,8 +4781,13 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_is_selinux_enabled" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_is_selinux_enabled" >&5
$as_echo "$ac_cv_lib_selinux_is_selinux_enabled" >&6; } $as_echo "$ac_cv_lib_selinux_is_selinux_enabled" >&6; }
if test "x$ac_cv_lib_selinux_is_selinux_enabled" = xyes; then : if test "x$ac_cv_lib_selinux_is_selinux_enabled" = xyes; then :
ac_fn_c_check_header_mongrel "$LINENO" "selinux/selinux.h" "ac_cv_header_selinux_selinux_h" "$ac_includes_default"
if test "x$ac_cv_header_selinux_selinux_h" = xyes; then :
LIBS="$LIBS -lselinux" LIBS="$LIBS -lselinux"
$as_echo "#define HAVE_SELINUX 1" >>confdefs.h $as_echo "#define HAVE_SELINUX 1" >>confdefs.h
fi
fi fi

View File

@ -3313,11 +3313,12 @@ channel_read(channel_T *channel, ch_part_T part, char *func)
/* /*
* Read from RAW or NL "channel"/"part". Blocks until there is something to * Read from RAW or NL "channel"/"part". Blocks until there is something to
* read or the timeout expires. * read or the timeout expires.
* When "raw" is TRUE don't block waiting on a NL.
* Returns what was read in allocated memory. * Returns what was read in allocated memory.
* Returns NULL in case of error or timeout. * Returns NULL in case of error or timeout.
*/ */
char_u * static char_u *
channel_read_block(channel_T *channel, ch_part_T part, int timeout) channel_read_block(channel_T *channel, ch_part_T part, int timeout, int raw)
{ {
char_u *buf; char_u *buf;
char_u *msg; char_u *msg;
@ -3327,7 +3328,7 @@ channel_read_block(channel_T *channel, ch_part_T part, int timeout)
readq_T *node; readq_T *node;
ch_log(channel, "Blocking %s read, timeout: %d msec", ch_log(channel, "Blocking %s read, timeout: %d msec",
mode == MODE_RAW ? "RAW" : "NL", timeout); mode == MODE_RAW ? "RAW" : "NL", timeout);
while (TRUE) while (TRUE)
{ {
@ -3340,6 +3341,10 @@ channel_read_block(channel_T *channel, ch_part_T part, int timeout)
break; break;
if (channel_collapse(channel, part, mode == MODE_NL) == OK) if (channel_collapse(channel, part, mode == MODE_NL) == OK)
continue; continue;
/* If not blocking or nothing more is coming then return what we
* have. */
if (raw || fd == INVALID_FD)
break;
} }
/* Wait for up to the channel timeout. */ /* Wait for up to the channel timeout. */
@ -3366,11 +3371,16 @@ channel_read_block(channel_T *channel, ch_part_T part, int timeout)
nl = channel_first_nl(node); nl = channel_first_nl(node);
/* Convert NUL to NL, the internal representation. */ /* Convert NUL to NL, the internal representation. */
for (p = buf; p < nl && p < buf + node->rq_buflen; ++p) for (p = buf; (nl == NULL || p < nl) && p < buf + node->rq_buflen; ++p)
if (*p == NUL) if (*p == NUL)
*p = NL; *p = NL;
if (nl + 1 == buf + node->rq_buflen) if (nl == NULL)
{
/* must be a closed channel with missing NL */
msg = channel_get(channel, part);
}
else if (nl + 1 == buf + node->rq_buflen)
{ {
/* get the whole buffer */ /* get the whole buffer */
msg = channel_get(channel, part); msg = channel_get(channel, part);
@ -3513,7 +3523,8 @@ common_channel_read(typval_T *argvars, typval_T *rettv, int raw)
timeout = opt.jo_timeout; timeout = opt.jo_timeout;
if (raw || mode == MODE_RAW || mode == MODE_NL) if (raw || mode == MODE_RAW || mode == MODE_NL)
rettv->vval.v_string = channel_read_block(channel, part, timeout); rettv->vval.v_string = channel_read_block(channel, part,
timeout, raw);
else else
{ {
if (opt.jo_set & JO_ID) if (opt.jo_set & JO_ID)
@ -3955,7 +3966,8 @@ ch_raw_common(typval_T *argvars, typval_T *rettv, int eval)
timeout = opt.jo_timeout; timeout = opt.jo_timeout;
else else
timeout = channel_get_timeout(channel, part_read); timeout = channel_get_timeout(channel, part_read);
rettv->vval.v_string = channel_read_block(channel, part_read, timeout); rettv->vval.v_string = channel_read_block(channel, part_read,
timeout, TRUE);
} }
free_job_options(&opt); free_job_options(&opt);
} }

View File

@ -433,8 +433,9 @@ if test "x$found_smack" = "x"; then
if test "$enable_selinux" = "yes"; then if test "$enable_selinux" = "yes"; then
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
AC_CHECK_LIB(selinux, is_selinux_enabled, AC_CHECK_LIB(selinux, is_selinux_enabled,
[AC_CHECK_HEADER(selinux/selinux.h,
[LIBS="$LIBS -lselinux" [LIBS="$LIBS -lselinux"
AC_DEFINE(HAVE_SELINUX)]) AC_DEFINE(HAVE_SELINUX)])])
else else
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
fi fi

View File

@ -31,7 +31,6 @@ void channel_close(channel_T *channel, int invoke_close_cb);
void channel_close_in(channel_T *channel); void channel_close_in(channel_T *channel);
void channel_clear(channel_T *channel); void channel_clear(channel_T *channel);
void channel_free_all(void); void channel_free_all(void);
char_u *channel_read_block(channel_T *channel, ch_part_T part, int timeout);
void common_channel_read(typval_T *argvars, typval_T *rettv, int raw); void common_channel_read(typval_T *argvars, typval_T *rettv, int raw);
channel_T *channel_fd2channel(sock_T fd, ch_part_T *partp); channel_T *channel_fd2channel(sock_T fd, ch_part_T *partp);
void channel_handle_events(int only_keep_open); void channel_handle_events(int only_keep_open);

View File

@ -3510,6 +3510,9 @@ may_req_ambiguous_char_width(void)
out_str((char_u *)" "); out_str((char_u *)" ");
term_windgoto(0, 0); term_windgoto(0, 0);
/* Need to reset the known cursor position. */
screen_start();
/* check for the characters now, otherwise they might be eaten by /* check for the characters now, otherwise they might be eaten by
* get_keystroke() */ * get_keystroke() */
out_flush(); out_flush();
@ -4585,7 +4588,7 @@ check_termcode(
is_mac_terminal = TRUE; is_mac_terminal = TRUE;
} }
# ifdef FEAT_MOUSE_SGR # ifdef FEAT_MOUSE_SGR
/* Iterm2 sends 0;95;0 */ /* iTerm2 sends 0;95;0 */
if (STRNCMP(tp + extra - 2, "0;95;0c", 7) == 0) if (STRNCMP(tp + extra - 2, "0;95;0c", 7) == 0)
is_iterm2 = TRUE; is_iterm2 = TRUE;
# endif # endif
@ -4597,7 +4600,7 @@ check_termcode(
{ {
# ifdef FEAT_MOUSE_SGR # ifdef FEAT_MOUSE_SGR
/* Xterm version 277 supports SGR. Also support /* Xterm version 277 supports SGR. Also support
* Terminal.app and iterm2. */ * Terminal.app and iTerm2. */
if (version >= 277 || is_iterm2 || is_mac_terminal) if (version >= 277 || is_iterm2 || is_mac_terminal)
set_option_value((char_u *)"ttym", 0L, set_option_value((char_u *)"ttym", 0L,
(char_u *)"sgr", 0); (char_u *)"sgr", 0);

View File

@ -0,0 +1,3 @@
let g:loaded_sourced_vim += 1
func! sourced#something()
endfunc

View File

@ -2,10 +2,16 @@
set runtimepath=./sautest set runtimepath=./sautest
func! Test_autoload_dict_func() func Test_autoload_dict_func()
let g:loaded_foo_vim = 0 let g:loaded_foo_vim = 0
let g:called_foo_bar_echo = 0 let g:called_foo_bar_echo = 0
call g:foo#bar.echo() call g:foo#bar.echo()
call assert_equal(1, g:loaded_foo_vim) call assert_equal(1, g:loaded_foo_vim)
call assert_equal(1, g:called_foo_bar_echo) call assert_equal(1, g:called_foo_bar_echo)
endfunc endfunc
func Test_source_autoload()
let g:loaded_sourced_vim = 0
source sautest/autoload/sourced.vim
call assert_equal(1, g:loaded_sourced_vim)
endfunc

View File

@ -515,7 +515,7 @@ func Test_nl_pipe()
call assert_equal("AND this", ch_readraw(handle)) call assert_equal("AND this", ch_readraw(handle))
call ch_sendraw(handle, "split this line\n") call ch_sendraw(handle, "split this line\n")
call assert_equal("this linethis linethis line", ch_readraw(handle)) call assert_equal("this linethis linethis line", ch_read(handle))
let reply = ch_evalraw(handle, "quit\n") let reply = ch_evalraw(handle, "quit\n")
call assert_equal("Goodbye!", reply) call assert_equal("Goodbye!", reply)
@ -1266,6 +1266,31 @@ func Test_read_in_close_cb()
endtry endtry
endfunc endfunc
" Use channel in NL mode but received text does not end in NL.
func Test_read_in_close_cb_incomplete()
if !has('job')
return
endif
call ch_log('Test_read_in_close_cb_incomplete()')
let g:Ch_received = ''
func! CloseHandler(chan)
while ch_status(a:chan, {'part': 'out'}) == 'buffered'
let g:Ch_received .= ch_read(a:chan)
endwhile
endfunc
let job = job_start(s:python . " test_channel_pipe.py incomplete",
\ {'close_cb': 'CloseHandler'})
call assert_equal("run", job_status(job))
try
call WaitFor('g:Ch_received != ""')
call assert_equal('incomplete', g:Ch_received)
finally
call job_stop(job)
delfunc CloseHandler
endtry
endfunc
func Test_out_cb_lambda() func Test_out_cb_lambda()
if !has('job') if !has('job')
return return

View File

@ -14,6 +14,10 @@ if __name__ == "__main__":
if sys.argv[1].startswith("err"): if sys.argv[1].startswith("err"):
print(sys.argv[1], file=sys.stderr) print(sys.argv[1], file=sys.stderr)
sys.stderr.flush() sys.stderr.flush()
elif sys.argv[1].startswith("incomplete"):
print(sys.argv[1], end='')
sys.stdout.flush()
sys.exit(0)
else: else:
print(sys.argv[1]) print(sys.argv[1])
sys.stdout.flush() sys.stdout.flush()

View File

@ -1886,7 +1886,7 @@ ex_function(exarg_T *eap)
* g:func global function name, same as "func" * g:func global function name, same as "func"
*/ */
p = eap->arg; p = eap->arg;
name = trans_function_name(&p, eap->skip, 0, &fudi, NULL); name = trans_function_name(&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL);
paren = (vim_strchr(p, '(') != NULL); paren = (vim_strchr(p, '(') != NULL);
if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip)
{ {

View File

@ -771,6 +771,14 @@ 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 */
/**/
1381,
/**/
1380,
/**/
1379,
/**/
1378,
/**/ /**/
1377, 1377,
/**/ /**/