To: vim-dev@vim.org Subject: Patch 6.2.474 (extra) Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.474 (extra, after 6.2.456) Problem: When Vim is starting up conversion is done unnecessarily. Failure to find the runtime files on Windows 98. (Randall W. Morris) Solution: Init enc_codepage negative, only use it when not negative. Don't use GetFileAttributesW() on Windows 98 or earlier. Files: src/globals.h, src/gui_w32.c, src/gui_w48.c, src/os_mswin.c, src/os_win32.c *** ../vim-6.2.473/src/globals.h Mon Apr 5 20:28:39 2004 --- src/globals.h Thu Apr 15 21:10:07 2004 *************** *** 669,675 **** EXTERN int enc_unicode INIT(= 0); /* 2: UCS-2 or UTF-16, 4: UCS-4 */ EXTERN int enc_utf8 INIT(= FALSE); /* UTF-8 encoded Unicode */ # ifdef WIN3264 ! EXTERN int enc_codepage INIT(= 0); /* codepage nr of 'encoding' */ # endif EXTERN int has_mbyte INIT(= 0); /* any multi-byte encoding */ --- 669,677 ---- EXTERN int enc_unicode INIT(= 0); /* 2: UCS-2 or UTF-16, 4: UCS-4 */ EXTERN int enc_utf8 INIT(= FALSE); /* UTF-8 encoded Unicode */ # ifdef WIN3264 ! /* Codepage nr of 'encoding'. Negative means it's not been set yet, zero ! * means 'encoding' is not a valid codepage. */ ! EXTERN int enc_codepage INIT(= -1); # endif EXTERN int has_mbyte INIT(= 0); /* any multi-byte encoding */ *** ../vim-6.2.473/src/gui_w32.c Tue Mar 30 22:11:17 2004 --- src/gui_w32.c Thu Apr 15 21:13:07 2004 *************** *** 1832,1838 **** /* Check if the Unicode buffer exists and is big enough. Create it * with the same lengt as the multi-byte string, the number of wide * characters is always equal or smaller. */ ! if ((enc_utf8 || (enc_codepage != 0 && (int)GetACP() != enc_codepage)) && (unicodebuf == NULL || len > unibuflen)) { vim_free(unicodebuf); --- 1831,1837 ---- /* Check if the Unicode buffer exists and is big enough. Create it * with the same lengt as the multi-byte string, the number of wide * characters is always equal or smaller. */ ! if ((enc_utf8 || (enc_codepage > 0 && (int)GetACP() != enc_codepage)) && (unicodebuf == NULL || len > unibuflen)) { vim_free(unicodebuf); *************** *** 1875,1881 **** foptions, pcliprect, unicodebuf, clen, unicodepdy); len = cells; /* used for underlining */ } ! else if (enc_codepage != 0 && (int)GetACP() != enc_codepage) { /* If we want to display codepage data, and the current CP is not the * ANSI one, we need to go via Unicode. */ --- 1874,1880 ---- foptions, pcliprect, unicodebuf, clen, unicodepdy); len = cells; /* used for underlining */ } ! else if (enc_codepage > 0 && (int)GetACP() != enc_codepage) { /* If we want to display codepage data, and the current CP is not the * ANSI one, we need to go via Unicode. */ *** ../vim-6.2.473/src/gui_w48.c Tue Apr 6 21:31:48 2004 --- src/gui_w48.c Thu Apr 15 21:13:48 2004 *************** *** 2628,2634 **** char_u *icon) { #ifdef FEAT_MBYTE ! if (title != NULL && enc_codepage != (int)GetACP()) { WCHAR *wbuf; --- 2628,2634 ---- char_u *icon) { #ifdef FEAT_MBYTE ! if (title != NULL && enc_codepage >= 0 && enc_codepage != (int)GetACP()) { WCHAR *wbuf; *** ../vim-6.2.473/src/os_mswin.c Wed Apr 14 14:10:23 2004 --- src/os_mswin.c Thu Apr 15 21:15:07 2004 *************** *** 451,457 **** if (p > buf && (*p == '\\' || *p == '/') && p[-1] != ':') *p = NUL; #ifdef FEAT_MBYTE ! if ((int)GetACP() != enc_codepage) { WCHAR *wp = enc_to_ucs2(buf, NULL); int n; --- 451,457 ---- if (p > buf && (*p == '\\' || *p == '/') && p[-1] != ':') *p = NUL; #ifdef FEAT_MBYTE ! if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { WCHAR *wp = enc_to_ucs2(buf, NULL); int n; *************** *** 1034,1040 **** lenp = &len_loc; } ! if (enc_codepage != 0) { /* We can do any CP### -> UCS-2 in one pass, and we can do it * without iconv() (convert_* may need iconv). */ --- 1034,1040 ---- lenp = &len_loc; } ! if (enc_codepage > 0) { /* We can do any CP### -> UCS-2 in one pass, and we can do it * without iconv() (convert_* may need iconv). */ *************** *** 1093,1099 **** lenp = &len_loc; } ! if (enc_codepage != 0) { /* We can do any UCS-2 -> CP### in one pass. */ int length; --- 1093,1099 ---- lenp = &len_loc; } ! if (enc_codepage > 0) { /* We can do any UCS-2 -> CP### in one pass. */ int length; *** ../vim-6.2.473/src/os_win32.c Wed Apr 14 10:43:29 2004 --- src/os_win32.c Thu Apr 15 21:20:20 2004 *************** *** 2366,2372 **** char_u *name) { #ifdef FEAT_MBYTE ! if ((int)GetACP() != enc_codepage) { WCHAR *p = enc_to_ucs2(name, NULL); long n; --- 2366,2376 ---- char_u *name) { #ifdef FEAT_MBYTE ! /* Apparently GetFileAttributesW() exists on Win95/98/ME, but it doesn't ! * work. */ ! PlatformId(); ! if (g_PlatformId == VER_PLATFORM_WIN32_NT ! && enc_codepage >= 0 && (int)GetACP() != enc_codepage) { WCHAR *p = enc_to_ucs2(name, NULL); long n; *************** *** 2393,2399 **** { perm |= FILE_ATTRIBUTE_ARCHIVE; /* file has changed, set archive bit */ #ifdef FEAT_MBYTE ! if ((int)GetACP() != enc_codepage) { WCHAR *p = enc_to_ucs2(name, NULL); long n; --- 2397,2403 ---- { perm |= FILE_ATTRIBUTE_ARCHIVE; /* file has changed, set archive bit */ #ifdef FEAT_MBYTE ! if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { WCHAR *p = enc_to_ucs2(name, NULL); long n; *************** *** 2419,2425 **** #ifdef FEAT_MBYTE WCHAR *p = NULL; ! if ((int)GetACP() != enc_codepage) p = enc_to_ucs2(name, NULL); #endif --- 2423,2433 ---- #ifdef FEAT_MBYTE WCHAR *p = NULL; ! /* Apparently GetFileAttributesW() exists on Win95/98/ME, but it doesn't ! * work. */ ! PlatformId(); ! if (g_PlatformId == VER_PLATFORM_WIN32_NT ! && enc_codepage >= 0 && (int)GetACP() != enc_codepage) p = enc_to_ucs2(name, NULL); #endif *************** *** 4014,4020 **** WCHAR *wn = NULL; int n; ! if ((int)GetACP() != enc_codepage) { wn = enc_to_ucs2(name, NULL); if (wn != NULL) --- 4022,4028 ---- WCHAR *wn = NULL; int n; ! if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { wn = enc_to_ucs2(name, NULL); if (wn != NULL) *************** *** 4155,4161 **** WCHAR *wnew = NULL; int retval = 0; ! if ((int)GetACP() != enc_codepage) { wold = enc_to_ucs2((char_u *)pszOldFile, NULL); wnew = enc_to_ucs2((char_u *)pszNewFile, NULL); --- 4163,4169 ---- WCHAR *wnew = NULL; int retval = 0; ! if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { wold = enc_to_ucs2((char_u *)pszOldFile, NULL); wnew = enc_to_ucs2((char_u *)pszNewFile, NULL); *************** *** 4268,4274 **** #ifdef FEAT_MBYTE WCHAR *wn = NULL; ! if ((int)GetACP() != enc_codepage) wn = enc_to_ucs2(n, NULL); #endif --- 4276,4282 ---- #ifdef FEAT_MBYTE WCHAR *wn = NULL; ! if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) wn = enc_to_ucs2(n, NULL); #endif *************** *** 4378,4384 **** WCHAR *wn; int f; ! if ((int)GetACP() != enc_codepage) { wn = enc_to_ucs2(name, NULL); if (wn != NULL) --- 4386,4392 ---- WCHAR *wn; int f; ! if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { wn = enc_to_ucs2(name, NULL); if (wn != NULL) *************** *** 4401,4407 **** WCHAR *wn, *wm; FILE *f; ! if ((int)GetACP() != enc_codepage) { wn = enc_to_ucs2(name, NULL); wm = enc_to_ucs2(mode, NULL); --- 4409,4415 ---- 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); *** ../vim-6.2.473/src/version.c Thu Apr 15 20:45:41 2004 --- src/version.c Fri Apr 16 11:03:59 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 474, /**/ -- If an elephant is left tied to a parking meter, the parking fee has to be paid just as it would for a vehicle. [real standing law in Florida, United States of America] /// 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 ///