comparison src/os_win32.c @ 1569:9fbb40a1228a v7.1.282

updated for version 7.1-282
author vimboss
date Sun, 16 Mar 2008 13:54:13 +0000
parents 69bcc0c891d7
children 73fe8baea242
comparison
equal deleted inserted replaced
1568:4e581f1b08da 1569:9fbb40a1228a
2854 case CTRL_LOGOFF_EVENT: 2854 case CTRL_LOGOFF_EVENT:
2855 case CTRL_SHUTDOWN_EVENT: 2855 case CTRL_SHUTDOWN_EVENT:
2856 windgoto((int)Rows - 1, 0); 2856 windgoto((int)Rows - 1, 0);
2857 g_fForceExit = TRUE; 2857 g_fForceExit = TRUE;
2858 2858
2859 sprintf((char *)IObuff, _("Vim: Caught %s event\n"), 2859 vim_snprintf((char *)IObuff, IOSIZE, _("Vim: Caught %s event\n"),
2860 (dwCtrlType == CTRL_CLOSE_EVENT 2860 (dwCtrlType == CTRL_CLOSE_EVENT
2861 ? _("close") 2861 ? _("close")
2862 : dwCtrlType == CTRL_LOGOFF_EVENT 2862 : dwCtrlType == CTRL_LOGOFF_EVENT
2863 ? _("logoff") 2863 ? _("logoff")
2864 : _("shutdown"))); 2864 : _("shutdown")));
3280 } 3280 }
3281 else 3281 else
3282 { 3282 {
3283 /* we use "command" or "cmd" to start the shell; slow but easy */ 3283 /* we use "command" or "cmd" to start the shell; slow but easy */
3284 char_u *newcmd; 3284 char_u *newcmd;
3285 3285 long_u cmdlen = (
3286 newcmd = lalloc((long_u) (
3287 #ifdef FEAT_GUI_W32 3286 #ifdef FEAT_GUI_W32
3288 STRLEN(vimrun_path) + 3287 STRLEN(vimrun_path) +
3289 #endif 3288 #endif
3290 STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10), TRUE); 3289 STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10);
3290
3291 newcmd = lalloc(cmdlen, TRUE);
3291 if (newcmd != NULL) 3292 if (newcmd != NULL)
3292 { 3293 {
3293 char_u *cmdbase = (*cmd == '"' ? cmd + 1 : cmd); 3294 char_u *cmdbase = (*cmd == '"' ? cmd + 1 : cmd);
3294 3295
3295 if ((STRNICMP(cmdbase, "start", 5) == 0) && vim_iswhite(cmdbase[5])) 3296 if ((STRNICMP(cmdbase, "start", 5) == 0) && vim_iswhite(cmdbase[5]))
3371 need_vimrun_warning = FALSE; 3372 need_vimrun_warning = FALSE;
3372 } 3373 }
3373 if (!s_dont_use_vimrun) 3374 if (!s_dont_use_vimrun)
3374 /* Use vimrun to execute the command. It opens a console 3375 /* Use vimrun to execute the command. It opens a console
3375 * window, which can be closed without killing Vim. */ 3376 * window, which can be closed without killing Vim. */
3376 sprintf((char *)newcmd, "%s%s%s %s %s", 3377 vim_snprintf((char *)newcmd, cmdlen, "%s%s%s %s %s",
3377 vimrun_path, 3378 vimrun_path,
3378 (msg_silent != 0 || (options & SHELL_DOOUT)) 3379 (msg_silent != 0 || (options & SHELL_DOOUT))
3379 ? "-s " : "", 3380 ? "-s " : "",
3380 p_sh, p_shcf, cmd); 3381 p_sh, p_shcf, cmd);
3381 else 3382 else
3382 #endif 3383 #endif
3383 sprintf((char *)newcmd, "%s %s %s", p_sh, p_shcf, cmd); 3384 vim_snprintf((char *)newcmd, cmdlen, "%s %s %s",
3385 p_sh, p_shcf, cmd);
3384 x = mch_system((char *)newcmd, options); 3386 x = mch_system((char *)newcmd, options);
3385 } 3387 }
3386 vim_free(newcmd); 3388 vim_free(newcmd);
3387 } 3389 }
3388 } 3390 }
4662 /* Wide functions of Borland C 5.5 do not work on Windows 98. */ 4664 /* Wide functions of Borland C 5.5 do not work on Windows 98. */
4663 && g_PlatformId == VER_PLATFORM_WIN32_NT 4665 && g_PlatformId == VER_PLATFORM_WIN32_NT
4664 # endif 4666 # endif
4665 ) 4667 )
4666 { 4668 {
4669 # if defined(DEBUG) && _MSC_VER > 1200
4670 /* Work around an annoying assertion in the Microsoft debug CRT
4671 * when mode's text/binary setting doesn't match _get_fmode(). */
4672 char newMode = mode[strlen(mode) - 1];
4673 int oldMode = 0;
4674
4675 _get_fmode(&oldMode);
4676 if (newMode == 't')
4677 _set_fmode(_O_TEXT);
4678 else if (newMode == 'b')
4679 _set_fmode(_O_BINARY);
4680 # endif
4667 wn = enc_to_ucs2(name, NULL); 4681 wn = enc_to_ucs2(name, NULL);
4668 wm = enc_to_ucs2(mode, NULL); 4682 wm = enc_to_ucs2(mode, NULL);
4669 if (wn != NULL && wm != NULL) 4683 if (wn != NULL && wm != NULL)
4670 f = _wfopen(wn, wm); 4684 f = _wfopen(wn, wm);
4671 vim_free(wn); 4685 vim_free(wn);
4672 vim_free(wm); 4686 vim_free(wm);
4687
4688 # if defined(DEBUG) && _MSC_VER > 1200
4689 _set_fmode(oldMode);
4690 # endif
4691
4673 if (f != NULL) 4692 if (f != NULL)
4674 return f; 4693 return f;
4675 /* Retry with non-wide function (for Windows 98). Can't use 4694 /* Retry with non-wide function (for Windows 98). Can't use
4676 * GetLastError() here and it's unclear what errno gets set to if 4695 * GetLastError() here and it's unclear what errno gets set to if
4677 * the _wfopen() fails for missing wide functions. */ 4696 * the _wfopen() fails for missing wide functions. */