To: vim-dev@vim.org Subject: Patch 7.2b.018 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 7.2b.018 Problem: When doing command line completion on a file name for a csh-like shell argument a '!' character isn't escaped properly. Solution: Add another backslash. Files: src/ex_getln.c, src/misc2.c, src/proto/misc2.pro, src/screen.c *** ../vim-7.2b.017/src/ex_getln.c Tue Jun 24 23:49:23 2008 --- src/ex_getln.c Thu Jul 24 10:36:42 2008 *************** *** 3707,3716 **** char_u *fname; int shell; { #ifdef BACKSLASH_IN_FILENAME char_u buf[20]; int j = 0; - char_u *p; /* Don't escape '[' and '{' if they are in 'isfname'. */ for (p = PATH_ESC_CHARS; *p != NUL; ++p) --- 3707,3716 ---- char_u *fname; int shell; { + char_u *p; #ifdef BACKSLASH_IN_FILENAME char_u buf[20]; int j = 0; /* Don't escape '[' and '{' if they are in 'isfname'. */ for (p = PATH_ESC_CHARS; *p != NUL; ++p) *************** *** 3719,3725 **** buf[j] = NUL; return vim_strsave_escaped(fname, buf); #else ! return vim_strsave_escaped(fname, shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS); #endif } --- 3719,3736 ---- buf[j] = NUL; return vim_strsave_escaped(fname, buf); #else ! p = vim_strsave_escaped(fname, shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS); ! if (shell && csh_like_shell() && p != NULL) ! { ! char_u *s; ! ! /* For csh and similar shells need to put two backslashes before '!'. ! * One is taken by Vim, one by the shell. */ ! s = vim_strsave_escaped(p, (char_u *)"!"); ! vim_free(p); ! p = s; ! } ! return p; #endif } *************** *** 5960,5966 **** --- 5971,5979 ---- linenr_T lnum; int histtype; garray_T winsizes; + #ifdef FEAT_AUTOCMD char_u typestr[2]; + #endif int save_restart_edit = restart_edit; int save_State = State; int save_exmode = exmode_active; *** ../vim-7.2b.017/src/misc2.c Wed Jul 16 22:42:51 2008 --- src/misc2.c Wed Jul 23 21:12:56 2008 *************** *** 1257,1262 **** --- 1257,1273 ---- return escaped_string; } + #if !defined(BACKSLASH_IN_FILENAME) || defined(FEAT_EVAL) || defined(PROTO) + /* + * Return TRUE when 'shell' has "csh" in the tail. + */ + int + csh_like_shell() + { + return (strstr((char *)gettail(p_sh), "csh") != NULL); + } + #endif + #if defined(FEAT_EVAL) || defined(PROTO) /* * Escape "string" for use as a shell argument with system(). *************** *** 1283,1289 **** * the like we must not put a backslash before it, it will be taken * literally. If do_special is set the '!' will be escaped twice. * Csh also needs to have "\n" escaped twice when do_special is set. */ ! csh_like = (strstr((char *)gettail(p_sh), "csh") != NULL); /* First count the number of extra bytes required. */ length = (unsigned)STRLEN(string) + 3; /* two quotes and a trailing NUL */ --- 1294,1300 ---- * the like we must not put a backslash before it, it will be taken * literally. If do_special is set the '!' will be escaped twice. * Csh also needs to have "\n" escaped twice when do_special is set. */ ! csh_like = csh_like_shell(); /* First count the number of extra bytes required. */ length = (unsigned)STRLEN(string) + 3; /* two quotes and a trailing NUL */ *** ../vim-7.2b.017/src/proto/misc2.pro Fri Jul 4 11:44:02 2008 --- src/proto/misc2.pro Wed Jul 23 21:12:59 2008 *************** *** 29,34 **** --- 29,35 ---- char_u *vim_strnsave __ARGS((char_u *string, int len)); char_u *vim_strsave_escaped __ARGS((char_u *string, char_u *esc_chars)); char_u *vim_strsave_escaped_ext __ARGS((char_u *string, char_u *esc_chars, int cc, int bsl)); + int csh_like_shell __ARGS((void)); char_u *vim_strsave_shellescape __ARGS((char_u *string, int do_special)); char_u *vim_strsave_up __ARGS((char_u *string)); char_u *vim_strnsave_up __ARGS((char_u *string, int len)); *** ../vim-7.2b.017/src/screen.c Fri Jul 18 17:11:39 2008 --- src/screen.c Thu Jul 24 16:45:07 2008 *************** *** 5447,5454 **** while (*s != NUL) { ! if (skip_status_match_char(xp, s)) ! ++s; len += ptr2cells(s); mb_ptr_adv(s); } --- 5447,5453 ---- while (*s != NUL) { ! s += skip_status_match_char(xp, s); len += ptr2cells(s); mb_ptr_adv(s); } *************** *** 5457,5463 **** } /* ! * Return TRUE for characters that are not displayed in a status match. * These are backslashes used for escaping. Do show backslashes in help tags. */ static int --- 5456,5462 ---- } /* ! * Return the number of characters that should be skipped in a status match. * These are backslashes used for escaping. Do show backslashes in help tags. */ static int *************** *** 5465,5477 **** expand_T *xp; char_u *s; { ! return ((rem_backslash(s) && xp->xp_context != EXPAND_HELP) #ifdef FEAT_MENU || ((xp->xp_context == EXPAND_MENUS || xp->xp_context == EXPAND_MENUNAMES) && (s[0] == '\t' || (s[0] == '\\' && s[1] != NUL))) #endif ! ); } /* --- 5464,5484 ---- expand_T *xp; char_u *s; { ! if ((rem_backslash(s) && xp->xp_context != EXPAND_HELP) #ifdef FEAT_MENU || ((xp->xp_context == EXPAND_MENUS || xp->xp_context == EXPAND_MENUNAMES) && (s[0] == '\t' || (s[0] == '\\' && s[1] != NUL))) #endif ! ) ! { ! #ifndef BACKSLASH_IN_FILENAME ! if (xp->xp_shell && csh_like_shell() && s[1] == '\\' && s[2] == '!') ! return 2; ! #endif ! return 1; ! } ! return 0; } /* *************** *** 5609,5616 **** #endif for ( ; *s != NUL; ++s) { ! if (skip_status_match_char(xp, s)) ! ++s; clen += ptr2cells(s); #ifdef FEAT_MBYTE if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1) --- 5616,5622 ---- #endif for ( ; *s != NUL; ++s) { ! s += skip_status_match_char(xp, s); clen += ptr2cells(s); #ifdef FEAT_MBYTE if (has_mbyte && (l = (*mb_ptr2len)(s)) > 1) *************** *** 6264,6270 **** #ifdef FEAT_MBYTE /* When drawing over the right halve of a double-wide char clear out the * left halve. Only needed in a terminal. */ ! if (has_mbyte # ifdef FEAT_GUI && !gui.in_use # endif --- 6270,6276 ---- #ifdef FEAT_MBYTE /* When drawing over the right halve of a double-wide char clear out the * left halve. Only needed in a terminal. */ ! if (has_mbyte && col > 0 && col < screen_Columns # ifdef FEAT_GUI && !gui.in_use # endif *************** *** 7138,7144 **** * out the left halve. When drawing over the left halve of a * double wide-char clear out the right halve. Only needed in a * terminal. */ ! if (mb_fix_col(start_col, row) != start_col) screen_puts_len((char_u *)" ", 1, row, start_col - 1, 0); if (end_col < screen_Columns && mb_fix_col(end_col, row) != end_col) screen_puts_len((char_u *)" ", 1, row, end_col, 0); --- 7144,7150 ---- * out the left halve. When drawing over the left halve of a * double wide-char clear out the right halve. Only needed in a * terminal. */ ! if (start_col > 0 && mb_fix_col(start_col, row) != start_col) screen_puts_len((char_u *)" ", 1, row, start_col - 1, 0); if (end_col < screen_Columns && mb_fix_col(end_col, row) != end_col) screen_puts_len((char_u *)" ", 1, row, end_col, 0); *** ../vim-7.2b.017/src/version.c Thu Jul 24 19:33:36 2008 --- src/version.c Thu Jul 24 20:23:37 2008 *************** *** 678,679 **** --- 678,681 ---- { /* Add new patch number below this line */ + /**/ + 18, /**/ -- Nothing is impossible for the man who doesn't have to do it. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///