diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2024-05-23 08:23:14 +0200 |
---|---|---|
committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2024-05-23 08:23:14 +0200 |
commit | 7e9447c98588730738724176d9acc595be6299e6 (patch) | |
tree | 7bec18966d7e4f4078a0be5cb6cf4f8db3dc5ece /src/term.c | |
parent | b3cd71ddf2bbadb63fa4dc4ef1147b5c4ae95994 (diff) | |
download | luasystem-7e9447c98588730738724176d9acc595be6299e6.tar.gz luasystem-7e9447c98588730738724176d9acc595be6299e6.tar.bz2 luasystem-7e9447c98588730738724176d9acc595be6299e6.zip |
fix several tests
Diffstat (limited to 'src/term.c')
-rw-r--r-- | src/term.c | 29 |
1 files changed, 11 insertions, 18 deletions
@@ -556,28 +556,13 @@ static int lst_tcsetattr(lua_State *L) | |||
556 | int r, i; | 556 | int r, i; |
557 | int fd = get_console_handle(L); // first is the console handle | 557 | int fd = get_console_handle(L); // first is the console handle |
558 | int act = luaL_checkinteger(L, 2); // second is the action to take | 558 | int act = luaL_checkinteger(L, 2); // second is the action to take |
559 | luaL_checktype(L, 3, LUA_TTABLE); // third is the termios table with fields | ||
560 | 559 | ||
561 | r = tcgetattr(fd, &t); | 560 | r = tcgetattr(fd, &t); |
562 | if (r == -1) return pusherror(L, NULL); | 561 | if (r == -1) return pusherror(L, NULL); |
563 | 562 | ||
564 | lua_getfield(L, 3, "iflag"); | 563 | t.c_iflag = lsbf_checkbitflagsfield(L, 3, "iflag", t.c_iflag); |
565 | if (!lua_isnil(L, -1)) { | 564 | t.c_oflag = lsbf_checkbitflagsfield(L, 3, "oflag", t.c_oflag); |
566 | t.c_iflag = lsbf_checkbitflags(L, -1); | 565 | t.c_lflag = lsbf_checkbitflagsfield(L, 3, "lflag", t.c_lflag); |
567 | } | ||
568 | lua_pop(L, 1); | ||
569 | |||
570 | lua_getfield(L, 3, "oflag"); | ||
571 | if (!lua_isnil(L, -1)) { | ||
572 | t.c_oflag = lsbf_checkbitflags(L, -1); | ||
573 | } | ||
574 | lua_pop(L, 1); | ||
575 | |||
576 | lua_getfield(L, 3, "lflag"); | ||
577 | if (!lua_isnil(L, -1)) { | ||
578 | t.c_lflag = lsbf_checkbitflags(L, -1); | ||
579 | } | ||
580 | lua_pop(L, 1); | ||
581 | 566 | ||
582 | // Skipping the others for now | 567 | // Skipping the others for now |
583 | 568 | ||
@@ -596,6 +581,14 @@ static int lst_tcsetattr(lua_State *L) | |||
596 | 581 | ||
597 | r = tcsetattr(fd, act, &t); | 582 | r = tcsetattr(fd, act, &t); |
598 | if (r == -1) return pusherror(L, NULL); | 583 | if (r == -1) return pusherror(L, NULL); |
584 | |||
585 | #else | ||
586 | // Windows does not have a tcsetattr function, but we check arguments anyway | ||
587 | get_console_handle(L, 1); // to validate args | ||
588 | luaL_checkinteger(L, 2); | ||
589 | lsbf_checkbitflagsfield(L, 3, "iflag", t.c_iflag); | ||
590 | lsbf_checkbitflagsfield(L, 3, "oflag", t.c_iflag); | ||
591 | lsbf_checkbitflagsfield(L, 3, "lflag", t.c_iflag); | ||
599 | #endif | 592 | #endif |
600 | 593 | ||
601 | lua_pushboolean(L, 1); | 594 | lua_pushboolean(L, 1); |