From ad002dff29d89db0d4ede202baac2bd6f7fad263 Mon Sep 17 00:00:00 2001 From: edyfox Date: Wed, 2 Apr 2008 05:58:42 +0000 Subject: [PATCH] Merged from the latest developing branch. git-svn-id: https://vim.svn.sourceforge.net/svnroot/vim/trunk@993 2a77ed30-b011-0410-a7ad-c7884a0aa172 --- src/eval.c | 3 ++- src/if_cscope.c | 41 ++++++++++++++++++++++++++++++++++++++--- src/misc2.c | 8 ++++++-- src/normal.c | 6 ++++-- src/spell.c | 16 ++++++++++------ src/version.c | 12 ++++++++++++ 6 files changed, 72 insertions(+), 14 deletions(-) diff --git a/src/eval.c b/src/eval.c index 2a920ed8..e008df24 100644 --- a/src/eval.c +++ b/src/eval.c @@ -13954,6 +13954,7 @@ f_reverse(argvars, rettv) rettv->vval.v_list = l; rettv->v_type = VAR_LIST; ++l->lv_refcount; + l->lv_idx = l->lv_len - l->lv_idx - 1; } } @@ -15202,7 +15203,7 @@ f_sort(argvars, rettv) if (!item_compare_func_err) { /* Clear the List and append the items in the sorted order. */ - l->lv_first = l->lv_last = NULL; + l->lv_first = l->lv_last = l->lv_idx_item = NULL; l->lv_len = 0; for (i = 0; i < len; ++i) list_append(l, ptrs[i]); diff --git a/src/if_cscope.c b/src/if_cscope.c index b2d39cf4..00195595 100644 --- a/src/if_cscope.c +++ b/src/if_cscope.c @@ -2130,6 +2130,7 @@ cs_release_csp(i, freefnpp) } #if defined(UNIX) { + int waitpid_errno; int pstat; pid_t pid; @@ -2145,6 +2146,7 @@ cs_release_csp(i, freefnpp) /* Block until cscope exits or until timer expires */ pid = waitpid(csinfo[i].pid, &pstat, 0); + waitpid_errno = errno; /* cancel pending alarm if still there and restore signal */ alarm(0); @@ -2158,9 +2160,10 @@ cs_release_csp(i, freefnpp) for (waited = 0; waited < 40; ++waited) { pid = waitpid(csinfo[i].pid, &pstat, WNOHANG); + waitpid_errno = errno; if (pid != 0) break; /* break unless the process is still running */ - mch_delay(50, FALSE); /* sleep 50 ms */ + mch_delay(50L, FALSE); /* sleep 50 ms */ } # endif /* @@ -2170,8 +2173,40 @@ cs_release_csp(i, freefnpp) */ if (pid < 0 && csinfo[i].pid > 1) { - kill(csinfo[i].pid, SIGKILL); - (void)waitpid(csinfo[i].pid, &pstat, 0); +# ifdef ECHILD + int alive = TRUE; + + if (waitpid_errno == ECHILD) + { + /* + * When using 'vim -g', vim is forked and cscope process is + * no longer a child process but a sibling. So waitpid() + * fails with errno being ECHILD (No child processes). + * Don't send SIGKILL to cscope immediately but wait + * (polling) for it to exit normally as result of sending + * the "q" command, hence giving it a chance to clean up + * its temporary files. + */ + int waited; + + sleep(0); + for (waited = 0; waited < 40; ++waited) + { + /* Check whether cscope process is still alive */ + if (kill(csinfo[i].pid, 0) != 0) + { + alive = FALSE; /* cscope process no longer exists */ + break; + } + mch_delay(50L, FALSE); /* sleep 50ms */ + } + } + if (alive) +# endif + { + kill(csinfo[i].pid, SIGKILL); + (void)waitpid(csinfo[i].pid, &pstat, 0); + } } } #else /* !UNIX */ diff --git a/src/misc2.c b/src/misc2.c index fd0405fd..6a562d88 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -751,7 +751,7 @@ vim_mem_profile_dump() #endif /* - * Note: if unsinged is 16 bits we can only allocate up to 64K with alloc(). + * Note: if unsigned is 16 bits we can only allocate up to 64K with alloc(). * Use lalloc for larger blocks. */ char_u * @@ -1082,7 +1082,11 @@ free_all_mem() win_free_all(); #endif - /* Free all buffers. */ + /* Free all buffers. Reset 'autochdir' to avoid accessing things that + * were freed already. */ +#ifdef FEAT_AUTOCHDIR + p_acd = FALSE; +#endif for (buf = firstbuf; buf != NULL; ) { nextbuf = buf->b_next; diff --git a/src/normal.c b/src/normal.c index eda2ad38..d3ce6a88 100644 --- a/src/normal.c +++ b/src/normal.c @@ -8345,6 +8345,7 @@ nv_wordcmd(cap) int n; int word_end; int flag = FALSE; + pos_T startpos = curwin->w_cursor; /* * Set inclusive for the "E" and "e" command. @@ -8405,8 +8406,9 @@ nv_wordcmd(cap) else n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP); - /* Don't leave the cursor on the NUL past the end of line. */ - if (n != FAIL) + /* Don't leave the cursor on the NUL past the end of line. Unless we + * didn't move it forward. */ + if (lt(startpos, curwin->w_cursor)) adjust_cursor(cap->oap); if (n == FAIL && cap->oap->op_type == OP_NOP) diff --git a/src/spell.c b/src/spell.c index f45be18c..567c6cd3 100644 --- a/src/spell.c +++ b/src/spell.c @@ -2268,6 +2268,8 @@ spell_move_to(wp, dir, allwords, curline, attrp) /* * For spell checking: concatenate the start of the following line "line" into * "buf", blanking-out special characters. Copy less then "maxlen" bytes. + * Keep the blanks at the start of the next line, this is used in win_line() + * to skip those bytes if the word was OK. */ void spell_cat_line(buf, line, maxlen) @@ -2284,12 +2286,14 @@ spell_cat_line(buf, line, maxlen) if (*p != NUL) { - *buf = ' '; - vim_strncpy(buf + 1, line, maxlen - 2); - n = (int)(p - line); - if (n >= maxlen) - n = maxlen - 1; - vim_memset(buf + 1, ' ', n); + /* Only worth concatenating if there is something else than spaces to + * concatenate. */ + n = (int)(p - line) + 1; + if (n < maxlen - 1) + { + vim_memset(buf, ' ', n); + vim_strncpy(buf + n, p, maxlen - 1 - n); + } } } diff --git a/src/version.c b/src/version.c index ad56d62a..ee03f3c8 100644 --- a/src/version.c +++ b/src/version.c @@ -667,6 +667,18 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 291, +/**/ + 290, +/**/ + 289, +/**/ + 288, +/**/ + 287, +/**/ + 286, +/**/ 285, /**/ 284, -- 2.11.4.GIT