Changeset 3188 for trunk/src/lib/maybe_con_fwrite.c
- Timestamp:
- Mar 24, 2018, 4:32:26 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/maybe_con_fwrite.c
r2906 r3188 5 5 6 6 /* 7 * Copyright (c) 2016 knut st. osmundsen <bird-kBuild-spamx@anduin.net>7 * Copyright (c) 2016-2018 knut st. osmundsen <bird-kBuild-spamx@anduin.net> 8 8 * 9 9 * Permission is hereby granted, free of charge, to any person obtaining a … … 33 33 * Header Files * 34 34 *********************************************************************************************************************************/ 35 #include "console.h" 35 36 #ifdef KBUILD_OS_WINDOWS 36 37 # include <windows.h> 37 38 #endif 38 39 #include <errno.h> 39 #include <stdio.h>40 40 #ifdef _MSC_VER 41 # include <io.h>42 41 # include <conio.h> 43 42 #endif 44 45 43 46 44 … … 69 67 if (fd >= 0) 70 68 { 71 if (isatty(fd)) 69 HANDLE hCon = (HANDLE)_get_osfhandle(fd); 70 if ( hCon != INVALID_HANDLE_VALUE 71 && hCon != NULL) 72 72 { 73 HANDLE hCon = (HANDLE)_get_osfhandle(fd); 74 if ( hCon != INVALID_HANDLE_VALUE 75 && hCon != NULL) 73 if (is_console_handle((intptr_t)hCon)) 76 74 { 77 75 size_t cbToWrite = cbUnit * cUnits; … … 85 83 s_uConsoleCp = GetConsoleCP(); 86 84 87 cwcToWrite = MultiByteToWideChar(s_uConsoleCp, 0 /*dwFlags*/, pvBuf, (int)cbToWrite, pawcTmp, (int)(cwcTmp - 1)); 85 cwcToWrite = MultiByteToWideChar(s_uConsoleCp, 0 /*dwFlags*/, pvBuf, (int)cbToWrite, 86 pawcTmp, (int)(cwcTmp - 1)); 88 87 if (cwcToWrite > 0) 89 88 { … … 92 91 93 92 /* Let the CRT do the rest. At least the Visual C++ 2010 CRT 94 sources indicates _cputws will do the right thing we want. */93 sources indicates _cputws will do the right thing. */ 95 94 fflush(pFile); 96 95 rc = _cputws(pawcTmp); … … 113 112 return fwrite(pvBuf, cbUnit, cUnits, pFile); 114 113 } 114
Note:
See TracChangeset
for help on using the changeset viewer.