From 4e516a1ee82e713c456b72f3f37dcddc7b69ad6c Mon Sep 17 00:00:00 2001 From: Mark Nudelman Date: Fri, 4 Oct 2024 08:46:20 -0700 Subject: [PATCH] Add --no-poll option. Related to #557. --- NEWS | 2 ++ opttbl.c | 10 ++++++++++ os.c | 5 +++-- version.c | 3 ++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index d6c8706b..35bc8f3f 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,8 @@ * Add --form-feed option (github #496). +* Add --no-poll option (github #557). + * Make TAB complete option name in -- command (github #531). * Make -R able to pass through any OSC escape sequences, diff --git a/opttbl.c b/opttbl.c index 3628449e..fdb2f6ca 100644 --- a/opttbl.c +++ b/opttbl.c @@ -84,6 +84,7 @@ public int match_shift; /* Extra horizontal shift on search match */ public int no_paste; /* Don't accept pasted input */ public int no_edit_warn; /* Don't warn when editing a LESSOPENed file */ public int stop_on_form_feed; /* Stop scrolling on a line starting with form feed */ +public int no_poll; /* Don't poll tty for ^X */ public long match_shift_fraction = NUM_FRAC_DENOM/2; /* 1/2 of screen width */ public char intr_char = CONTROL('X'); /* Char to interrupt reads */ #if HILITE_SEARCH @@ -184,6 +185,7 @@ static struct optname proc_backspace_optname = { "proc-backspace", NULL }; static struct optname proc_tab_optname = { "proc-tab", NULL }; static struct optname proc_return_optname = { "proc-return", NULL }; static struct optname match_shift_optname = { "match-shift", NULL }; +static struct optname no_poll_optname = { "no-poll", NULL }; #if LESSTEST static struct optname ttyin_name_optname = { "tty", NULL }; #endif /*LESSTEST*/ @@ -756,6 +758,14 @@ static struct loption option[] = NULL } }, + { OLETTER_NONE, &no_poll_optname, + O_BOOL, OPT_OFF, &no_poll, NULL, + { + "Poll for ^X when reading data", + "Don't poll for ^X when reading data", + NULL + } + }, #if LESSTEST { OLETTER_NONE, &ttyin_name_optname, O_STRING|O_NO_TOGGLE, 0, NULL, opt_ttyin_name, diff --git a/os.c b/os.c index 9f897775..ec5bfaab 100644 --- a/os.c +++ b/os.c @@ -81,6 +81,7 @@ extern int follow_mode; extern int scanning_eof; extern char intr_char; extern int is_tty; +extern int no_poll; #if !MSDOS_COMPILER extern int tty; #endif @@ -152,7 +153,7 @@ public int supports_ctrl_x(void) return (TRUE); #else #if USE_POLL - return (use_poll); + return (use_poll && !no_poll); #else return (FALSE); #endif /* USE_POLL */ @@ -238,7 +239,7 @@ public ssize_t iread(int fd, unsigned char *buf, size_t len) } #endif #if USE_POLL - if (is_tty && fd != tty && use_poll) + if (is_tty && fd != tty && use_poll && !no_poll) { int ret = check_poll(fd, tty); if (ret != 0) diff --git a/version.c b/version.c index 08b54131..2dd909d2 100644 --- a/version.c +++ b/version.c @@ -1034,7 +1034,8 @@ v667 9/26/24 Fix uninitialized variable in edit_ifile. v659.1 Add --no-paste; add --no-edit-warn; add TAB for -- command; add LESSANSIOSCALLOW and LESSANSIOSCCCHARS; fix bug searching near invalid UTF-8 sequence; add LESS_SHELL_LINES; fix bug - with --no-number-headers; add mouse cmds to lesskey. + with --no-number-headers; add mouse cmds to lesskey; + add form-feed; add --no-poll. */