don't rely on GetLastError() to detect errors in enable_ansi_support
galich opened this issue · comments
Sergey Galich commented
Lines 20 to 36 in 36b0ff3
GetStdHandle()
can return valid handle and GetLastError() will return ERROR_NOT_SUPPORTED (50). Error must be checked only when GetStdHandle() returns INVALID_HANDLE_VALUE (-1). It happens when GUI app creates console via AllocConsole() and tries to call enable_ansi_support().
GetConsoleMode()
and SetConsoleMode()
return 0 (FALSE) when they fail, GetLastError() should be called after that.
Roy Ivy III commented
Benjamin Sago commented
Thanks for going through the Windows side of this; sorry again it took so long for me to merge.