To: vim-dev@vim.org Subject: Patch 6.0.134 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.134 Problem: When completing ":set tags=" a path with an embedded space causes the completion to stop. (Sektor van Skijlen) Solution: Escape spaces with backslashes, like for ":set path=". Also take backslashes into account when searching for the start of the path to complete (e.g., for 'backupdir' and 'cscopeprg'). Files: src/ex_docmd.c, src/ex_getln.c, src/option.c, src/structs.h *** ../vim60.133/src/ex_docmd.c Mon Dec 31 17:47:49 2001 --- src/ex_docmd.c Wed Jan 2 13:08:49 2002 *************** *** 2153,2159 **** xp->xp_pattern = buff; xp->xp_context = EXPAND_COMMANDS; /* Default until we get past command */ ! xp->xp_set_path = FALSE; /* * 2. skip comment lines and leading space, colons or bars --- 2153,2159 ---- xp->xp_pattern = buff; xp->xp_context = EXPAND_COMMANDS; /* Default until we get past command */ ! xp->xp_backslash = XP_BS_NONE; /* * 2. skip comment lines and leading space, colons or bars *** ../vim60.133/src/ex_getln.c Wed Oct 31 20:51:33 2001 --- src/ex_getln.c Wed Jan 2 13:22:16 2002 *************** *** 2605,2611 **** for (i = 0; i < numfiles; ++i) { /* for ":set path=" we need to escape spaces twice */ ! if (xp->xp_set_path) { p = vim_strsave_escaped(files[i], (char_u *)" "); if (p != NULL) --- 2605,2611 ---- for (i = 0; i < numfiles; ++i) { /* for ":set path=" we need to escape spaces twice */ ! if (xp->xp_backslash == XP_BS_THREE) { p = vim_strsave_escaped(files[i], (char_u *)" "); if (p != NULL) *************** *** 2643,2649 **** } } } ! xp->xp_set_path = FALSE; } else if (xp->xp_context == EXPAND_TAGS) { --- 2643,2649 ---- } } } ! xp->xp_backslash = XP_BS_NONE; } else if (xp->xp_context == EXPAND_TAGS) { *************** *** 3103,3138 **** if (options & WILD_SILENT) flags |= EW_SILENT; ! if (xp->xp_context == EXPAND_FILES) { /* ! * Expand file names. ! */ ! return expand_wildcards(1, &pat, num_file, file, flags|EW_FILE); ! } ! else if (xp->xp_context == EXPAND_DIRECTORIES) ! { ! /* ! * Expand directory names. */ int free_pat = FALSE; int i; ! /* for ":set path=" we need to remove backslashes for escaped space */ ! if (xp->xp_set_path) { free_pat = TRUE; pat = vim_strsave(pat); for (i = 0; pat[i]; ++i) ! if (pat[i] == '\\' ! && pat[i + 1] == '\\' ! && pat[i + 2] == '\\' ! && pat[i + 3] == ' ') ! STRCPY(pat + i, pat + i + 3); } ! ret = expand_wildcards(1, &pat, num_file, file, ! (flags | EW_DIR) & ~EW_FILE); if (free_pat) vim_free(pat); return ret; --- 3103,3141 ---- if (options & WILD_SILENT) flags |= EW_SILENT; ! if (xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_DIRECTORIES) { /* ! * Expand file or directory names. */ int free_pat = FALSE; int i; ! /* for ":set path=" and ":set tags=" halve backslashes for escaped ! * space */ ! if (xp->xp_backslash != XP_BS_NONE) { free_pat = TRUE; pat = vim_strsave(pat); for (i = 0; pat[i]; ++i) ! if (pat[i] == '\\') ! { ! if (xp->xp_backslash == XP_BS_THREE ! && pat[i + 1] == '\\' ! && pat[i + 2] == '\\' ! && pat[i + 3] == ' ') ! STRCPY(pat + i, pat + i + 3); ! if (xp->xp_backslash == XP_BS_ONE ! && pat[i + 1] == ' ') ! STRCPY(pat + i, pat + i + 1); ! } } ! if (xp->xp_context == EXPAND_FILES) ! flags |= EW_FILE; ! else ! flags = (flags | EW_DIR) & ~EW_FILE; ! ret = expand_wildcards(1, &pat, num_file, file, flags); if (free_pat) vim_free(pat); return ret; *** ../vim60.133/src/option.c Tue Jan 15 14:28:35 2002 --- src/option.c Tue Jan 15 14:24:07 2002 *************** *** 7603,7609 **** int opt_idx = 0; /* init for GCC */ char_u *p; char_u *s; - char_u *after_blank = NULL; int is_term_option = FALSE; int key; --- 7603,7608 ---- *************** *** 7636,7646 **** ++p; break; } - /* remember possible start of file name to expand */ - if (after_blank == NULL - && ((*p == ' ' && (p - s) < 2) - || (*p == ',' && p == s))) - after_blank = p + 1; --p; } if (STRNCMP(p, "no", 2) == 0) --- 7635,7640 ---- *************** *** 7733,7742 **** xp->xp_context = EXPAND_NOTHING; if (is_term_option || (flags & P_NUM)) return; ! if (after_blank != NULL) ! xp->xp_pattern = after_blank; ! else ! xp->xp_pattern = p + 1; if (flags & P_EXPAND) { p = options[opt_idx].var; --- 7727,7735 ---- xp->xp_context = EXPAND_NOTHING; if (is_term_option || (flags & P_NUM)) return; ! ! xp->xp_pattern = p + 1; ! if (flags & P_EXPAND) { p = options[opt_idx].var; *************** *** 7758,7768 **** || p == (char_u *)&p_cdpath #endif ) ! xp->xp_set_path = TRUE; } else xp->xp_context = EXPAND_FILES; } return; } --- 7751,7790 ---- || p == (char_u *)&p_cdpath #endif ) ! xp->xp_backslash = XP_BS_THREE; ! else ! xp->xp_backslash = XP_BS_ONE; } else + { xp->xp_context = EXPAND_FILES; + /* for 'tags' need three backslashes for a space */ + if (p == (char_u *)&p_tags) + xp->xp_backslash = XP_BS_THREE; + else + xp->xp_backslash = XP_BS_ONE; + } + } + + /* For an option that is a list of file names, find the start of the + * last file name. */ + for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) + { + /* count number of backslashes before ' ' or ',' */ + if (*p == ' ' || *p == ',') + { + s = p; + while (s > xp->xp_pattern && *(s - 1) == '\\') + --s; + if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) + || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) + { + xp->xp_pattern = p + 1; + break; + } + } } + return; } *** ../vim60.133/src/structs.h Fri Nov 2 16:29:44 2001 --- src/structs.h Wed Jan 2 13:16:36 2002 *************** *** 364,371 **** { int xp_context; /* type of expansion */ char_u *xp_pattern; /* start of item to expand */ ! int xp_set_path; /* ":set path=/dir/" */ } expand_T; /* * Command modifiers ":vertical", ":browse", ":confirm" and ":hide" set a flag. --- 364,376 ---- { int xp_context; /* type of expansion */ char_u *xp_pattern; /* start of item to expand */ ! int xp_backslash; /* one of the XP_BS_ values */ } expand_T; + + /* values for xp_backslash */ + #define XP_BS_NONE 0 /* nothing special for backslashes */ + #define XP_BS_ONE 1 /* uses one backslash before a space */ + #define XP_BS_THREE 2 /* uses three backslashes before a space */ /* * Command modifiers ":vertical", ":browse", ":confirm" and ":hide" set a flag. *** ../vim60.133/src/version.c Tue Jan 15 14:28:35 2002 --- src/version.c Tue Jan 15 14:30:42 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 134, /**/ -- Every engineer dreams about saving the universe and having sex with aliens. This is much more glamorous than the real life of an engineer, which consists of hiding from the universe and having sex without the participation of other life forms. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim ))) \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///