diff options
-rw-r--r-- | runtime/doc/todo.txt | 1 | ||||
-rw-r--r-- | src/Make_mvc.mak | 5 | ||||
-rw-r--r-- | src/blowfish.c | 8 | ||||
-rw-r--r-- | src/dosinst.c | 146 | ||||
-rw-r--r-- | src/ex_cmds.c | 16 | ||||
-rw-r--r-- | src/ex_docmd.c | 5 | ||||
-rw-r--r-- | src/ex_getln.c | 7 | ||||
-rw-r--r-- | src/fileio.c | 4 | ||||
-rw-r--r-- | src/getchar.c | 2 | ||||
-rw-r--r-- | src/gui.c | 2 | ||||
-rw-r--r-- | src/gui_gtk_x11.c | 4 | ||||
-rw-r--r-- | src/gui_w32.c | 8 | ||||
-rw-r--r-- | src/gui_w48.c | 6 | ||||
-rw-r--r-- | src/gui_x11.c | 2 | ||||
-rw-r--r-- | src/gui_xmebw.c | 8 | ||||
-rw-r--r-- | src/if_python.c | 4 | ||||
-rw-r--r-- | src/mbyte.c | 2 | ||||
-rw-r--r-- | src/menu.c | 32 | ||||
-rw-r--r-- | src/message.c | 2 | ||||
-rw-r--r-- | src/misc1.c | 213 | ||||
-rw-r--r-- | src/ops.c | 2 | ||||
-rw-r--r-- | src/option.c | 4 | ||||
-rw-r--r-- | src/os_mswin.c | 8 | ||||
-rw-r--r-- | src/os_unix.c | 4 | ||||
-rw-r--r-- | src/os_win32.c | 4 | ||||
-rw-r--r-- | src/search.c | 6 | ||||
-rw-r--r-- | src/sha256.c | 2 | ||||
-rw-r--r-- | src/syntax.c | 2 | ||||
-rw-r--r-- | src/tag.c | 6 | ||||
-rw-r--r-- | src/ui.c | 2 | ||||
-rw-r--r-- | src/undo.c | 138 | ||||
-rw-r--r-- | src/vim.h | 2 |
32 files changed, 440 insertions, 217 deletions
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index f69886cda3..cb365a37c1 100644 --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1098,7 +1098,6 @@ Vim 7.3: - Conceal feature: no update when moving to another window. (Dominique Pelle, 2010 Jul 5) Vince will look into it. Patches to possibly include: -- Win32: patch for better font scaling. (George Reilly, 2009 Mar 26) - Patch for completion of ":find" arguments. (Nazri Ramliy, 2009 Feb 22, 26) 8 For ":find" and ":sfind" expand files found in 'path'. Update 2009 Mar 28. diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak index 14c46ed52d..29dd623df9 100644 --- a/src/Make_mvc.mak +++ b/src/Make_mvc.mak @@ -1057,8 +1057,9 @@ $(OUTDIR)/window.obj: $(OUTDIR) window.c $(INCL) $(OUTDIR)/xpm_w32.obj: $(OUTDIR) xpm_w32.c $(CC) $(CFLAGS) $(XPM_INC) xpm_w32.c -$(OUTDIR)/vim.res: $(OUTDIR) vim.rc gvim.exe.mnf version.h tools.bmp tearoff.bmp \ - vim.ico vim_error.ico vim_alert.ico vim_info.ico vim_quest.ico +$(OUTDIR)/vim.res: $(OUTDIR) vim.rc gvim.exe.mnf version.h tools.bmp \ + tearoff.bmp vim.ico vim_error.ico \ + vim_alert.ico vim_info.ico vim_quest.ico $(RC) /l 0x409 /Fo$(OUTDIR)/vim.res $(RCFLAGS) vim.rc iid_ole.c if_ole.h vim.tlb: if_ole.idl diff --git a/src/blowfish.c b/src/blowfish.c index 78e56991bc..ff84cccebe 100644 --- a/src/blowfish.c +++ b/src/blowfish.c @@ -421,7 +421,7 @@ bf_key_init(password, salt, salt_len) * See http://en.wikipedia.org/wiki/Key_strengthening. */ key = sha256_key(password, salt, salt_len); for (i = 0; i < 1000; i++) - key = sha256_key(key, salt, salt_len); + key = sha256_key(key, salt, salt_len); /* Convert the key from 64 hex chars to 32 binary chars. */ keylen = (int)STRLEN(key) / 2; @@ -432,8 +432,8 @@ bf_key_init(password, salt, salt_len) } for (i = 0; i < keylen; i++) { - sscanf((char *)&key[i * 2], "%2x", &j); - key[i] = j; + sscanf((char *)&key[i * 2], "%2x", &j); + key[i] = j; } mch_memmove(sbx, sbi, 4 * 4 * 256); @@ -534,7 +534,7 @@ bf_self_test() for (i = 0; i < bn; i++) { bf_key_init((char_u *)(bf_test_data[i].password), - bf_test_data[i].salt, + bf_test_data[i].salt, (int)STRLEN(bf_test_data[i].salt)); if (!bf_check_tables(pax, sbx, bf_test_data[i].keysum)) err++; diff --git a/src/dosinst.c b/src/dosinst.c index b4399dfe67..0923cf78fe 100644 --- a/src/dosinst.c +++ b/src/dosinst.c @@ -1370,10 +1370,10 @@ reg_create_key( *phKey = NULL; return RegCreateKeyEx( - root, subkey, - 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_WOW64_64KEY | KEY_WRITE, - NULL, phKey, &disp); + root, subkey, + 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_WOW64_64KEY | KEY_WRITE, + NULL, phKey, &disp); } static LONG @@ -1398,8 +1398,8 @@ reg_create_key_and_value( if (ERROR_SUCCESS == lRet) { - lRet = reg_set_string_value(hKey, value_name, data); - RegCloseKey(hKey); + lRet = reg_set_string_value(hKey, value_name, data); + RegCloseKey(hKey); } return lRet; } @@ -1419,13 +1419,13 @@ register_inproc_server( lRet = reg_create_key_and_value(hRootKey, subkey, NULL, extname); if (ERROR_SUCCESS == lRet) { - sprintf(subkey, "CLSID\\%s\\InProcServer32", clsid); - lRet = reg_create_key_and_value(hRootKey, subkey, NULL, module); - if (ERROR_SUCCESS == lRet) - { - lRet = reg_create_key_and_value(hRootKey, subkey, + sprintf(subkey, "CLSID\\%s\\InProcServer32", clsid); + lRet = reg_create_key_and_value(hRootKey, subkey, NULL, module); + if (ERROR_SUCCESS == lRet) + { + lRet = reg_create_key_and_value(hRootKey, subkey, "ThreadingModel", threading_model); - } + } } return lRet; } @@ -1438,27 +1438,27 @@ register_shellex( const char *exe_path) { LONG lRet = reg_create_key_and_value( - hRootKey, - "*\\shellex\\ContextMenuHandlers\\gvim", - NULL, - clsid); + hRootKey, + "*\\shellex\\ContextMenuHandlers\\gvim", + NULL, + clsid); if (ERROR_SUCCESS == lRet) { - lRet = reg_create_key_and_value( - HKEY_LOCAL_MACHINE, - "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", - clsid, - name); - - if (ERROR_SUCCESS == lRet) - { - lRet = reg_create_key_and_value( - HKEY_LOCAL_MACHINE, - "Software\\Vim\\Gvim", - "path", - exe_path); - } + lRet = reg_create_key_and_value( + HKEY_LOCAL_MACHINE, + "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", + clsid, + name); + + if (ERROR_SUCCESS == lRet) + { + lRet = reg_create_key_and_value( + HKEY_LOCAL_MACHINE, + "Software\\Vim\\Gvim", + "path", + exe_path); + } } return lRet; } @@ -1469,25 +1469,25 @@ register_openwith( const char *exe_path) { LONG lRet = reg_create_key_and_value( - hRootKey, - "Applications\\gvim.exe\\shell\\edit\\command", - NULL, - exe_path); + hRootKey, + "Applications\\gvim.exe\\shell\\edit\\command", + NULL, + exe_path); if (ERROR_SUCCESS == lRet) { - int i; - static const char *openwith[] = { - ".htm\\OpenWithList\\gvim.exe", - ".vim\\OpenWithList\\gvim.exe", - "*\\OpenWithList\\gvim.exe", - }; + int i; + static const char *openwith[] = { + ".htm\\OpenWithList\\gvim.exe", + ".vim\\OpenWithList\\gvim.exe", + "*\\OpenWithList\\gvim.exe", + }; - for (i = 0; ERROR_SUCCESS == lRet + for (i = 0; ERROR_SUCCESS == lRet && i < sizeof(openwith) / sizeof(openwith[0]); i++) - { - lRet = reg_create_key_and_value(hRootKey, openwith[i], NULL, ""); - } + { + lRet = reg_create_key_and_value(hRootKey, openwith[i], NULL, ""); + } } return lRet; @@ -1504,7 +1504,7 @@ register_uninstall( "DisplayName", display_name); if (ERROR_SUCCESS == lRet) - lRet = reg_create_key_and_value(hRootKey, appname, + lRet = reg_create_key_and_value(hRootKey, appname, "UninstallString", uninstall_string); return lRet; } @@ -1521,47 +1521,47 @@ register_uninstall( install_registry(void) { #ifdef WIN3264 - LONG lRet = ERROR_SUCCESS; + LONG lRet = ERROR_SUCCESS; const char *vim_ext_ThreadingModel = "Apartment"; const char *vim_ext_name = "Vim Shell Extension"; const char *vim_ext_clsid = "{51EEE242-AD87-11d3-9C1E-0090278BBD99}"; char buf[BUFSIZE]; char vim_exe_path[BUFSIZE]; - char display_name[BUFSIZE]; - char uninstall_string[BUFSIZE]; + char display_name[BUFSIZE]; + char uninstall_string[BUFSIZE]; sprintf(vim_exe_path, "%s\\gvim.exe", installdir); if (install_popup) { - char bufg[BUFSIZE]; - struct stat st; + char bufg[BUFSIZE]; + struct stat st; - if (stat("gvimext.dll", &st) >= 0) - sprintf(bufg, "%s\\gvimext.dll", installdir); - else - /* gvimext.dll is in gvimext subdir */ - sprintf(bufg, "%s\\gvimext\\gvimext.dll", installdir); + if (stat("gvimext.dll", &st) >= 0) + sprintf(bufg, "%s\\gvimext.dll", installdir); + else + /* gvimext.dll is in gvimext subdir */ + sprintf(bufg, "%s\\gvimext\\gvimext.dll", installdir); - printf("Creating \"Edit with Vim\" popup menu entry\n"); + printf("Creating \"Edit with Vim\" popup menu entry\n"); - lRet = register_inproc_server( - HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name, + lRet = register_inproc_server( + HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name, bufg, vim_ext_ThreadingModel); - if (ERROR_SUCCESS != lRet) + if (ERROR_SUCCESS != lRet) return FAIL; - lRet = register_shellex( - HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name, vim_exe_path); - if (ERROR_SUCCESS != lRet) + lRet = register_shellex( + HKEY_CLASSES_ROOT, vim_ext_clsid, vim_ext_name, vim_exe_path); + if (ERROR_SUCCESS != lRet) return FAIL; } if (install_openwith) { - printf("Creating \"Open with ...\" list entry\n"); + printf("Creating \"Open with ...\" list entry\n"); - lRet = register_openwith(HKEY_CLASSES_ROOT, vim_exe_path); - if (ERROR_SUCCESS != lRet) + lRet = register_openwith(HKEY_CLASSES_ROOT, vim_exe_path); + if (ERROR_SUCCESS != lRet) return FAIL; } @@ -1570,20 +1570,20 @@ install_registry(void) /* For the NSIS installer use the generated uninstaller. */ if (interactive) { - sprintf(display_name, "Vim " VIM_VERSION_SHORT); - sprintf(uninstall_string, "%suninstal.exe", buf); + sprintf(display_name, "Vim " VIM_VERSION_SHORT); + sprintf(uninstall_string, "%suninstal.exe", buf); } else { - sprintf(display_name, "Vim " VIM_VERSION_SHORT " (self-installing)"); - sprintf(uninstall_string, "%suninstall-gui.exe", buf); + sprintf(display_name, "Vim " VIM_VERSION_SHORT " (self-installing)"); + sprintf(uninstall_string, "%suninstall-gui.exe", buf); } lRet = register_uninstall( - HKEY_LOCAL_MACHINE, - "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT, - display_name, - uninstall_string); + HKEY_LOCAL_MACHINE, + "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT, + display_name, + uninstall_string); if (ERROR_SUCCESS != lRet) return FAIL; #endif /* WIN3264 */ diff --git a/src/ex_cmds.c b/src/ex_cmds.c index c0668cf0ef..602c340da4 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -3099,8 +3099,8 @@ theend: * ECMD_FORCEIT: ! used for Ex command * ECMD_ADDBUF: don't edit, just add to buffer list * oldwin: Should be "curwin" when editing a new buffer in the current - * window, NULL when splitting the window first. When not NULL info - * of the previous buffer for "oldwin" is stored. + * window, NULL when splitting the window first. When not NULL info + * of the previous buffer for "oldwin" is stored. * * return FAIL for failure, OK otherwise */ @@ -7232,8 +7232,8 @@ set_context_in_sign_cmd(xp, arg) cmd_idx = sign_cmd_idx(arg, end_subcmd); /* :sign {subcmd} {subcmd_args} - * | - * begin_subcmd_args */ + * | + * begin_subcmd_args */ begin_subcmd_args = skipwhite(end_subcmd); p = skiptowhite(begin_subcmd_args); if (*p == NUL) @@ -7261,8 +7261,8 @@ set_context_in_sign_cmd(xp, arg) /* expand last argument of subcmd */ /* :sign define {name} {args}... - * | - * p */ + * | + * p */ /* Loop until reaching last argument. */ do @@ -7275,8 +7275,8 @@ set_context_in_sign_cmd(xp, arg) p = vim_strchr(last, '='); /* :sign define {name} {args}... {last}= - * | | - * last p */ + * | | + * last p */ if (p == NUL) { /* Expand last argument name (before equal sign). */ diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 1105a87695..b9a9da3107 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3442,6 +3442,11 @@ set_one_cmd_context(xp, buff) */ switch (ea.cmdidx) { + case CMD_find: + case CMD_sfind: + case CMD_tabfind: + xp->xp_context = EXPAND_FILES_IN_PATH; + break; case CMD_cd: case CMD_chdir: case CMD_lcd: diff --git a/src/ex_getln.c b/src/ex_getln.c index b2e89e1927..153271b5cc 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -4099,6 +4099,7 @@ addstar(fname, len, context) int ends_in_star; if (context != EXPAND_FILES + && context != EXPAND_FILES_IN_PATH && context != EXPAND_SHELLCMD && context != EXPAND_DIRECTORIES) { @@ -4423,7 +4424,9 @@ ExpandFromContext(xp, pat, num_file, file, options) if (options & WILD_SILENT) flags |= EW_SILENT; - if (xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_DIRECTORIES) + if (xp->xp_context == EXPAND_FILES + || xp->xp_context == EXPAND_DIRECTORIES + || xp->xp_context == EXPAND_FILES_IN_PATH) { /* * Expand file or directory names. @@ -4453,6 +4456,8 @@ ExpandFromContext(xp, pat, num_file, file, options) if (xp->xp_context == EXPAND_FILES) flags |= EW_FILE; + else if (xp->xp_context == EXPAND_FILES_IN_PATH) + flags |= (EW_FILE | EW_PATH); else flags = (flags | EW_DIR) & ~EW_FILE; /* Expand wildcards, supporting %:h and the like. */ diff --git a/src/fileio.c b/src/fileio.c index cdbd01a125..d467ebad0f 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2970,8 +2970,8 @@ prepare_crypt_read(fp) return FAIL; method = get_crypt_method((char *)buffer, CRYPT_MAGIC_LEN + - CRYPT_SEED_LEN_MAX + - CRYPT_SALT_LEN_MAX); + CRYPT_SEED_LEN_MAX + + CRYPT_SALT_LEN_MAX); if (method < 0 || method != curbuf->b_p_cm) return FAIL; diff --git a/src/getchar.c b/src/getchar.c index 2718ec6aa9..f1a4dda06d 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -2941,7 +2941,7 @@ inchar(buf, maxlen, wait_time, tb_change_cnt) #if defined(FEAT_NETBEANS_INTG) /* Process the queued netbeans messages. */ - netbeans_parse_messages(); + netbeans_parse_messages(); #endif if (got_int || (script_char = getc(scriptin[curscript])) < 0) @@ -1383,7 +1383,7 @@ gui_set_shellsize(mustset, fit_to_display, direction) int screen_h; #ifdef FEAT_GUI_GTK int un_maximize = mustset; - int did_adjust = 0; + int did_adjust = 0; #endif int x = -1, y = -1; diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 05cbe0b4da..d8e2487382 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -790,7 +790,7 @@ focus_in_event(GtkWidget *widget, static gint focus_out_event(GtkWidget *widget UNUSED, - GdkEventFocus *event UNUSED, + GdkEventFocus *event UNUSED, gpointer data UNUSED) { gui_focus_change(FALSE); @@ -5456,7 +5456,7 @@ gui_mch_wait_for_chars(long wtime) #if defined(FEAT_NETBEANS_INTG) /* Process the queued netbeans messages. */ - netbeans_parse_messages(); + netbeans_parse_messages(); #endif /* diff --git a/src/gui_w32.c b/src/gui_w32.c index 8a663d98bd..cfd4b78571 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -2967,7 +2967,7 @@ dialog_callback( * codepage: use wide function and convert text. */ if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT && enc_codepage >= 0 && (int)GetACP() != enc_codepage) - { + { WCHAR *wp = (WCHAR *)alloc(IOSIZE * sizeof(WCHAR)); char_u *p; @@ -4828,7 +4828,7 @@ netbeans_draw_multisign_indicator(int row) int x; if (!netbeans_active()) - return; + return; x = 0; y = TEXT_Y(row); @@ -4855,10 +4855,10 @@ netbeans_init_winsock() int wsaerr; if (WSInitialized) - return; + return; wsaerr = WSAStartup(MAKEWORD(2, 2), &wsaData); if (wsaerr == 0) - WSInitialized = TRUE; + WSInitialized = TRUE; } #endif diff --git a/src/gui_w48.c b/src/gui_w48.c index 6e567f69eb..00d86fd0d7 100644 --- a/src/gui_w48.c +++ b/src/gui_w48.c @@ -941,7 +941,7 @@ _OnFindRepl(void) if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT && enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - findrep_wtoa(&s_findrep_struct, &s_findrep_struct_w); + findrep_wtoa(&s_findrep_struct, &s_findrep_struct_w); } # endif @@ -1999,7 +1999,7 @@ gui_mch_wait_for_chars(int wtime) #ifdef FEAT_NETBEANS_INTG /* Process the queued netbeans messages. */ - netbeans_parse_messages(); + netbeans_parse_messages(); #endif /* @@ -2619,7 +2619,7 @@ gui_mch_find_dialog(exarg_T *eap) if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT && enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - findrep_atow(&s_findrep_struct_w, &s_findrep_struct); + findrep_atow(&s_findrep_struct_w, &s_findrep_struct); s_findrep_hwnd = FindTextW( (LPFINDREPLACEW) &s_findrep_struct_w); } diff --git a/src/gui_x11.c b/src/gui_x11.c index 73bc76f763..f955bc85d3 100644 --- a/src/gui_x11.c +++ b/src/gui_x11.c @@ -3454,7 +3454,7 @@ gui_mch_register_sign(signfile) { /* Sign width is fixed at two columns now. if (sign->width > gui.sign_width) - gui.sign_width = sign->width + 8; */ + gui.sign_width = sign->width + 8; */ } else EMSG(_(e_signdata)); diff --git a/src/gui_xmebw.c b/src/gui_xmebw.c index 4e01765c6f..5b6508867c 100644 --- a/src/gui_xmebw.c +++ b/src/gui_xmebw.c @@ -143,10 +143,10 @@ static XtResource resources[] = XmPrimitiveClassExtRec xmEnhancedButtonPrimClassExtRec = { /* next_extension */ NULL, - /* record_type */ NULLQUARK, - /* version */ XmPrimitiveClassExtVersion, - /* record_size */ sizeof(XmPrimitiveClassExtRec), - /* widget_baseline */ XmInheritBaselineProc, + /* record_type */ NULLQUARK, + /* version */ XmPrimitiveClassExtVersion, + /* record_size */ sizeof(XmPrimitiveClassExtRec), + /* widget_baseline */ XmInheritBaselineProc, /* widget_display_rect */ XmInheritDisplayRectProc, /* widget_margins */ NULL }; diff --git a/src/if_python.c b/src/if_python.c index 1b0780158e..e017b7137f 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -1160,8 +1160,8 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookupDict) || (our_tv->v_type == VAR_DICT && our_tv->vval.v_dict != NULL)) { sprintf(ptrBuf, PRINTF_DECIMAL_LONG_U, - our_tv->v_type == VAR_LIST ? (long_u)our_tv->vval.v_list - : (long_u)our_tv->vval.v_dict); + our_tv->v_type == VAR_LIST ? (long_u)our_tv->vval.v_list + : (long_u)our_tv->vval.v_dict); result = PyDict_GetItemString(lookupDict, ptrBuf); if (result != NULL) { diff --git a/src/mbyte.c b/src/mbyte.c index 8a86859a90..3a83eb4820 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -3177,7 +3177,7 @@ show_utf8() clen = utf_ptr2len(line + i); } sprintf((char *)IObuff + rlen, "%02x ", - (line[i] == NL) ? NUL : line[i]); /* NUL is stored as NL */ + (line[i] == NL) ? NUL : line[i]); /* NUL is stored as NL */ --clen; rlen += (int)STRLEN(IObuff + rlen); if (rlen > IOSIZE - 20) diff --git a/src/menu.c b/src/menu.c index 3ab957cf61..10becdbdaa 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1365,7 +1365,7 @@ get_menu_name(xp, idx) str = menu->dname; #ifdef FEAT_MULTI_LANG if (menu->en_dname == NULL) - should_advance = TRUE; + should_advance = TRUE; } #endif else @@ -1374,8 +1374,8 @@ get_menu_name(xp, idx) #ifdef FEAT_MULTI_LANG if (should_advance) #endif - /* Advance to next menu entry. */ - menu = menu->next; + /* Advance to next menu entry. */ + menu = menu->next; #ifdef FEAT_MULTI_LANG should_advance = !should_advance; @@ -1445,18 +1445,18 @@ get_menu_names(xp, idx) } else #ifdef FEAT_MULTI_LANG - { - if (should_advance) - str = menu->en_dname; - else - { + { + if (should_advance) + str = menu->en_dname; + else + { #endif - str = menu->dname; + str = menu->dname; #ifdef FEAT_MULTI_LANG - if (menu->en_dname == NULL) - should_advance = TRUE; - } - } + if (menu->en_dname == NULL) + should_advance = TRUE; + } + } #endif } else @@ -1465,8 +1465,8 @@ get_menu_names(xp, idx) #ifdef FEAT_MULTI_LANG if (should_advance) #endif - /* Advance to next menu entry. */ - menu = menu->next; + /* Advance to next menu entry. */ + menu = menu->next; #ifdef FEAT_MULTI_LANG should_advance = !should_advance; @@ -1514,7 +1514,7 @@ menu_name_equal(name, menu) if (menu->en_name != NULL && (menu_namecmp(name,menu->en_name) || menu_namecmp(name,menu->en_dname))) - return TRUE; + return TRUE; #endif return menu_namecmp(name, menu->name) || menu_namecmp(name, menu->dname); } diff --git a/src/message.c b/src/message.c index c00846e0ff..7c94cbf8b2 100644 --- a/src/message.c +++ b/src/message.c @@ -808,7 +808,7 @@ delete_first_msg() p = first_msg_hist; first_msg_hist = p->next; if (first_msg_hist == NULL) - last_msg_hist = NULL; /* history is empty */ + last_msg_hist = NULL; /* history is empty */ vim_free(p->msg); vim_free(p); --msg_hist_len; diff --git a/src/misc1.c b/src/misc1.c index d87696d5cd..675c2e77a5 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -9217,6 +9217,205 @@ unix_expandpath(gap, path, wildoff, flags, didstar) } #endif +#if defined(FEAT_SEARCHPATH) +static int find_previous_pathsep __ARGS((char_u *path, char_u **psep)); +static int is_unique __ARGS((char_u *maybe_unique, garray_T *gap, int i)); +static void uniquefy_paths __ARGS((garray_T *gap, char_u *pattern)); +static int expand_in_path __ARGS((garray_T *gap, char_u *pattern, int flags)); + +/* + * Moves psep to the previous path separator in path, starting from the + * end of path. + * Returns FAIL is psep ends up at the beginning of path. + */ + static int +find_previous_pathsep(path, psep) + char_u *path; + char_u **psep; +{ + /* skip the current separator */ + if (*psep > path && vim_ispathsep(**psep)) + (*psep)--; + + /* find the previous separator */ + while (*psep > path && !vim_ispathsep(**psep)) + (*psep)--; + + if (*psep != path && vim_ispathsep(**psep)) + return OK; + + return FAIL; +} + +/* + * Returns TRUE if maybe_unique is unique wrt other_paths in gap. maybe_unique + * is the end portion of ((char_u **)gap->ga_data)[i]. + */ + static int +is_unique(maybe_unique, gap, i) + char_u *maybe_unique; + garray_T *gap; + int i; +{ + int j; + int candidate_len; + int other_path_len; + char_u *rival; + char_u **other_paths; + + other_paths = (gap->ga_data != NULL) ? (char_u **)gap->ga_data + : (char_u **)""; + + for (j = 0; j < gap->ga_len && !got_int; j++) + { + ui_breakcheck(); + /* don't compare it with itself */ + if (j == i) + continue; + + candidate_len = STRLEN(maybe_unique); + other_path_len = STRLEN(other_paths[j]); + + if (other_path_len < candidate_len) + continue; /* it's different */ + + rival = other_paths[j] + other_path_len - candidate_len; + + if (fnamecmp(maybe_unique, rival) == 0) + return FALSE; + } + + return TRUE; +} + +/* + * Sorts, removes duplicates and modifies all the fullpath names in gap so that + * they are unique with respect to each other while conserving the part that + * matches the pattern. Beware, this is at least O(n^2) wrt gap->ga_len. + */ + static void +uniquefy_paths(gap, pattern) + garray_T *gap; + char_u *pattern; +{ + int i; + int j; + int len; + char_u *pathsep_p; + char_u *path; + char_u **fnames = (char_u **) gap->ga_data; + + int sort_again = 0; + char_u *pat; + char_u *file_pattern; + regmatch_T regmatch; + + /* Remove duplicate entries */ + sort_strings(fnames, gap->ga_len); + for (i = 0; i < gap->ga_len - 1; i++) + if (fnamecmp(fnames[i], fnames[i+1]) == 0) + { + vim_free(fnames[i]); + for (j = i+1; j < gap->ga_len; j++) + fnames[j-1] = fnames[j]; + gap->ga_len--; + i--; + } + + /* + * We need to prepend a '*' at the beginning of file_pattern so that the + * regex matches anywhere in the path. FIXME: is this valid for all + * possible pattern? + */ + len = STRLEN(pattern); + file_pattern = alloc(len + 2); + file_pattern[0] = '*'; + file_pattern[1] = '\0'; + STRCAT(file_pattern, pattern); + pat = file_pat_to_reg_pat(file_pattern, NULL, NULL, TRUE); + vim_free(file_pattern); + regmatch.rm_ic = TRUE; /* always ignore case */ + + if (pat != NULL) + { + regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); + vim_free(pat); + } + if (pat == NULL || regmatch.regprog == NULL) + return; + + for (i = 0; i < gap->ga_len; i++) + { + path = fnames[i]; + len = STRLEN(path); + + /* we start at the end of the path */ + pathsep_p = path + len - 1; + + while (find_previous_pathsep(path, &pathsep_p)) + if (vim_regexec(®match, pathsep_p + 1, (colnr_T)0) + && is_unique(pathsep_p, gap, i)) + { + sort_again = 1; + mch_memmove(path, pathsep_p + 1, STRLEN(pathsep_p)); + break; + } + } + + if (sort_again) + sort_strings(fnames, gap->ga_len); +} + +/* + * Calls globpath with 'path' values for the given pattern and stores + * the result in gap. + * Returns the total number of matches. + */ + static int +expand_in_path(gap, pattern, flags) + garray_T *gap; + char_u *pattern; + int flags; /* EW_* flags */ +{ + int c = 0; + char_u *path_option = *curbuf->b_p_path == NUL + ? p_path : curbuf->b_p_path; + char_u *files; + char_u *s; /* start */ + char_u *e; /* end */ + + files = globpath(path_option, pattern, 0); + if (files == NULL) + return 0; + + /* Copy each path in files into gap */ + s = e = files; + while (*s != '\0') + { + while (*e != '\n' && *e != '\0') + e++; + if (*e == '\0') + { + addfile(gap, s, flags); + break; + } + else + { + /* *e is '\n' */ + *e = '\0'; + addfile(gap, s, flags); + e++; + s = e; + } + } + + c = gap->ga_len; + vim_free(files); + + return c; +} +#endif + /* * Generic wildcard expansion code. * @@ -9325,7 +9524,14 @@ gen_expand_wildcards(num_pat, pat, num_file, file, flags) * when EW_NOTFOUND is given. */ if (mch_has_exp_wildcard(p)) - add_pat = mch_expandpath(&ga, p, flags); + { +#if defined(FEAT_SEARCHPATH) + if (*p != '.' && !vim_ispathsep(*p) && (flags & EW_PATH)) + add_pat = expand_in_path(&ga, p, flags); + else +#endif + add_pat = mch_expandpath(&ga, p, flags); + } } if (add_pat == -1 || (add_pat == 0 && (fla |