diff --git a/src/ex_cmds.c b/src/ex_cmds.c index d53652fda2..e8b39b3c8f 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -6670,11 +6670,6 @@ ex_sign(eap) sp = (sign_T *)alloc_clear((unsigned)sizeof(sign_T)); if (sp == NULL) return; - if (sp_prev == NULL) - first_sign = sp; - else - sp_prev->sn_next = sp; - sp->sn_name = vim_strnsave(arg, (int)(p - arg)); /* If the name is a number use that for the typenr, * otherwise use a negative number. */ @@ -6687,13 +6682,14 @@ ex_sign(eap) for (lp = first_sign; lp != NULL; lp = lp->sn_next) { - if (lp->sn_typenr == last_sign_typenr) + if (lp->sn_typenr == -last_sign_typenr) { --last_sign_typenr; if (last_sign_typenr == 0) last_sign_typenr = MAX_TYPENR; if (last_sign_typenr == start) { + vim_free(sp); EMSG(_("E612: Too many signs defined")); return; } @@ -6702,10 +6698,17 @@ ex_sign(eap) } } - sp->sn_typenr = last_sign_typenr--; - if (last_sign_typenr == 0) + sp->sn_typenr = -last_sign_typenr; + if (--last_sign_typenr == 0) last_sign_typenr = MAX_TYPENR; /* wrap around */ } + + /* add the new sign to the list of signs */ + if (sp_prev == NULL) + first_sign = sp; + else + sp_prev->sn_next = sp; + sp->sn_name = vim_strnsave(arg, (int)(p - arg)); } /* set values for a defined sign. */ diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 14b62fa73f..a91d4f2ddf 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -10736,7 +10736,7 @@ ses_fname(fd, buf, flagp) * Write a file name to the session file. * Takes care of the "slash" option in 'sessionoptions' and escapes special * characters. - * Returns FAIL if writing fails. + * Returns FAIL if writing fails or out of memory. */ static int ses_put_fname(fd, name, flagp) @@ -10745,49 +10745,32 @@ ses_put_fname(fd, name, flagp) unsigned *flagp; { char_u *sname; + char_u *p; int retval = OK; - int c; sname = home_replace_save(NULL, name); - if (sname != NULL) - name = sname; - while (*name != NUL) - { -#ifdef FEAT_MBYTE - { - int l; + if (sname == NULL) + return FAIL; - if (has_mbyte && (l = (*mb_ptr2len)(name)) > 1) - { - /* copy a multibyte char */ - while (--l >= 0) - { - if (putc(*name, fd) != *name) - retval = FAIL; - ++name; - } - continue; - } - } -#endif - c = *name++; - if (c == '\\' && (*flagp & SSOP_SLASH)) - /* change a backslash to a forward slash */ - c = '/'; - else if ((vim_strchr(escape_chars, c) != NULL -#ifdef BACKSLASH_IN_FILENAME - && c != '\\' -#endif - ) || c == '#' || c == '%') - { - /* escape a special character with a backslash */ - if (putc('\\', fd) != '\\') - retval = FAIL; - } - if (putc(c, fd) != c) - retval = FAIL; + if (*flagp & SSOP_SLASH) + { + /* change all backslashes to forward slashes */ + for (p = sname; *p != NUL; mb_ptr_adv(p)) + if (*p == '\\') + *p = '/'; } + + /* escapse special characters */ + p = vim_strsave_fnameescape(sname, FALSE); vim_free(sname); + if (p == NULL) + return FAIL; + + /* write the result */ + if (fputs((char *)p, fd) < 0) + retval = FAIL; + + vim_free(p); return retval; } diff --git a/src/normal.c b/src/normal.c index a31f6c7130..8006351e71 100644 --- a/src/normal.c +++ b/src/normal.c @@ -5700,8 +5700,13 @@ nv_ident(cap) else if (cmdchar == '#') aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\"); else if (tag_cmd) - /* Don't escape spaces and Tabs in a tag with a backslash */ - aux_ptr = (char_u *)"\\|\"\n["; + { + if (curbuf->b_help) + /* ":help" handles unescaped argument */ + aux_ptr = (char_u *)""; + else + aux_ptr = (char_u *)"\\|\"\n["; + } else aux_ptr = (char_u *)"\\|\"\n*?["; diff --git a/src/ops.c b/src/ops.c index 98bd2d171a..cf5d1b13c1 100644 --- a/src/ops.c +++ b/src/ops.c @@ -4153,9 +4153,10 @@ do_join(count, insert_space, save_undo) int save_undo; { char_u *curr = NULL; + char_u *curr_start = NULL; char_u *cend; char_u *newp; - char_u *spaces; /* number of spaces inserte before a line */ + char_u *spaces; /* number of spaces inserted before a line */ int endcurr1 = NUL; int endcurr2 = NUL; int currsize = 0; /* size of the current line */ @@ -4181,7 +4182,7 @@ do_join(count, insert_space, save_undo) */ for (t = 0; t < count; ++t) { - curr = ml_get((linenr_T)(curwin->w_cursor.lnum + t)); + curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t)); if (insert_space && t > 0) { curr = skipwhite(curr); @@ -4265,10 +4266,10 @@ do_join(count, insert_space, save_undo) copy_spaces(cend, (size_t)(spaces[t])); } mark_col_adjust(curwin->w_cursor.lnum + t, (colnr_T)0, (linenr_T)-t, - (long)(cend - newp + spaces[t])); + (long)(cend - newp + spaces[t] - (curr - curr_start))); if (t == 0) break; - curr = ml_get((linenr_T)(curwin->w_cursor.lnum + t - 1)); + curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t - 1)); if (insert_space && t > 1) curr = skipwhite(curr); currsize = (int)STRLEN(curr); diff --git a/src/option.c b/src/option.c index 18c14bb033..378b889917 100644 --- a/src/option.c +++ b/src/option.c @@ -10150,7 +10150,7 @@ buf_copy_options(buf, flags) buf->b_p_smc = p_smc; #endif #ifdef FEAT_SPELL - buf->b_s.b_p_spc = vim_strsave(p_spf); + buf->b_s.b_p_spc = vim_strsave(p_spc); (void)compile_cap_prog(&buf->b_s); buf->b_s.b_p_spf = vim_strsave(p_spf); buf->b_s.b_p_spl = vim_strsave(p_spl); diff --git a/src/os_macosx.m b/src/os_macosx.m index 0849aa49bb..e45a349eff 100644 --- a/src/os_macosx.m +++ b/src/os_macosx.m @@ -15,6 +15,10 @@ Error: MACOS 9 is no longer supported in Vim 7 #endif +/* Avoid a conflict for the definition of Boolean between Mac header files and + * X11 header files. */ +#define NO_X11_INCLUDES + #include "vim.h" #import diff --git a/src/os_unix.c b/src/os_unix.c index 466345bdc0..c8356ada5c 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4174,9 +4174,6 @@ mch_call_shell(cmd, options) # ifdef FEAT_GUI if (pty_master_fd >= 0) { -# ifndef FEAT_GUI_MACVIM - close(pty_slave_fd); /* close slave side of pty */ -# endif fromshell_fd = pty_master_fd; toshell_fd = dup(pty_master_fd); } @@ -4649,10 +4646,14 @@ finished: break; } -#ifdef FEAT_GUI_MACVIM - if (pty_slave_fd >= 0) - close(pty_slave_fd); /* close slave side of pty */ -#endif +# ifdef FEAT_GUI + /* Close slave side of pty. Only do this after the child has + * exited, otherwise the child may hang when it tries to write on + * the pty. */ + if (pty_master_fd >= 0) + close(pty_slave_fd); +# endif + /* Make sure the child that writes to the external program is * dead. */ if (wpid > 0) diff --git a/src/os_win32.c b/src/os_win32.c index 8c59e09967..6bfcc2af52 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -2308,12 +2308,14 @@ fname_case( int len) { char szTrueName[_MAX_PATH + 2]; + char szTrueNameTemp[_MAX_PATH + 2]; char *ptrue, *ptruePrev; char *porig, *porigPrev; int flen; WIN32_FIND_DATA fb; HANDLE hFind; int c; + int slen; flen = (int)STRLEN(name); if (flen == 0 || flen > _MAX_PATH) @@ -2358,12 +2360,19 @@ fname_case( } *ptrue = NUL; + /* To avoid a slow failure append "\*" when searching a directory, + * server or network share. */ + STRCPY(szTrueNameTemp, szTrueName); + slen = strlen(szTrueNameTemp); + if (*porig == psepc && slen + 2 < _MAX_PATH) + STRCPY(szTrueNameTemp + slen, "\\*"); + /* Skip "", "." and "..". */ if (ptrue > ptruePrev && (ptruePrev[0] != '.' || (ptruePrev[1] != NUL && (ptruePrev[1] != '.' || ptruePrev[2] != NUL))) - && (hFind = FindFirstFile(szTrueName, &fb)) + && (hFind = FindFirstFile(szTrueNameTemp, &fb)) != INVALID_HANDLE_VALUE) { c = *porig; diff --git a/src/testdir/test68.in b/src/testdir/test68.in index 94104c07bd..8d0c501e2a 100644 --- a/src/testdir/test68.in +++ b/src/testdir/test68.in @@ -50,6 +50,17 @@ a b #a b } +STARTTEST +/^{/+2 +:set tw& fo=a +I^^ +ENDTEST + +{ + 1aa + 2bb +} + STARTTEST :g/^STARTTEST/.,/^ENDTEST/d :1;/^Results/,$wq! test.out diff --git a/src/testdir/test68.ok b/src/testdir/test68.ok index 85f35cfca1..aebe364363 100644 --- a/src/testdir/test68.ok +++ b/src/testdir/test68.ok @@ -33,3 +33,6 @@ a b #a b } + +{ 1aa ^^2bb } + diff --git a/src/version.c b/src/version.c index ad07c0743c..57bd321de3 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,22 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 27, +/**/ + 26, +/**/ + 25, +/**/ + 24, +/**/ + 23, +/**/ + 22, +/**/ + 21, +/**/ + 20, /**/ 19, /**/ diff --git a/src/vim.h b/src/vim.h index 5497d4420d..5a22eae1e3 100644 --- a/src/vim.h +++ b/src/vim.h @@ -193,8 +193,8 @@ #endif #ifdef NO_X11_INCLUDES - /* In os_mac_conv.c NO_X11_INCLUDES is defined to avoid X11 headers. - * Disable all X11 related things to avoid conflicts. */ + /* In os_mac_conv.c and os_macosx.m NO_X11_INCLUDES is defined to avoid + * X11 headers. Disable all X11 related things to avoid conflicts. */ # ifdef FEAT_X11 # undef FEAT_X11 # endif