comparison src/main.c @ 15868:7fad90423bd2 v8.1.0941

patch 8.1.0941: macros for MS-Windows are inconsistent commit https://github.com/vim/vim/commit/4f97475d326c2773a78561fb874e4f23c25cbcd9 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 17 17:44:42 2019 +0100 patch 8.1.0941: macros for MS-Windows are inconsistent Problem: Macros for MS-Windows are inconsistent, using "32", "3264 and others. Solution: Use MSWIN for all MS-Windows builds. Use FEAT_GUI_MSWIN for the GUI build. (Hirohito Higashi, closes #3932)
author Bram Moolenaar <Bram@vim.org>
date Sun, 17 Feb 2019 17:45:08 +0100
parents a6ca8cf07a98
children a246b020984c
comparison
equal deleted inserted replaced
15867:4a3823e692d3 15868:7fad90423bd2
9 9
10 #define EXTERN 10 #define EXTERN
11 #include "vim.h" 11 #include "vim.h"
12 12
13 #ifdef __CYGWIN__ 13 #ifdef __CYGWIN__
14 # ifndef WIN32 14 # ifndef MSWIN
15 # include <cygwin/version.h> 15 # include <cygwin/version.h>
16 # include <sys/cygwin.h> /* for cygwin_conv_to_posix_path() and/or 16 # include <sys/cygwin.h> /* for cygwin_conv_to_posix_path() and/or
17 * cygwin_conv_path() */ 17 * cygwin_conv_path() */
18 # endif 18 # endif
19 # include <limits.h> 19 # include <limits.h>
20 #endif 20 #endif
21 21
22 #if defined(WIN3264) && !defined(FEAT_GUI_W32) 22 #if defined(MSWIN) && !defined(FEAT_GUI_MSWIN)
23 # include "iscygpty.h" 23 # include "iscygpty.h"
24 #endif 24 #endif
25 25
26 /* Values for edit_type. */ 26 /* Values for edit_type. */
27 #define EDIT_NONE 0 /* no edit type yet */ 27 #define EDIT_NONE 0 /* no edit type yet */
117 * Do any system-specific initialisations. These can NOT use IObuff or 117 * Do any system-specific initialisations. These can NOT use IObuff or
118 * NameBuff. Thus emsg2() cannot be called! 118 * NameBuff. Thus emsg2() cannot be called!
119 */ 119 */
120 mch_early_init(); 120 mch_early_init();
121 121
122 #if defined(WIN32) 122 #ifdef MSWIN
123 /* 123 /*
124 * MinGW expands command line arguments, which confuses our code to 124 * MinGW expands command line arguments, which confuses our code to
125 * convert when 'encoding' changes. Get the unexpanded arguments. 125 * convert when 'encoding' changes. Get the unexpanded arguments.
126 */ 126 */
127 argc = get_cmd_argsW(&argv); 127 argc = get_cmd_argsW(&argv);
248 } 248 }
249 #endif 249 #endif
250 params.fname = alist_name(&GARGLIST[0]); 250 params.fname = alist_name(&GARGLIST[0]);
251 } 251 }
252 252
253 #if defined(WIN32) 253 #ifdef MSWIN
254 { 254 {
255 extern void set_alist_count(void); 255 extern void set_alist_count(void);
256 256
257 /* Remember the number of entries in the argument list. If it changes 257 /* Remember the number of entries in the argument list. If it changes
258 * we don't react on setting 'encoding'. */ 258 * we don't react on setting 'encoding'. */
852 check_scrollbind((linenr_T)0, 0L); 852 check_scrollbind((linenr_T)0, 0L);
853 TIME_MSG("diff scrollbinding"); 853 TIME_MSG("diff scrollbinding");
854 } 854 }
855 #endif 855 #endif
856 856
857 #if defined(WIN3264) && !defined(FEAT_GUI_W32) 857 #if defined(MSWIN) && !defined(FEAT_GUI_MSWIN)
858 mch_set_winsize_now(); /* Allow winsize changes from now on */ 858 mch_set_winsize_now(); /* Allow winsize changes from now on */
859 #endif 859 #endif
860 860
861 #if defined(FEAT_GUI) 861 #if defined(FEAT_GUI)
862 /* When tab pages were created, may need to update the tab pages line and 862 /* When tab pages were created, may need to update the tab pages line and
878 #ifdef FEAT_NETBEANS_INTG 878 #ifdef FEAT_NETBEANS_INTG
879 if (netbeansArg != NULL && strncmp("-nb", netbeansArg, 3) == 0) 879 if (netbeansArg != NULL && strncmp("-nb", netbeansArg, 3) == 0)
880 { 880 {
881 # ifdef FEAT_GUI 881 # ifdef FEAT_GUI
882 # if !defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK) \ 882 # if !defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK) \
883 && !defined(FEAT_GUI_W32) 883 && !defined(FEAT_GUI_MSWIN)
884 if (gui.in_use) 884 if (gui.in_use)
885 { 885 {
886 mch_errmsg(_("netbeans is not supported with this GUI\n")); 886 mch_errmsg(_("netbeans is not supported with this GUI\n"));
887 mch_exit(2); 887 mch_exit(2);
888 } 888 }
1532 #endif 1532 #endif
1533 #ifdef FEAT_EVAL 1533 #ifdef FEAT_EVAL
1534 if (garbage_collect_at_exit) 1534 if (garbage_collect_at_exit)
1535 garbage_collect(FALSE); 1535 garbage_collect(FALSE);
1536 #endif 1536 #endif
1537 #if defined(WIN32) 1537 #ifdef MSWIN
1538 free_cmd_argsW(); 1538 free_cmd_argsW();
1539 #endif 1539 #endif
1540 1540
1541 mch_exit(exitval); 1541 mch_exit(exitval);
1542 } 1542 }
1557 # if defined(FEAT_FLOAT) && defined(LC_NUMERIC) 1557 # if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
1558 /* Make sure strtod() uses a decimal point, not a comma. */ 1558 /* Make sure strtod() uses a decimal point, not a comma. */
1559 setlocale(LC_NUMERIC, "C"); 1559 setlocale(LC_NUMERIC, "C");
1560 # endif 1560 # endif
1561 1561
1562 # ifdef WIN32 1562 # ifdef MSWIN
1563 /* Apparently MS-Windows printf() may cause a crash when we give it 8-bit 1563 /* Apparently MS-Windows printf() may cause a crash when we give it 8-bit
1564 * text while it's expecting text in the current locale. This call avoids 1564 * text while it's expecting text in the current locale. This call avoids
1565 * that. */ 1565 * that. */
1566 setlocale(LC_CTYPE, "C"); 1566 setlocale(LC_CTYPE, "C");
1567 # endif 1567 # endif
1640 gui.dofork = FALSE; 1640 gui.dofork = FALSE;
1641 # endif 1641 # endif
1642 } 1642 }
1643 # endif 1643 # endif
1644 1644
1645 # if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) 1645 # if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN)
1646 # ifdef FEAT_GUI_W32 1646 # ifdef FEAT_GUI_MSWIN
1647 else if (STRICMP(argv[i], "--windowid") == 0) 1647 else if (STRICMP(argv[i], "--windowid") == 0)
1648 # else 1648 # else
1649 else if (STRICMP(argv[i], "--socketid") == 0) 1649 else if (STRICMP(argv[i], "--socketid") == 0)
1650 # endif 1650 # endif
1651 { 1651 {
1659 else 1659 else
1660 count = sscanf(argv[i + 1], SCANF_DECIMAL_LONG_U, &id); 1660 count = sscanf(argv[i + 1], SCANF_DECIMAL_LONG_U, &id);
1661 if (count != 1) 1661 if (count != 1)
1662 mainerr(ME_INVALID_ARG, (char_u *)argv[i]); 1662 mainerr(ME_INVALID_ARG, (char_u *)argv[i]);
1663 else 1663 else
1664 # ifdef FEAT_GUI_W32 1664 # ifdef FEAT_GUI_MSWIN
1665 win_socket_id = id; 1665 win_socket_id = id;
1666 # else 1666 # else
1667 gtk_socket_id = id; 1667 gtk_socket_id = id;
1668 # endif 1668 # endif
1669 i++; 1669 i++;
1940 --argc; 1940 --argc;
1941 ++argv; 1941 ++argv;
1942 } 1942 }
1943 } 1943 }
1944 #endif 1944 #endif
1945 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) 1945 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN)
1946 # ifdef FEAT_GUI_GTK 1946 # ifdef FEAT_GUI_GTK
1947 else if (STRNICMP(argv[0] + argv_idx, "socketid", 8) == 0) 1947 else if (STRNICMP(argv[0] + argv_idx, "socketid", 8) == 0)
1948 # else 1948 # else
1949 else if (STRNICMP(argv[0] + argv_idx, "windowid", 8) == 0) 1949 else if (STRNICMP(argv[0] + argv_idx, "windowid", 8) == 0)
1950 # endif 1950 # endif
2235 #endif 2235 #endif
2236 case 'T': /* "-T {terminal}" terminal name */ 2236 case 'T': /* "-T {terminal}" terminal name */
2237 case 'u': /* "-u {vimrc}" vim inits file */ 2237 case 'u': /* "-u {vimrc}" vim inits file */
2238 case 'U': /* "-U {gvimrc}" gvim inits file */ 2238 case 'U': /* "-U {gvimrc}" gvim inits file */
2239 case 'W': /* "-W {scriptout}" overwrite */ 2239 case 'W': /* "-W {scriptout}" overwrite */
2240 #ifdef FEAT_GUI_W32 2240 #ifdef FEAT_GUI_MSWIN
2241 case 'P': /* "-P {parent title}" MDI parent */ 2241 case 'P': /* "-P {parent title}" MDI parent */
2242 #endif 2242 #endif
2243 want_argument = TRUE; 2243 want_argument = TRUE;
2244 break; 2244 break;
2245 2245
2397 mch_errmsg("\"\n"); 2397 mch_errmsg("\"\n");
2398 mch_exit(2); 2398 mch_exit(2);
2399 } 2399 }
2400 break; 2400 break;
2401 2401
2402 #ifdef FEAT_GUI_W32 2402 #ifdef FEAT_GUI_MSWIN
2403 case 'P': /* "-P {parent title}" MDI parent */ 2403 case 'P': /* "-P {parent title}" MDI parent */
2404 gui_mch_set_parent(argv[0]); 2404 gui_mch_set_parent(argv[0]);
2405 break; 2405 break;
2406 #endif 2406 #endif
2407 } 2407 }
2443 vim_free(p); 2443 vim_free(p);
2444 p = r; 2444 p = r;
2445 } 2445 }
2446 } 2446 }
2447 #endif 2447 #endif
2448 #if defined(__CYGWIN32__) && !defined(WIN32) 2448 #if defined(__CYGWIN32__) && !defined(MSWIN)
2449 /* 2449 /*
2450 * If vim is invoked by non-Cygwin tools, convert away any 2450 * If vim is invoked by non-Cygwin tools, convert away any
2451 * DOS paths, so things like .swp files are created correctly. 2451 * DOS paths, so things like .swp files are created correctly.
2452 * Look for evidence of non-Cygwin paths before we bother. 2452 * Look for evidence of non-Cygwin paths before we bother.
2453 * This is only for when using the Unix files. 2453 * This is only for when using the Unix files.
2479 #else 2479 #else
2480 2 /* add buffer number now and use curbuf */ 2480 2 /* add buffer number now and use curbuf */
2481 #endif 2481 #endif
2482 ); 2482 );
2483 2483
2484 #if defined(WIN32) 2484 #ifdef MSWIN
2485 { 2485 {
2486 /* Remember this argument has been added to the argument list. 2486 /* Remember this argument has been added to the argument list.
2487 * Needed when 'encoding' is changed. */ 2487 * Needed when 'encoding' is changed. */
2488 used_file_arg(argv[0], parmp->literal, parmp->full_path, 2488 used_file_arg(argv[0], parmp->literal, parmp->full_path,
2489 # ifdef FEAT_DIFF 2489 # ifdef FEAT_DIFF
2559 { 2559 {
2560 mch_errmsg(_("Vim: Error: Failure to start gvim from NetBeans\n")); 2560 mch_errmsg(_("Vim: Error: Failure to start gvim from NetBeans\n"));
2561 exit(1); 2561 exit(1);
2562 } 2562 }
2563 #endif 2563 #endif
2564 #if defined(WIN3264) && !defined(FEAT_GUI_W32) 2564 #if defined(MSWIN) && !defined(FEAT_GUI_MSWIN)
2565 if (is_cygpty_used()) 2565 if (is_cygpty_used())
2566 { 2566 {
2567 # if defined(HAVE_BIND_TEXTDOMAIN_CODESET) \ 2567 # if defined(HAVE_BIND_TEXTDOMAIN_CODESET) \
2568 && defined(FEAT_GETTEXT) 2568 && defined(FEAT_GETTEXT)
2569 char *s, *tofree = NULL; 2569 char *s, *tofree = NULL;
3421 main_msg(_("-display <display>\tRun vim on <display> (also: --display)")); 3421 main_msg(_("-display <display>\tRun vim on <display> (also: --display)"));
3422 main_msg(_("--role <role>\tSet a unique role to identify the main window")); 3422 main_msg(_("--role <role>\tSet a unique role to identify the main window"));
3423 main_msg(_("--socketid <xid>\tOpen Vim inside another GTK widget")); 3423 main_msg(_("--socketid <xid>\tOpen Vim inside another GTK widget"));
3424 main_msg(_("--echo-wid\t\tMake gvim echo the Window ID on stdout")); 3424 main_msg(_("--echo-wid\t\tMake gvim echo the Window ID on stdout"));
3425 #endif 3425 #endif
3426 #ifdef FEAT_GUI_W32 3426 #ifdef FEAT_GUI_MSWIN
3427 main_msg(_("-P <parent title>\tOpen Vim inside parent application")); 3427 main_msg(_("-P <parent title>\tOpen Vim inside parent application"));
3428 main_msg(_("--windowid <HWND>\tOpen Vim inside another win32 widget")); 3428 main_msg(_("--windowid <HWND>\tOpen Vim inside another win32 widget"));
3429 #endif 3429 #endif
3430 3430
3431 #ifdef FEAT_GUI_GNOME 3431 #ifdef FEAT_GUI_GNOME
3458 #endif /* NO_VIM_MAIN */ 3458 #endif /* NO_VIM_MAIN */
3459 3459
3460 #if defined(STARTUPTIME) || defined(PROTO) 3460 #if defined(STARTUPTIME) || defined(PROTO)
3461 static struct timeval prev_timeval; 3461 static struct timeval prev_timeval;
3462 3462
3463 # ifdef WIN3264 3463 # ifdef MSWIN
3464 /* 3464 /*
3465 * Windows doesn't have gettimeofday(), although it does have struct timeval. 3465 * Windows doesn't have gettimeofday(), although it does have struct timeval.
3466 */ 3466 */
3467 static int 3467 static int
3468 gettimeofday(struct timeval *tv, char *dummy) 3468 gettimeofday(struct timeval *tv, char *dummy)
3565 static void 3565 static void
3566 set_progpath(char_u *argv0) 3566 set_progpath(char_u *argv0)
3567 { 3567 {
3568 char_u *val = argv0; 3568 char_u *val = argv0;
3569 3569
3570 # if defined(WIN32) 3570 # ifdef MSWIN
3571 /* A relative path containing a "/" will become invalid when using ":cd", 3571 /* A relative path containing a "/" will become invalid when using ":cd",
3572 * turn it into a full path. 3572 * turn it into a full path.
3573 * On MS-Windows "vim" should be expanded to "vim.exe", thus always do 3573 * On MS-Windows "vim" should be expanded to "vim.exe", thus always do
3574 * this. */ 3574 * this. */
3575 char_u *path = NULL; 3575 char_u *path = NULL;
3598 } 3598 }
3599 # endif 3599 # endif
3600 3600
3601 set_vim_var_string(VV_PROGPATH, val, -1); 3601 set_vim_var_string(VV_PROGPATH, val, -1);
3602 3602
3603 # ifdef WIN32 3603 # ifdef MSWIN
3604 vim_free(path); 3604 vim_free(path);
3605 # endif 3605 # endif
3606 } 3606 }
3607 3607
3608 #endif /* NO_VIM_MAIN */ 3608 #endif /* NO_VIM_MAIN */
3621 static void 3621 static void
3622 exec_on_server(mparm_T *parmp) 3622 exec_on_server(mparm_T *parmp)
3623 { 3623 {
3624 if (parmp->serverName_arg == NULL || *parmp->serverName_arg != NUL) 3624 if (parmp->serverName_arg == NULL || *parmp->serverName_arg != NUL)
3625 { 3625 {
3626 # ifdef WIN32 3626 # ifdef MSWIN
3627 /* Initialise the client/server messaging infrastructure. */ 3627 /* Initialise the client/server messaging infrastructure. */
3628 serverInitMessaging(); 3628 serverInitMessaging();
3629 # endif 3629 # endif
3630 3630
3631 /* 3631 /*
3643 /* If we're still running, get the name to register ourselves. 3643 /* If we're still running, get the name to register ourselves.
3644 * On Win32 can register right now, for X11 need to setup the 3644 * On Win32 can register right now, for X11 need to setup the
3645 * clipboard first, it's further down. */ 3645 * clipboard first, it's further down. */
3646 parmp->servername = serverMakeName(parmp->serverName_arg, 3646 parmp->servername = serverMakeName(parmp->serverName_arg,
3647 parmp->argv[0]); 3647 parmp->argv[0]);
3648 # ifdef WIN32 3648 # ifdef MSWIN
3649 if (parmp->servername != NULL) 3649 if (parmp->servername != NULL)
3650 { 3650 {
3651 serverSetName(parmp->servername); 3651 serverSetName(parmp->servername);
3652 vim_free(parmp->servername); 3652 vim_free(parmp->servername);
3653 } 3653 }
3840 /* Let vim start normally. */ 3840 /* Let vim start normally. */
3841 mch_errmsg(_(": Send failed. Trying to execute locally\n")); 3841 mch_errmsg(_(": Send failed. Trying to execute locally\n"));
3842 break; 3842 break;
3843 } 3843 }
3844 3844
3845 # ifdef FEAT_GUI_W32 3845 # ifdef FEAT_GUI_MSWIN
3846 /* Guess that when the server name starts with "g" it's a GUI 3846 /* Guess that when the server name starts with "g" it's a GUI
3847 * server, which we can bring to the foreground here. 3847 * server, which we can bring to the foreground here.
3848 * Foreground() in the server doesn't work very well. */ 3848 * Foreground() in the server doesn't work very well. */
3849 if (argtype != ARGTYPE_SEND && TOUPPER_ASC(*sname) == 'G') 3849 if (argtype != ARGTYPE_SEND && TOUPPER_ASC(*sname) == 'G')
3850 SetForegroundWindow(srv); 3850 SetForegroundWindow(srv);
3858 { 3858 {
3859 int numFiles = *argc - i - 1; 3859 int numFiles = *argc - i - 1;
3860 int j; 3860 int j;
3861 char_u *done = alloc(numFiles); 3861 char_u *done = alloc(numFiles);
3862 char_u *p; 3862 char_u *p;
3863 # ifdef FEAT_GUI_W32 3863 # ifdef FEAT_GUI_MSWIN
3864 NOTIFYICONDATA ni; 3864 NOTIFYICONDATA ni;
3865 int count = 0; 3865 int count = 0;
3866 extern HWND message_window; 3866 extern HWND message_window;
3867 # endif 3867 # endif
3868 3868
3869 if (numFiles > 0 && argv[i + 1][0] == '+') 3869 if (numFiles > 0 && argv[i + 1][0] == '+')
3870 /* Skip "+cmd" argument, don't wait for it to be edited. */ 3870 /* Skip "+cmd" argument, don't wait for it to be edited. */
3871 --numFiles; 3871 --numFiles;
3872 3872
3873 # ifdef FEAT_GUI_W32 3873 # ifdef FEAT_GUI_MSWIN
3874 ni.cbSize = sizeof(ni); 3874 ni.cbSize = sizeof(ni);
3875 ni.hWnd = message_window; 3875 ni.hWnd = message_window;
3876 ni.uID = 0; 3876 ni.uID = 0;
3877 ni.uFlags = NIF_ICON|NIF_TIP; 3877 ni.uFlags = NIF_ICON|NIF_TIP;
3878 ni.hIcon = LoadIcon((HINSTANCE)GetModuleHandle(0), "IDR_VIM"); 3878 ni.hIcon = LoadIcon((HINSTANCE)GetModuleHandle(0), "IDR_VIM");
3882 3882
3883 /* Wait for all files to unload in remote */ 3883 /* Wait for all files to unload in remote */
3884 vim_memset(done, 0, numFiles); 3884 vim_memset(done, 0, numFiles);
3885 while (memchr(done, 0, numFiles) != NULL) 3885 while (memchr(done, 0, numFiles) != NULL)
3886 { 3886 {
3887 # ifdef WIN32 3887 # ifdef MSWIN
3888 p = serverGetReply(srv, NULL, TRUE, TRUE, 0); 3888 p = serverGetReply(srv, NULL, TRUE, TRUE, 0);
3889 if (p == NULL) 3889 if (p == NULL)
3890 break; 3890 break;
3891 # else 3891 # else
3892 if (serverReadReply(xterm_dpy, srv, &p, TRUE, -1) < 0) 3892 if (serverReadReply(xterm_dpy, srv, &p, TRUE, -1) < 0)
3893 break; 3893 break;
3894 # endif 3894 # endif
3895 j = atoi((char *)p); 3895 j = atoi((char *)p);
3896 if (j >= 0 && j < numFiles) 3896 if (j >= 0 && j < numFiles)
3897 { 3897 {
3898 # ifdef FEAT_GUI_W32 3898 # ifdef FEAT_GUI_MSWIN
3899 ++count; 3899 ++count;
3900 sprintf(ni.szTip, _("%d of %d edited"), 3900 sprintf(ni.szTip, _("%d of %d edited"),
3901 count, numFiles); 3901 count, numFiles);
3902 Shell_NotifyIcon(NIM_MODIFY, &ni); 3902 Shell_NotifyIcon(NIM_MODIFY, &ni);
3903 # endif 3903 # endif
3904 done[j] = 1; 3904 done[j] = 1;
3905 } 3905 }
3906 } 3906 }
3907 # ifdef FEAT_GUI_W32 3907 # ifdef FEAT_GUI_MSWIN
3908 Shell_NotifyIcon(NIM_DELETE, &ni); 3908 Shell_NotifyIcon(NIM_DELETE, &ni);
3909 # endif 3909 # endif
3910 } 3910 }
3911 } 3911 }
3912 else if (STRICMP(argv[i], "--remote-expr") == 0) 3912 else if (STRICMP(argv[i], "--remote-expr") == 0)
3913 { 3913 {
3914 if (i == *argc - 1) 3914 if (i == *argc - 1)
3915 mainerr_arg_missing((char_u *)argv[i]); 3915 mainerr_arg_missing((char_u *)argv[i]);
3916 # ifdef WIN32 3916 # ifdef MSWIN
3917 /* Win32 always works? */ 3917 /* Win32 always works? */
3918 if (serverSendToVim(sname, (char_u *)argv[i + 1], 3918 if (serverSendToVim(sname, (char_u *)argv[i + 1],
3919 &res, NULL, 1, 0, FALSE) < 0) 3919 &res, NULL, 1, 0, FALSE) < 0)
3920 # else 3920 # else
3921 if (xterm_dpy == NULL) 3921 if (xterm_dpy == NULL)
3933 mch_errmsg(_(": Send expression failed.\n")); 3933 mch_errmsg(_(": Send expression failed.\n"));
3934 } 3934 }
3935 } 3935 }
3936 else if (STRICMP(argv[i], "--serverlist") == 0) 3936 else if (STRICMP(argv[i], "--serverlist") == 0)
3937 { 3937 {
3938 # ifdef WIN32 3938 # ifdef MSWIN
3939 /* Win32 always works? */ 3939 /* Win32 always works? */
3940 res = serverGetVimNames(); 3940 res = serverGetVimNames();
3941 # else 3941 # else
3942 if (xterm_dpy != NULL) 3942 if (xterm_dpy != NULL)
3943 res = serverGetVimNames(xterm_dpy); 3943 res = serverGetVimNames(xterm_dpy);