diff options
| author | Thijs <thijs@thijsschreijer.nl> | 2024-05-22 23:57:00 +0200 |
|---|---|---|
| committer | Thijs <thijs@thijsschreijer.nl> | 2024-05-22 23:57:00 +0200 |
| commit | e1a8aede05d3217882cf2de426f0a87a659e4308 (patch) | |
| tree | a2793677c06c450a7fcd48c81c9031eea28fb5fd /src | |
| parent | c08ea611759407b0e0c8dbea384c4f5273d27d3f (diff) | |
| download | luasystem-e1a8aede05d3217882cf2de426f0a87a659e4308.tar.gz luasystem-e1a8aede05d3217882cf2de426f0a87a659e4308.tar.bz2 luasystem-e1a8aede05d3217882cf2de426f0a87a659e4308.zip | |
fix windows (manual) tests
Diffstat (limited to 'src')
| -rw-r--r-- | src/term.c | 23 |
1 files changed, 10 insertions, 13 deletions
| @@ -361,26 +361,17 @@ static int lst_setconsoleflags(lua_State *L) | |||
| 361 | } | 361 | } |
| 362 | LSBF_BITFLAG new_console_mode = lsbf_checkbitflags(L, 2); | 362 | LSBF_BITFLAG new_console_mode = lsbf_checkbitflags(L, 2); |
| 363 | 363 | ||
| 364 | DWORD prev_console_mode; | 364 | if (!SetConsoleMode(console_handle, new_console_mode)) { |
| 365 | if (GetConsoleMode(console_handle, &prev_console_mode) == 0) | ||
| 366 | { | ||
| 367 | termFormatError(L, GetLastError(), "failed to get console mode"); | ||
| 368 | return 2; | ||
| 369 | } | ||
| 370 | |||
| 371 | int success = SetConsoleMode(console_handle, new_console_mode) != 0; | ||
| 372 | if (!success) | ||
| 373 | { | ||
| 374 | termFormatError(L, GetLastError(), "failed to set console mode"); | 365 | termFormatError(L, GetLastError(), "failed to set console mode"); |
| 375 | return 2; | 366 | return 2; |
| 376 | } | 367 | } |
| 377 | 368 | ||
| 378 | #else | 369 | #else |
| 379 | get_console_handle(L); // to validate args | 370 | get_console_handle(L); // to validate args |
| 380 | lua_pushboolean(L, 1); // always return true on Posix | ||
| 381 | return 1; | ||
| 382 | |||
| 383 | #endif | 371 | #endif |
| 372 | |||
| 373 | lua_pushboolean(L, 1); | ||
| 374 | return 1; | ||
| 384 | } | 375 | } |
| 385 | 376 | ||
| 386 | 377 | ||
| @@ -657,6 +648,9 @@ static int lst_setnonblock(lua_State *L) | |||
| 657 | } | 648 | } |
| 658 | 649 | ||
| 659 | #else | 650 | #else |
| 651 | if (lua_gettop(L) > 1) { | ||
| 652 | lua_settop(L, 1); // use one argument, because the second boolean will fail as get_console_flags expects bitflags | ||
| 653 | } | ||
| 660 | HANDLE console_handle = get_console_handle(L, 1); | 654 | HANDLE console_handle = get_console_handle(L, 1); |
| 661 | if (console_handle == NULL) { | 655 | if (console_handle == NULL) { |
| 662 | return 2; // error message is already on the stack | 656 | return 2; // error message is already on the stack |
| @@ -697,6 +691,9 @@ static int lst_getnonblock(lua_State *L) | |||
| 697 | } | 691 | } |
| 698 | 692 | ||
| 699 | #else | 693 | #else |
| 694 | if (lua_gettop(L) > 1) { | ||
| 695 | lua_settop(L, 1); // use one argument, because the second boolean will fail as get_console_flags expects bitflags | ||
| 696 | } | ||
| 700 | HANDLE console_handle = get_console_handle(L, 1); | 697 | HANDLE console_handle = get_console_handle(L, 1); |
| 701 | if (console_handle == NULL) { | 698 | if (console_handle == NULL) { |
| 702 | return 2; // error message is already on the stack | 699 | return 2; // error message is already on the stack |
