To: vim_dev@googlegroups.com Subject: Patch 7.4.2195 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.2195 Problem: MS-Windows: The vimrun program does not support Unicode. Solution: Use GetCommandLineW(). Cleanup old #ifdefs. (Ken Takata) Files: src/vimrun.c *** ../vim-7.4.2194/src/vimrun.c 2015-10-13 17:52:55.921988351 +0200 --- src/vimrun.c 2016-08-10 21:52:15.854044151 +0200 *************** *** 17,105 **** #include #include ! #ifndef __CYGWIN__ ! # include #endif #ifdef __BORLANDC__ - extern char * - #ifdef _RTLDLL - __import - #endif - _oscmd; # define _kbhit kbhit # define _getch getch - #else - # ifdef __MINGW32__ - # ifndef WIN32_LEAN_AND_MEAN - # define WIN32_LEAN_AND_MEAN - # endif - # include - # else - # ifdef __CYGWIN__ - # ifndef WIN32_LEAN_AND_MEAN - # define WIN32_LEAN_AND_MEAN - # endif - # include - # define _getch getchar - # else - extern char *_acmdln; - # endif - # endif #endif int main(void) { ! const char *p; ! int retval; ! int inquote = 0; ! int silent = 0; - #ifdef __BORLANDC__ - p = _oscmd; - #else - # if defined(__MINGW32__) || defined(__CYGWIN__) - p = (const char *)GetCommandLine(); - # else - p = _acmdln; - # endif - #endif /* * Skip the executable name, which might be in "". */ while (*p) { ! if (*p == '"') inquote = !inquote; ! else if (!inquote && *p == ' ') { ++p; break; } ++p; } ! while (*p == ' ') ++p; /* * "-s" argument: don't wait for a key hit. */ ! if (p[0] == '-' && p[1] == 's' && p[2] == ' ') { silent = 1; p += 3; ! while (*p == ' ') ++p; } /* Print the command, including quotes and redirection. */ ! puts(p); /* * Do it! */ ! retval = system(p); if (retval == -1) perror("vimrun system(): "); --- 17,82 ---- #include #include ! #include ! #ifndef WIN32_LEAN_AND_MEAN ! # define WIN32_LEAN_AND_MEAN #endif + #include #ifdef __BORLANDC__ # define _kbhit kbhit # define _getch getch #endif int main(void) { ! const wchar_t *p; ! int retval; ! int inquote = 0; ! int silent = 0; ! HANDLE hstdout; ! DWORD written; ! ! p = (const wchar_t *)GetCommandLineW(); /* * Skip the executable name, which might be in "". */ while (*p) { ! if (*p == L'"') inquote = !inquote; ! else if (!inquote && *p == L' ') { ++p; break; } ++p; } ! while (*p == L' ') ++p; /* * "-s" argument: don't wait for a key hit. */ ! if (p[0] == L'-' && p[1] == L's' && p[2] == L' ') { silent = 1; p += 3; ! while (*p == L' ') ++p; } /* Print the command, including quotes and redirection. */ ! hstdout = GetStdHandle(STD_OUTPUT_HANDLE); ! WriteConsoleW(hstdout, p, wcslen(p), &written, NULL); ! WriteConsoleW(hstdout, L"\r\n", 2, &written, NULL); /* * Do it! */ ! retval = _wsystem(p); if (retval == -1) perror("vimrun system(): "); *************** *** 110,119 **** { puts("Hit any key to close this window..."); - #ifndef __CYGWIN__ while (_kbhit()) (void)_getch(); - #endif (void)_getch(); } --- 87,94 ---- *** ../vim-7.4.2194/src/version.c 2016-08-10 21:36:19.319004255 +0200 --- src/version.c 2016-08-10 21:53:51.361163542 +0200 *************** *** 765,766 **** --- 765,768 ---- { /* Add new patch number below this line */ + /**/ + 2195, /**/ -- A)bort, R)etry, D)o it right this time /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///