From 8aad4f42671818fd94b7f94d5f6ecead3d3b1e01 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 14 Nov 2023 14:37:33 -0600 Subject: [PATCH] Elliott wants to use CTRL(), and glibc implicitly pulls this in anyway. (The explicit #include is because musl and bionic don't.) --- toys.h | 1 + toys/net/microcom.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/toys.h b/toys.h index bde3d90d..88b7a837 100644 --- a/toys.h +++ b/toys.h @@ -66,6 +66,7 @@ // Non-posix headers #include #include +#include #include "lib/lib.h" #include "lib/lsm.h" diff --git a/toys/net/microcom.c b/toys/net/microcom.c index 770afa0b..d805a062 100644 --- a/toys/net/microcom.c +++ b/toys/net/microcom.c @@ -38,7 +38,7 @@ static void handle_esc(void) char input; xputsn("\r\n[b]reak, [p]aste file, [q]uit: "); - if (read(0, &input, 1)<1 || input == 'D'-64 || input == 'q') { + if (read(0, &input, 1)<1 || input == CTRL('D') || input == 'q') { xputs("exit\r"); xexit(); } @@ -53,12 +53,12 @@ static void handle_esc(void) memset(toybuf, 0, sizeof(toybuf)); while (1) { xprintf("\r\e[2K\e[1mFilename: \e[0m%s", toybuf); - if (read(0, &input, 1) <= 0 || input == '['-64) { + if (read(0, &input, 1) <= 0 || input == CTRL('[')) { return; } if (input == '\r') break; if (input == 0x7f && len > 0) toybuf[--len] = 0; - else if (input == 'U'-64) while (len > 0) toybuf[--len] = 0; + else if (input == CTRL('U')) while (len > 0) toybuf[--len] = 0; else if (input >= ' ' && input <= 0x7f && len < sizeof(toybuf)) toybuf[len++] = input; } @@ -122,7 +122,7 @@ void microcom_main(void) // Read from stdin, write to connection. if (fds[1].revents) { if (read(0, toybuf, 1) != 1) break; - if (!FLAG(X) && *toybuf == ']'-64) handle_esc(); + if (!FLAG(X) && *toybuf == CTRL(']')) handle_esc(); else xwrite(TT.fd, toybuf, 1); } } -- 2.39.2