From 3f80a1fc6eb4f5a0f7103adcf533f614df5efb43 Mon Sep 17 00:00:00 2001 From: edyfox Date: Thu, 29 Jan 2009 02:57:41 +0000 Subject: [PATCH] Merged from the latest developing branch. git-svn-id: https://vim.svn.sourceforge.net/svnroot/vim/trunk@1339 2a77ed30-b011-0410-a7ad-c7884a0aa172 --- src/eval.c | 15 +++++----- src/ex_docmd.c | 47 ++++++++++++++++++++++++++--- src/gui_w32.c | 32 +++++++++++++++++++- src/gui_w48.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- src/if_cscope.c | 12 ++++++-- src/if_ole.cpp | 8 +++-- src/version.c | 10 +++++++ 7 files changed, 196 insertions(+), 20 deletions(-) diff --git a/src/eval.c b/src/eval.c index bc86a559..76a6044a 100644 --- a/src/eval.c +++ b/src/eval.c @@ -7918,9 +7918,9 @@ get_func_tv(name, len, rettv, arg, firstline, lastline, doesrange, else if (!aborting()) { if (argcount == MAX_FUNC_ARGS) - emsg_funcname("E740: Too many arguments for function %s", name); + emsg_funcname(N_("E740: Too many arguments for function %s"), name); else - emsg_funcname("E116: Invalid arguments for function %s", name); + emsg_funcname(N_("E116: Invalid arguments for function %s"), name); } while (--argcount >= 0) @@ -8153,6 +8153,7 @@ call_func(name, len, rettv, argcount, argvars, firstline, lastline, /* * Give an error message with a function name. Handle things. + * "ermsg" is to be passed without translation, use N_() instead of _(). */ static void emsg_funcname(ermsg, name) @@ -19867,7 +19868,7 @@ ex_function(eap) } } else - emsg_funcname("E123: Undefined function: %s", name); + emsg_funcname(N_("E123: Undefined function: %s"), name); } goto ret_free; } @@ -19911,7 +19912,7 @@ ex_function(eap) : eval_isnamec(arg[j]))) ++j; if (arg[j] != NUL) - emsg_funcname(_(e_invarg2), arg); + emsg_funcname(e_invarg2, arg); } } @@ -20183,7 +20184,7 @@ ex_function(eap) v = find_var(name, &ht); if (v != NULL && v->di_tv.v_type == VAR_FUNC) { - emsg_funcname("E707: Function name conflicts with variable: %s", + emsg_funcname(N_("E707: Function name conflicts with variable: %s"), name); goto erret; } @@ -20198,7 +20199,7 @@ ex_function(eap) } if (fp->uf_calls > 0) { - emsg_funcname("E127: Cannot redefine function %s: It is in use", + emsg_funcname(N_("E127: Cannot redefine function %s: It is in use"), name); goto erret; } @@ -21477,7 +21478,7 @@ call_user_func(fp, argcount, argvars, rettv, firstline, lastline, selfdict) /* * Return TRUE if items in "fc" do not have "copyID". That means they are not - * referenced from anywyere. + * referenced from anywhere. */ static int can_free_funccal(fc, copyID) diff --git a/src/ex_docmd.c b/src/ex_docmd.c index b060e63e..b5d76c1e 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -5482,6 +5482,9 @@ invalid_count: return OK; } +/* + * ":command ..." + */ static void ex_command(eap) exarg_T *eap; @@ -5914,6 +5917,7 @@ do_ucmd(eap) char_u *start; char_u *end; + char_u *ksp; size_t len, totlen; size_t split_len = 0; @@ -5930,16 +5934,51 @@ do_ucmd(eap) /* * Replace <> in the command by the arguments. + * First round: "buf" is NULL, compute length, allocate "buf". + * Second round: copy result into "buf". */ buf = NULL; for (;;) { - p = cmd->uc_rep; - q = buf; + p = cmd->uc_rep; /* source */ + q = buf; /* destinateion */ totlen = 0; - while ((start = vim_strchr(p, '<')) != NULL - && (end = vim_strchr(start + 1, '>')) != NULL) + + for (;;) { + start = vim_strchr(p, '<'); + if (start != NULL) + end = vim_strchr(start + 1, '>'); + if (buf != NULL) + { + ksp = vim_strchr(p, K_SPECIAL); + if (ksp != NULL && (start == NULL || ksp < start || end == NULL) + && ((ksp[1] == KS_SPECIAL && ksp[2] == KE_FILLER) +# ifdef FEAT_GUI + || (ksp[1] == KS_EXTRA && ksp[2] == (int)KE_CSI) +# endif + )) + { + /* K_SPECIAL han been put in the buffer as K_SPECIAL + * KS_SPECIAL KE_FILLER, like for mappings, but + * do_cmdline() doesn't handle that, so convert it back. + * Also change K_SPECIAL KS_EXTRA KE_CSI into CSI. */ + len = ksp - p; + if (len > 0) + { + mch_memmove(q, p, len); + q += len; + } + *q++ = ksp[1] == KS_SPECIAL ? K_SPECIAL : CSI; + p = ksp + 3; + continue; + } + } + + /* break if there no is found */ + if (start == NULL || end == NULL) + break; + /* Include the '>' */ ++end; diff --git a/src/gui_w32.c b/src/gui_w32.c index a36f9766..164e8c61 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -1582,6 +1582,17 @@ gui_mch_init(void) s_findrep_struct.lpstrReplaceWith[0] = NUL; s_findrep_struct.wFindWhatLen = MSWIN_FR_BUFSIZE; s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE; +# if defined(FEAT_MBYTE) && defined(WIN3264) + s_findrep_struct_w.lStructSize = sizeof(s_findrep_struct_w); + s_findrep_struct_w.lpstrFindWhat = + (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR)); + s_findrep_struct_w.lpstrFindWhat[0] = NUL; + s_findrep_struct_w.lpstrReplaceWith = + (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR)); + s_findrep_struct_w.lpstrReplaceWith[0] = NUL; + s_findrep_struct_w.wFindWhatLen = MSWIN_FR_BUFSIZE; + s_findrep_struct_w.wReplaceWithLen = MSWIN_FR_BUFSIZE; +# endif #endif theend: @@ -2938,8 +2949,27 @@ dialog_callback( /* If the edit box exists, copy the string. */ if (s_textfield != NULL) - GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2, + { +# if defined(FEAT_MBYTE) && defined(WIN3264) + /* If the OS is Windows NT, and 'encoding' differs from active + * 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; + + GetDlgItemTextW(hwnd, DLG_NONBUTTON_CONTROL + 2, wp, IOSIZE); + p = utf16_to_enc(wp, NULL); + vim_strncpy(s_textfield, p, IOSIZE); + vim_free(p); + vim_free(wp); + } + else +# endif + GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2, s_textfield, IOSIZE); + } /* * Need to check for IDOK because if the user just hits Return to diff --git a/src/gui_w48.c b/src/gui_w48.c index 4de0c763..123584bb 100644 --- a/src/gui_w48.c +++ b/src/gui_w48.c @@ -153,6 +153,9 @@ static int destroying = FALSE; /* call DestroyWindow() ourselves */ #ifdef MSWIN_FIND_REPLACE static UINT s_findrep_msg = 0; /* set in gui_w[16/32].c */ static FINDREPLACE s_findrep_struct; +# if defined(FEAT_MBYTE) && defined(WIN3264) +static FINDREPLACEW s_findrep_struct_w; +# endif static HWND s_findrep_hwnd = NULL; static int s_findrep_is_find; /* TRUE for find dialog, FALSE for find/replace dialog */ @@ -884,6 +887,45 @@ _OnMenu( #endif #ifdef MSWIN_FIND_REPLACE +# if defined(FEAT_MBYTE) && defined(WIN3264) +/* + * copy useful data from structure LPFINDREPLACE to structure LPFINDREPLACEW + */ + static void +findrep_atow(LPFINDREPLACEW lpfrw, LPFINDREPLACE lpfr) +{ + WCHAR *wp; + + lpfrw->hwndOwner = lpfr->hwndOwner; + lpfrw->Flags = lpfr->Flags; + + wp = enc_to_utf16(lpfr->lpstrFindWhat, NULL); + wcsncpy(lpfrw->lpstrFindWhat, wp, lpfrw->wFindWhatLen - 1); + vim_free(wp); + + /* the field "lpstrReplaceWith" doesn't need to be copied */ +} + +/* + * copy useful data from structure LPFINDREPLACEW to structure LPFINDREPLACE + */ + static void +findrep_wtoa(LPFINDREPLACE lpfr, LPFINDREPLACEW lpfrw) +{ + char_u *p; + + lpfr->Flags = lpfrw->Flags; + + p = utf16_to_enc(lpfrw->lpstrFindWhat, NULL); + vim_strncpy(lpfr->lpstrFindWhat, p, lpfr->wFindWhatLen - 1); + vim_free(p); + + p = utf16_to_enc(lpfrw->lpstrReplaceWith, NULL); + vim_strncpy(lpfr->lpstrReplaceWith, p, lpfr->wReplaceWithLen - 1); + vim_free(p); +} +# endif + /* * Handle a Find/Replace window message. */ @@ -893,6 +935,16 @@ _OnFindRepl(void) int flags = 0; int down; +# if defined(FEAT_MBYTE) && defined(WIN3264) + /* If the OS is Windows NT, and 'encoding' differs from active codepage: + * convert text from wide string. */ + if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT + && enc_codepage >= 0 && (int)GetACP() != enc_codepage) + { + findrep_wtoa(&s_findrep_struct, &s_findrep_struct_w); + } +# endif + if (s_findrep_struct.Flags & FR_DIALOGTERM) /* Give main window the focus back. */ (void)SetFocus(s_hwnd); @@ -1663,8 +1715,17 @@ process_message(void) if (msg.message == WM_OLE) { char_u *str = (char_u *)msg.lParam; - add_to_input_buf(str, (int)STRLEN(str)); - vim_free(str); + if (str == NULL || *str == NUL) + { + /* Message can't be ours, forward it. Fixes problem with Ultramon + * 3.0.4 */ + DispatchMessage(&msg); + } + else + { + add_to_input_buf(str, (int)STRLEN(str)); + vim_free(str); /* was allocated in CVim::SendKeys() */ + } return; } #endif @@ -2553,7 +2614,19 @@ gui_mch_find_dialog(exarg_T *eap) if (!IsWindow(s_findrep_hwnd)) { initialise_findrep(eap->arg); - s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct); +# if defined(FEAT_MBYTE) && defined(WIN3264) + /* If the OS is Windows NT, and 'encoding' differs from active + * codepage: convert text and use wide function. */ + if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT + && enc_codepage >= 0 && (int)GetACP() != enc_codepage) + { + findrep_atow(&s_findrep_struct_w, &s_findrep_struct); + s_findrep_hwnd = FindTextW( + (LPFINDREPLACEW) &s_findrep_struct_w); + } + else +# endif + s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct); } set_window_title(s_findrep_hwnd, @@ -2578,7 +2651,18 @@ gui_mch_replace_dialog(exarg_T *eap) if (!IsWindow(s_findrep_hwnd)) { initialise_findrep(eap->arg); - s_findrep_hwnd = ReplaceText((LPFINDREPLACE) &s_findrep_struct); +# if defined(FEAT_MBYTE) && defined(WIN3264) + if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT + && enc_codepage >= 0 && (int)GetACP() != enc_codepage) + { + findrep_atow(&s_findrep_struct_w, &s_findrep_struct); + s_findrep_hwnd = ReplaceTextW( + (LPFINDREPLACEW) &s_findrep_struct_w); + } + else +# endif + s_findrep_hwnd = ReplaceText( + (LPFINDREPLACE) &s_findrep_struct); } set_window_title(s_findrep_hwnd, diff --git a/src/if_cscope.c b/src/if_cscope.c index 4dff1163..a9a0506b 100644 --- a/src/if_cscope.c +++ b/src/if_cscope.c @@ -1177,8 +1177,16 @@ cs_help(eap) (void)MSG_PUTS(_("cscope commands:\n")); while (cmdp->name != NULL) { - (void)smsg((char_u *)_("%-5s: %-30s (Usage: %s)"), - cmdp->name, _(cmdp->help), cmdp->usage); + char *help = _(cmdp->help); + int space_cnt = 30 - vim_strsize((char_u *)help); + + /* Use %*s rather than %30s to ensure proper alignment in utf-8 */ + if (space_cnt < 0) + space_cnt = 0; + (void)smsg((char_u *)_("%-5s: %s%*s (Usage: %s)"), + cmdp->name, + help, space_cnt, " ", + cmdp->usage); if (strcmp(cmdp->name, "find") == 0) MSG_PUTS(_("\n" " c: Find functions calling this function\n" diff --git a/src/if_ole.cpp b/src/if_ole.cpp index b2057f97..fc3077df 100644 --- a/src/if_ole.cpp +++ b/src/if_ole.cpp @@ -353,9 +353,13 @@ CVim::SendKeys(BSTR keys) } /* Pass the string to the main input loop. The memory will be freed when - * the message is processed. + * the message is processed. Except for an empty message, we don't need + * to post it then. */ - PostMessage(NULL, WM_OLE, 0, (LPARAM)str); + if (*str == NUL) + vim_free(str); + else + PostMessage(NULL, WM_OLE, 0, (LPARAM)str); return S_OK; } diff --git a/src/version.c b/src/version.c index b04c8816..06abbfc5 100644 --- a/src/version.c +++ b/src/version.c @@ -677,6 +677,16 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 93, +/**/ + 92, +/**/ + 91, +/**/ + 90, +/**/ + 89, +/**/ 88, /**/ 87, -- 2.11.4.GIT