To: vim-dev@vim.org Subject: Patch 6.3a.026 (extra) Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.3a.026 (extra, after 6.3a.008) Problem: Editing files on Windows 98 doesn't work when 'encoding' is "utf-8" (Antoine Mechelynck) Warning for missing function prototype. Solution: For all wide functions check if it failed because it is not implemented. Use ANSI function declaration for char_to_string(). Files: src/gui_w48.c, src/os_mswin.c, src/os_win32.c *** ../vim-6.3a.025/src/gui_w48.c Thu May 13 14:36:40 2004 --- src/gui_w48.c Sat May 15 15:11:28 2004 *************** *** 480,489 **** * Return the length. */ static int ! char_to_string(ch, string, slen) ! int ch; ! char_u *string; ! int slen; { int len; int i; --- 480,486 ---- * Return the length. */ static int ! char_to_string(int ch, char_u *string, int slen) { int len; int i; *************** *** 2711,2724 **** if (title != NULL && enc_codepage >= 0 && enc_codepage != (int)GetACP()) { WCHAR *wbuf; /* Convert the title from 'encoding' to ucs2. */ wbuf = (WCHAR *)enc_to_ucs2(title, NULL); if (wbuf != NULL) { ! SetWindowTextW(s_hwnd, wbuf); vim_free(wbuf); ! return; } } #endif --- 2708,2724 ---- if (title != NULL && enc_codepage >= 0 && enc_codepage != (int)GetACP()) { WCHAR *wbuf; + int n; /* Convert the title from 'encoding' to ucs2. */ wbuf = (WCHAR *)enc_to_ucs2(title, NULL); if (wbuf != NULL) { ! n = SetWindowTextW(s_hwnd, wbuf); vim_free(wbuf); ! if (n != 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) ! return; ! /* Retry with non-wide function (for Windows 98). */ } } #endif *************** *** 3128,3139 **** for (i = 0; i < cFiles; ++i) { #ifdef FEAT_MBYTE ! DragQueryFileW(hDrop, i, szFile, BUFPATHLEN); ! fnames[i] = ucs2_to_enc(szFile, NULL); ! #else ! DragQueryFile(hDrop, i, szFile, BUFPATHLEN); ! fnames[i] = vim_strsave(szFile); #endif } DragFinish(hDrop); --- 3128,3141 ---- for (i = 0; i < cFiles; ++i) { #ifdef FEAT_MBYTE ! if (DragQueryFileW(hDrop, i, szFile, BUFPATHLEN) > 0) ! fnames[i] = ucs2_to_enc(szFile, NULL); ! else #endif + { + DragQueryFile(hDrop, i, szFile, BUFPATHLEN); + fnames[i] = vim_strsave(szFile); + } } DragFinish(hDrop); *** ../vim-6.3a.025/src/os_mswin.c Fri May 7 10:59:38 2004 --- src/os_mswin.c Sat May 15 15:17:39 2004 *************** *** 460,466 **** { n = _wstat(wp, (struct _stat *)stp); vim_free(wp); ! return n; } } #endif --- 460,470 ---- { n = _wstat(wp, (struct _stat *)stp); vim_free(wp); ! if (n >= 0) ! return n; ! /* Retry with non-wide function (for Windows 98). Can't use ! * GetLastError() here and it's unclear what errno gets set to if ! * the _wstat() fails for missing wide functions. */ } } #endif *** ../vim-6.3a.025/src/os_win32.c Tue May 11 17:54:06 2004 --- src/os_win32.c Sat May 15 15:17:49 2004 *************** *** 4366,4372 **** vim_free(wn); wn = NULL; } ! (void)FindClose(hFile); } if (wn == NULL) #endif --- 4366,4373 ---- vim_free(wn); wn = NULL; } ! else ! (void)FindClose(hFile); } if (wn == NULL) #endif *************** *** 4469,4475 **** { f = _wopen(wn, flags, mode); vim_free(wn); ! return f; } } --- 4470,4480 ---- { f = _wopen(wn, flags, mode); vim_free(wn); ! if (f >= 0) ! return f; ! /* Retry with non-wide function (for Windows 98). Can't use ! * GetLastError() here and it's unclear what errno gets set to if ! * the _wopen() fails for missing wide functions. */ } } *************** *** 4483,4501 **** mch_fopen(char *name, char *mode) { WCHAR *wn, *wm; ! FILE *f; if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { wn = enc_to_ucs2(name, NULL); wm = enc_to_ucs2(mode, NULL); if (wn != NULL && wm != NULL) - { f = _wfopen(wn, wm); - return f; - } vim_free(wn); vim_free(wm); } return fopen(name, mode); --- 4488,4508 ---- mch_fopen(char *name, char *mode) { WCHAR *wn, *wm; ! FILE *f = NULL; if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { wn = enc_to_ucs2(name, NULL); wm = enc_to_ucs2(mode, NULL); if (wn != NULL && wm != NULL) f = _wfopen(wn, wm); vim_free(wn); vim_free(wm); + if (f != NULL) + return f; + /* Retry with non-wide function (for Windows 98). Can't use + * GetLastError() here and it's unclear what errno gets set to if + * the _wfopen() fails for missing wide functions. */ } return fopen(name, mode); *** ../vim-6.3a.025/src/version.c Sat May 15 12:24:16 2004 --- src/version.c Sat May 15 17:07:50 2004 *************** *** 643,644 **** --- 643,646 ---- { /* Add new patch number below this line */ + /**/ + 26, /**/ -- GUARD #1: Where'd you get the coconut? ARTHUR: We found them. GUARD #1: Found them? In Mercea? The coconut's tropical! ARTHUR: What do you mean? GUARD #1: Well, this is a temperate zone. The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///