Mercurial > vim
comparison src/os_win32.c @ 31752:3365a601e73b v9.0.1208
patch 9.0.1208: code is indented more than necessary
Commit: https://github.com/vim/vim/commit/a41e221935edab62672a15123af48f4f14ac1c7d
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Mon Jan 16 18:19:05 2023 +0000
patch 9.0.1208: code is indented more than necessary
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11819)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 16 Jan 2023 19:30:04 +0100 |
parents | edbadc330871 |
children | ea09e0f546f0 |
comparison
equal
deleted
inserted
replaced
31751:997105f91449 | 31752:3365a601e73b |
---|---|
276 PfnRtlGetVersion pRtlGetVersion; | 276 PfnRtlGetVersion pRtlGetVersion; |
277 DWORD ver = MAKE_VER(0, 0, 0); | 277 DWORD ver = MAKE_VER(0, 0, 0); |
278 | 278 |
279 osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); | 279 osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); |
280 hNtdll = GetModuleHandle("ntdll.dll"); | 280 hNtdll = GetModuleHandle("ntdll.dll"); |
281 if (hNtdll != NULL) | 281 if (hNtdll == NULL) |
282 { | 282 return ver; |
283 pRtlGetVersion = | 283 |
284 (PfnRtlGetVersion)GetProcAddress(hNtdll, "RtlGetVersion"); | 284 pRtlGetVersion = |
285 pRtlGetVersion(&osver); | 285 (PfnRtlGetVersion)GetProcAddress(hNtdll, "RtlGetVersion"); |
286 ver = MAKE_VER(min(osver.dwMajorVersion, 255), | 286 pRtlGetVersion(&osver); |
287 min(osver.dwMinorVersion, 255), | 287 ver = MAKE_VER(min(osver.dwMajorVersion, 255), |
288 min(osver.dwBuildNumber, 32767)); | 288 min(osver.dwMinorVersion, 255), |
289 } | 289 min(osver.dwBuildNumber, 32767)); |
290 return ver; | 290 return ver; |
291 } | 291 } |
292 | 292 |
293 #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) | 293 #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) |
294 static BOOL | 294 static BOOL |
476 GetModuleFileName(NULL, temp, MAX_ENV_PATH_LEN - 1); | 476 GetModuleFileName(NULL, temp, MAX_ENV_PATH_LEN - 1); |
477 if (*temp != NUL) | 477 if (*temp != NUL) |
478 exe_name = FullName_save((char_u *)temp, FALSE); | 478 exe_name = FullName_save((char_u *)temp, FALSE); |
479 } | 479 } |
480 | 480 |
481 if (exe_path == NULL && exe_name != NULL) | 481 if (exe_path != NULL || exe_name == NULL) |
482 { | 482 return; |
483 exe_path = vim_strnsave(exe_name, gettail_sep(exe_name) - exe_name); | 483 |
484 if (exe_path != NULL) | 484 exe_path = vim_strnsave(exe_name, gettail_sep(exe_name) - exe_name); |
485 { | 485 if (exe_path == NULL) |
486 // Append our starting directory to $PATH, so that when doing | 486 return; |
487 // "!xxd" it's found in our starting directory. Needed because | 487 |
488 // SearchPath() also looks there. | 488 // Append our starting directory to $PATH, so that when doing |
489 p = mch_getenv("PATH"); | 489 // "!xxd" it's found in our starting directory. Needed because |
490 if (p == NULL | 490 // SearchPath() also looks there. |
491 || STRLEN(p) + STRLEN(exe_path) + 2 < MAX_ENV_PATH_LEN) | 491 p = mch_getenv("PATH"); |
492 { | 492 if (p == NULL |
493 if (p == NULL || *p == NUL) | 493 || STRLEN(p) + STRLEN(exe_path) + 2 < MAX_ENV_PATH_LEN) |
494 temp[0] = NUL; | 494 { |
495 else | 495 if (p == NULL || *p == NUL) |
496 { | 496 temp[0] = NUL; |
497 STRCPY(temp, p); | 497 else |
498 STRCAT(temp, ";"); | 498 { |
499 } | 499 STRCPY(temp, p); |
500 STRCAT(temp, exe_path); | 500 STRCAT(temp, ";"); |
501 vim_setenv((char_u *)"PATH", (char_u *)temp); | 501 } |
502 } | 502 STRCAT(temp, exe_path); |
503 } | 503 vim_setenv((char_u *)"PATH", (char_u *)temp); |
504 } | 504 } |
505 } | 505 } |
506 | 506 |
507 /* | 507 /* |
508 * Unescape characters in "p" that appear in "escaped". | 508 * Unescape characters in "p" that appear in "escaped". |
531 { | 531 { |
532 HINSTANCE dll = NULL; | 532 HINSTANCE dll = NULL; |
533 | 533 |
534 // No need to load any library when registering OLE. | 534 // No need to load any library when registering OLE. |
535 if (found_register_arg) | 535 if (found_register_arg) |
536 return dll; | 536 return NULL; |
537 | 537 |
538 // NOTE: Do not use mch_dirname() and mch_chdir() here, they may call | 538 // NOTE: Do not use mch_dirname() and mch_chdir() here, they may call |
539 // vimLoadLib() recursively, which causes a stack overflow. | 539 // vimLoadLib() recursively, which causes a stack overflow. |
540 if (exe_path == NULL) | 540 if (exe_path == NULL) |
541 get_exe_name(); | 541 get_exe_name(); |
542 if (exe_path != NULL) | 542 |
543 { | 543 if (exe_path == NULL) |
544 WCHAR old_dirw[MAXPATHL]; | 544 return NULL; |
545 | 545 |
546 if (GetCurrentDirectoryW(MAXPATHL, old_dirw) != 0) | 546 WCHAR old_dirw[MAXPATHL]; |
547 { | 547 |
548 // Change directory to where the executable is, both to make | 548 if (GetCurrentDirectoryW(MAXPATHL, old_dirw) == 0) |
549 // sure we find a .dll there and to avoid looking for a .dll | 549 return NULL; |
550 // in the current directory. | 550 |
551 SetCurrentDirectory((LPCSTR)exe_path); | 551 // Change directory to where the executable is, both to make |
552 dll = LoadLibrary(name); | 552 // sure we find a .dll there and to avoid looking for a .dll |
553 SetCurrentDirectoryW(old_dirw); | 553 // in the current directory. |
554 return dll; | 554 SetCurrentDirectory((LPCSTR)exe_path); |
555 } | 555 dll = LoadLibrary(name); |
556 } | 556 SetCurrentDirectoryW(old_dirw); |
557 return dll; | 557 return dll; |
558 } | 558 } |
559 | 559 |
560 #if defined(VIMDLL) || defined(PROTO) | 560 #if defined(VIMDLL) || defined(PROTO) |
561 /* | 561 /* |
905 void | 905 void |
906 PlatformId(void) | 906 PlatformId(void) |
907 { | 907 { |
908 static int done = FALSE; | 908 static int done = FALSE; |
909 | 909 |
910 if (!done) | 910 if (done) |
911 { | 911 return; |
912 OSVERSIONINFO ovi; | 912 |
913 | 913 OSVERSIONINFO ovi; |
914 ovi.dwOSVersionInfoSize = sizeof(ovi); | 914 |
915 GetVersionEx(&ovi); | 915 ovi.dwOSVersionInfoSize = sizeof(ovi); |
916 GetVersionEx(&ovi); | |
916 | 917 |
917 #ifdef FEAT_EVAL | 918 #ifdef FEAT_EVAL |
918 vim_snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d", | 919 vim_snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d", |
919 (int)ovi.dwMajorVersion, (int)ovi.dwMinorVersion); | 920 (int)ovi.dwMajorVersion, (int)ovi.dwMinorVersion); |
920 #endif | 921 #endif |
921 if ((ovi.dwMajorVersion == 6 && ovi.dwMinorVersion >= 2) | 922 if ((ovi.dwMajorVersion == 6 && ovi.dwMinorVersion >= 2) |
922 || ovi.dwMajorVersion > 6) | 923 || ovi.dwMajorVersion > 6) |
923 win8_or_later = TRUE; | 924 win8_or_later = TRUE; |
924 | 925 |
925 if ((ovi.dwMajorVersion == 10 && ovi.dwBuildNumber >= 19045) | 926 if ((ovi.dwMajorVersion == 10 && ovi.dwBuildNumber >= 19045) |
926 || ovi.dwMajorVersion > 10) | 927 || ovi.dwMajorVersion > 10) |
927 win10_22H2_or_later = TRUE; | 928 win10_22H2_or_later = TRUE; |
928 | 929 |
929 #ifdef HAVE_ACL | 930 #ifdef HAVE_ACL |
930 // Enable privilege for getting or setting SACLs. | 931 // Enable privilege for getting or setting SACLs. |
931 win32_enable_privilege(SE_SECURITY_NAME, TRUE); | 932 win32_enable_privilege(SE_SECURITY_NAME, TRUE); |
932 #endif | 933 #endif |
933 done = TRUE; | 934 done = TRUE; |
934 } | |
935 } | 935 } |
936 #ifdef _MSC_VER | 936 #ifdef _MSC_VER |
937 # pragma warning(pop) | 937 # pragma warning(pop) |
938 #endif | 938 #endif |
939 | 939 |
3049 { | 3049 { |
3050 CONSOLE_SCREEN_BUFFER_INFO csbi; | 3050 CONSOLE_SCREEN_BUFFER_INFO csbi; |
3051 COORD dwWindowSize; | 3051 COORD dwWindowSize; |
3052 BOOL NeedAdjust = FALSE; | 3052 BOOL NeedAdjust = FALSE; |
3053 | 3053 |
3054 if (GetConsoleScreenBufferInfo(g_hConOut, &csbi)) | 3054 if (!GetConsoleScreenBufferInfo(g_hConOut, &csbi)) |
3055 { | 3055 return FALSE; |
3056 /* | 3056 |
3057 * A buffer resize will fail if the current console window does | 3057 /* |
3058 * not lie completely within that buffer. To avoid this, we might | 3058 * A buffer resize will fail if the current console window does |
3059 * have to move and possibly shrink the window. | 3059 * not lie completely within that buffer. To avoid this, we might |
3060 */ | 3060 * have to move and possibly shrink the window. |
3061 if (csbi.srWindow.Right >= dwBufferSize.X) | 3061 */ |
3062 { | 3062 if (csbi.srWindow.Right >= dwBufferSize.X) |
3063 dwWindowSize.X = SRWIDTH(csbi.srWindow); | 3063 { |
3064 if (dwWindowSize.X > dwBufferSize.X) | 3064 dwWindowSize.X = SRWIDTH(csbi.srWindow); |
3065 dwWindowSize.X = dwBufferSize.X; | 3065 if (dwWindowSize.X > dwBufferSize.X) |
3066 csbi.srWindow.Right = dwBufferSize.X - 1; | 3066 dwWindowSize.X = dwBufferSize.X; |
3067 csbi.srWindow.Left = dwBufferSize.X - dwWindowSize.X; | 3067 csbi.srWindow.Right = dwBufferSize.X - 1; |
3068 NeedAdjust = TRUE; | 3068 csbi.srWindow.Left = dwBufferSize.X - dwWindowSize.X; |
3069 } | 3069 NeedAdjust = TRUE; |
3070 if (csbi.srWindow.Bottom >= dwBufferSize.Y) | 3070 } |
3071 { | 3071 if (csbi.srWindow.Bottom >= dwBufferSize.Y) |
3072 dwWindowSize.Y = SRHEIGHT(csbi.srWindow); | 3072 { |
3073 if (dwWindowSize.Y > dwBufferSize.Y) | 3073 dwWindowSize.Y = SRHEIGHT(csbi.srWindow); |
3074 dwWindowSize.Y = dwBufferSize.Y; | 3074 if (dwWindowSize.Y > dwBufferSize.Y) |
3075 csbi.srWindow.Bottom = dwBufferSize.Y - 1; | 3075 dwWindowSize.Y = dwBufferSize.Y; |
3076 csbi.srWindow.Top = dwBufferSize.Y - dwWindowSize.Y; | 3076 csbi.srWindow.Bottom = dwBufferSize.Y - 1; |
3077 NeedAdjust = TRUE; | 3077 csbi.srWindow.Top = dwBufferSize.Y - dwWindowSize.Y; |
3078 } | 3078 NeedAdjust = TRUE; |
3079 if (NeedAdjust && WantAdjust) | 3079 } |
3080 { | 3080 if (NeedAdjust && WantAdjust) |
3081 if (!SetConsoleWindowInfo(g_hConOut, TRUE, &csbi.srWindow)) | 3081 { |
3082 return FALSE; | 3082 if (!SetConsoleWindowInfo(g_hConOut, TRUE, &csbi.srWindow)) |
3083 } | 3083 return FALSE; |
3084 return TRUE; | 3084 } |
3085 } | 3085 return TRUE; |
3086 | |
3087 return FALSE; | |
3088 } | 3086 } |
3089 | 3087 |
3090 typedef struct ConsoleBufferStruct | 3088 typedef struct ConsoleBufferStruct |
3091 { | 3089 { |
3092 BOOL IsValid; | 3090 BOOL IsValid; |
3672 int len) | 3670 int len) |
3673 { | 3671 { |
3674 WCHAR wszHostName[256 + 1]; | 3672 WCHAR wszHostName[256 + 1]; |
3675 DWORD wcch = ARRAY_LENGTH(wszHostName); | 3673 DWORD wcch = ARRAY_LENGTH(wszHostName); |
3676 | 3674 |
3677 if (GetComputerNameW(wszHostName, &wcch)) | 3675 if (!GetComputerNameW(wszHostName, &wcch)) |
3678 { | 3676 return; |
3679 char_u *p = utf16_to_enc(wszHostName, NULL); | 3677 |
3680 | 3678 char_u *p = utf16_to_enc(wszHostName, NULL); |
3681 if (p != NULL) | 3679 if (p == NULL) |
3682 { | 3680 return; |
3683 vim_strncpy(s, p, len - 1); | 3681 |
3684 vim_free(p); | 3682 vim_strncpy(s, p, len - 1); |
3685 return; | 3683 vim_free(p); |
3686 } | |
3687 } | |
3688 } | 3684 } |
3689 | 3685 |
3690 | 3686 |
3691 /* | 3687 /* |
3692 * return process ID | 3688 * return process ID |
3730 * Originally this was: | 3726 * Originally this was: |
3731 * return (getcwd(buf, len) != NULL ? OK : FAIL); | 3727 * return (getcwd(buf, len) != NULL ? OK : FAIL); |
3732 * But the Win32s known bug list says that getcwd() doesn't work | 3728 * But the Win32s known bug list says that getcwd() doesn't work |
3733 * so use the Win32 system call instead. <Negri> | 3729 * so use the Win32 system call instead. <Negri> |
3734 */ | 3730 */ |
3735 if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0) | 3731 if (GetCurrentDirectoryW(_MAX_PATH, wbuf) == 0) |
3736 { | 3732 return FAIL; |
3737 WCHAR wcbuf[_MAX_PATH + 1]; | 3733 |
3738 char_u *p = NULL; | 3734 WCHAR wcbuf[_MAX_PATH + 1]; |
3739 | 3735 char_u *p = NULL; |
3740 if (GetLongPathNameW(wbuf, wcbuf, _MAX_PATH) != 0) | 3736 |
3741 { | 3737 if (GetLongPathNameW(wbuf, wcbuf, _MAX_PATH) != 0) |
3742 p = utf16_to_enc(wcbuf, NULL); | 3738 { |
3743 if (STRLEN(p) >= (size_t)len) | 3739 p = utf16_to_enc(wcbuf, NULL); |
3744 { | 3740 if (STRLEN(p) >= (size_t)len) |
3745 // long path name is too long, fall back to short one | 3741 { |
3746 vim_free(p); | 3742 // long path name is too long, fall back to short one |
3747 p = NULL; | |
3748 } | |
3749 } | |
3750 if (p == NULL) | |
3751 p = utf16_to_enc(wbuf, NULL); | |
3752 | |
3753 if (p != NULL) | |
3754 { | |
3755 vim_strncpy(buf, p, len - 1); | |
3756 vim_free(p); | 3743 vim_free(p); |
3757 return OK; | 3744 p = NULL; |
3758 } | 3745 } |
3759 } | 3746 } |
3760 return FAIL; | 3747 if (p == NULL) |
3748 p = utf16_to_enc(wbuf, NULL); | |
3749 | |
3750 if (p == NULL) | |
3751 return FAIL; | |
3752 | |
3753 vim_strncpy(buf, p, len - 1); | |
3754 vim_free(p); | |
3755 return OK; | |
3761 } | 3756 } |
3762 | 3757 |
3763 /* | 3758 /* |
3764 * Get file permissions for "name". | 3759 * Get file permissions for "name". |
3765 * Return mode_t or -1 for error. | 3760 * Return mode_t or -1 for error. |
3972 OPEN_EXISTING, // creation disposition | 3967 OPEN_EXISTING, // creation disposition |
3973 FILE_FLAG_BACKUP_SEMANTICS, // file attributes | 3968 FILE_FLAG_BACKUP_SEMANTICS, // file attributes |
3974 NULL); // handle to template file | 3969 NULL); // handle to template file |
3975 vim_free(wn); | 3970 vim_free(wn); |
3976 | 3971 |
3977 if (hFile != INVALID_HANDLE_VALUE) | 3972 if (hFile == INVALID_HANDLE_VALUE) |
3978 { | 3973 return FILEINFO_READ_FAIL; |
3979 if (GetFileInformationByHandle(hFile, info) != 0) | 3974 |
3980 res = FILEINFO_OK; | 3975 if (GetFileInformationByHandle(hFile, info) != 0) |
3981 else | 3976 res = FILEINFO_OK; |
3982 res = FILEINFO_INFO_FAIL; | 3977 else |
3983 CloseHandle(hFile); | 3978 res = FILEINFO_INFO_FAIL; |
3984 } | 3979 CloseHandle(hFile); |
3985 | 3980 |
3986 return res; | 3981 return res; |
3987 } | 3982 } |
3988 | 3983 |
3989 /* | 3984 /* |
6168 * Clear the data related to "job". | 6163 * Clear the data related to "job". |
6169 */ | 6164 */ |
6170 void | 6165 void |
6171 mch_clear_job(job_T *job) | 6166 mch_clear_job(job_T *job) |
6172 { | 6167 { |
6173 if (job->jv_status != JOB_FAILED) | 6168 if (job->jv_status == JOB_FAILED) |
6174 { | 6169 return; |
6175 if (job->jv_job_object != NULL) | 6170 |
6176 CloseHandle(job->jv_job_object); | 6171 if (job->jv_job_object != NULL) |
6177 CloseHandle(job->jv_proc_info.hProcess); | 6172 CloseHandle(job->jv_job_object); |
6178 } | 6173 CloseHandle(job->jv_proc_info.hProcess); |
6179 } | 6174 } |
6180 #endif | 6175 #endif |
6181 | 6176 |
6182 | 6177 |
6183 #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) | 6178 #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) |
7986 static BOOL | 7981 static BOOL |
7987 load_ntdll(void) | 7982 load_ntdll(void) |
7988 { | 7983 { |
7989 static int loaded = -1; | 7984 static int loaded = -1; |
7990 | 7985 |
7991 if (loaded == -1) | 7986 if (loaded != -1) |
7992 { | 7987 return (BOOL) loaded; |
7993 HMODULE hNtdll = GetModuleHandle("ntdll.dll"); | 7988 |
7994 if (hNtdll != NULL) | 7989 HMODULE hNtdll = GetModuleHandle("ntdll.dll"); |
7995 { | 7990 if (hNtdll != NULL) |
7996 pNtOpenFile = (PfnNtOpenFile) GetProcAddress(hNtdll, "NtOpenFile"); | 7991 { |
7997 pNtClose = (PfnNtClose) GetProcAddress(hNtdll, "NtClose"); | 7992 pNtOpenFile = (PfnNtOpenFile) GetProcAddress(hNtdll, "NtOpenFile"); |
7998 pNtSetEaFile = (PfnNtSetEaFile) | 7993 pNtClose = (PfnNtClose) GetProcAddress(hNtdll, "NtClose"); |
7999 GetProcAddress(hNtdll, "NtSetEaFile"); | 7994 pNtSetEaFile = (PfnNtSetEaFile) |
8000 pNtQueryEaFile = (PfnNtQueryEaFile) | 7995 GetProcAddress(hNtdll, "NtSetEaFile"); |
8001 GetProcAddress(hNtdll, "NtQueryEaFile"); | 7996 pNtQueryEaFile = (PfnNtQueryEaFile) |
8002 pNtQueryInformationFile = (PfnNtQueryInformationFile) | 7997 GetProcAddress(hNtdll, "NtQueryEaFile"); |
8003 GetProcAddress(hNtdll, "NtQueryInformationFile"); | 7998 pNtQueryInformationFile = (PfnNtQueryInformationFile) |
8004 pRtlInitUnicodeString = (PfnRtlInitUnicodeString) | 7999 GetProcAddress(hNtdll, "NtQueryInformationFile"); |
8005 GetProcAddress(hNtdll, "RtlInitUnicodeString"); | 8000 pRtlInitUnicodeString = (PfnRtlInitUnicodeString) |
8006 } | 8001 GetProcAddress(hNtdll, "RtlInitUnicodeString"); |
8007 if (pNtOpenFile == NULL | 8002 } |
8008 || pNtClose == NULL | 8003 if (pNtOpenFile == NULL |
8009 || pNtSetEaFile == NULL | 8004 || pNtClose == NULL |
8010 || pNtQueryEaFile == NULL | 8005 || pNtSetEaFile == NULL |
8011 || pNtQueryInformationFile == NULL | 8006 || pNtQueryEaFile == NULL |
8012 || pRtlInitUnicodeString == NULL) | 8007 || pNtQueryInformationFile == NULL |
8013 loaded = FALSE; | 8008 || pRtlInitUnicodeString == NULL) |
8014 else | 8009 loaded = FALSE; |
8015 loaded = TRUE; | 8010 else |
8016 } | 8011 loaded = TRUE; |
8017 return (BOOL) loaded; | 8012 return (BOOL) loaded; |
8018 } | 8013 } |
8019 | 8014 |
8020 /* | 8015 /* |
8021 * Copy extended attributes (EA) from file "from" to file "to". | 8016 * Copy extended attributes (EA) from file "from" to file "to". |
8188 } | 8183 } |
8189 | 8184 |
8190 void | 8185 void |
8191 free_cmd_argsW(void) | 8186 free_cmd_argsW(void) |
8192 { | 8187 { |
8193 if (ArglistW != NULL) | 8188 if (ArglistW == NULL) |
8194 { | 8189 return; |
8195 GlobalFree(ArglistW); | 8190 |
8196 ArglistW = NULL; | 8191 GlobalFree(ArglistW); |
8197 } | 8192 ArglistW = NULL; |
8198 } | 8193 } |
8199 | 8194 |
8200 /* | 8195 /* |
8201 * Remember "name" is an argument that was added to the argument list. | 8196 * Remember "name" is an argument that was added to the argument list. |
8202 * This avoids that we have to re-parse the argument list when fix_arg_enc() | 8197 * This avoids that we have to re-parse the argument list when fix_arg_enc() |
8897 { | 8892 { |
8898 CONSOLE_SCREEN_BUFFER_INFO csbi; | 8893 CONSOLE_SCREEN_BUFFER_INFO csbi; |
8899 COORD coord; | 8894 COORD coord; |
8900 SMALL_RECT newsize; | 8895 SMALL_RECT newsize; |
8901 | 8896 |
8902 if (GetConsoleScreenBufferInfo(g_hConOut, &csbi)) | 8897 if (!GetConsoleScreenBufferInfo(g_hConOut, &csbi)) |
8903 { | 8898 return; |
8904 coord.X = SRWIDTH(csbi.srWindow); | 8899 |
8905 coord.Y = SRHEIGHT(csbi.srWindow); | 8900 coord.X = SRWIDTH(csbi.srWindow); |
8906 SetConsoleScreenBufferSize(g_hConOut, coord); | 8901 coord.Y = SRHEIGHT(csbi.srWindow); |
8907 | 8902 SetConsoleScreenBufferSize(g_hConOut, coord); |
8908 newsize.Left = 0; | 8903 |
8909 newsize.Top = 0; | 8904 newsize.Left = 0; |
8910 newsize.Right = coord.X - 1; | 8905 newsize.Top = 0; |
8911 newsize.Bottom = coord.Y - 1; | 8906 newsize.Right = coord.X - 1; |
8912 SetConsoleWindowInfo(g_hConOut, TRUE, &newsize); | 8907 newsize.Bottom = coord.Y - 1; |
8913 | 8908 SetConsoleWindowInfo(g_hConOut, TRUE, &newsize); |
8914 SetConsoleScreenBufferSize(g_hConOut, coord); | 8909 |
8915 } | 8910 SetConsoleScreenBufferSize(g_hConOut, coord); |
8916 } | 8911 } |
8917 #endif | 8912 #endif |
8918 | 8913 |
8919 char * | 8914 char * |
8920 GetWin32Error(void) | 8915 GetWin32Error(void) |
8924 | 8919 |
8925 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, | 8920 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, |
8926 NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL); | 8921 NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL); |
8927 if (oldmsg != NULL) | 8922 if (oldmsg != NULL) |
8928 LocalFree(oldmsg); | 8923 LocalFree(oldmsg); |
8929 if (msg != NULL) | 8924 if (msg == NULL) |
8930 { | 8925 return NULL; |
8931 // remove trailing \r\n | 8926 |
8932 char *pcrlf = strstr(msg, "\r\n"); | 8927 // remove trailing \r\n |
8933 if (pcrlf != NULL) | 8928 char *pcrlf = strstr(msg, "\r\n"); |
8934 *pcrlf = '\0'; | 8929 if (pcrlf != NULL) |
8935 oldmsg = msg; | 8930 *pcrlf = '\0'; |
8936 } | 8931 oldmsg = msg; |
8937 return msg; | 8932 return msg; |
8938 } | 8933 } |
8939 | 8934 |
8940 #if defined(FEAT_RELTIME) || defined(PROTO) | 8935 #if defined(FEAT_RELTIME) || defined(PROTO) |
8941 static HANDLE timer_handle; | 8936 static HANDLE timer_handle; |