mksh R40 Release Candidate 1
Testsuite: • add new need-pass: {yes|no} attribute, default yes • exit with 1 if a need-pass test failed unexpectedly idea by Kacper Kornet <draenog@pld-linux.org> • mark utf8bom-2 as need-pass: no Infrstructure: • add housekeeping function for making a tty raw • switch functions with unused results to void • struct op: u.charflag contains last char of ;; in TPAT • var.c:arraysearch is now a global function Language: • add ;& (fall through) and ;| (examine next) delimiters in addition to ;; (end case) as zsh extensions, because POSIX standardised on ;& already • add -A (read into array), -N (read exactly n bytes), -n (read up to n bytes), -t (timeout) flags for read from ksh93 • allow read -N -1 or -n -1 to slurp the entire input • add -a (read into array the input characters) extension specific to mksh to read, idea by David Korn • add -e (exit with error if PWD was not set correctly after a physical cd) to cd builtin, mandated by next POSIX, and change error codes accordingly Rewrites: • full rewrite of read builtin and its manpage section • add regression tetss for most of the new functionality • duplicate hexdump demo tests for use of read -a • use read -raN-1 in dot.mkshrc to get NUL safe base64, DJB cdb hash and Jenkins one-at-a-time hash functions
This commit is contained in:
73
edit.c
73
edit.c
@ -25,7 +25,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.211 2011/04/22 12:16:38 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.212 2011/05/29 02:18:49 tg Exp $");
|
||||
|
||||
/*
|
||||
* in later versions we might use libtermcap for this, but since external
|
||||
@ -68,7 +68,7 @@ static char holdbuf[LINE]; /* place to hold last edit buffer */
|
||||
|
||||
static int x_getc(void);
|
||||
static void x_putcf(int);
|
||||
static bool x_mode(bool);
|
||||
static void x_mode(bool);
|
||||
static int x_do_comment(char *, int, int *);
|
||||
static void x_print_expansions(int, char *const *, bool);
|
||||
static int x_cf_glob(int *, const char *, int, int, int *, int *, char ***);
|
||||
@ -3180,44 +3180,26 @@ x_lastcp(void)
|
||||
return (xlp);
|
||||
}
|
||||
|
||||
static bool
|
||||
static void
|
||||
x_mode(bool onoff)
|
||||
{
|
||||
static bool x_cur_mode;
|
||||
bool prev;
|
||||
|
||||
if (x_cur_mode == onoff)
|
||||
return (x_cur_mode);
|
||||
prev = x_cur_mode;
|
||||
return;
|
||||
x_cur_mode = onoff;
|
||||
|
||||
if (onoff) {
|
||||
struct termios cb;
|
||||
x_mkraw(tty_fd, NULL, false);
|
||||
|
||||
cb = tty_state;
|
||||
|
||||
edchars.erase = cb.c_cc[VERASE];
|
||||
edchars.kill = cb.c_cc[VKILL];
|
||||
edchars.intr = cb.c_cc[VINTR];
|
||||
edchars.quit = cb.c_cc[VQUIT];
|
||||
edchars.eof = cb.c_cc[VEOF];
|
||||
edchars.erase = tty_state.c_cc[VERASE];
|
||||
edchars.kill = tty_state.c_cc[VKILL];
|
||||
edchars.intr = tty_state.c_cc[VINTR];
|
||||
edchars.quit = tty_state.c_cc[VQUIT];
|
||||
edchars.eof = tty_state.c_cc[VEOF];
|
||||
#ifdef VWERASE
|
||||
edchars.werase = cb.c_cc[VWERASE];
|
||||
edchars.werase = tty_state.c_cc[VWERASE];
|
||||
#endif
|
||||
cb.c_iflag &= ~(INLCR | ICRNL);
|
||||
cb.c_lflag &= ~(ISIG | ICANON | ECHO);
|
||||
#if defined(VLNEXT) && defined(_POSIX_VDISABLE)
|
||||
/* OSF/1 processes lnext when ~icanon */
|
||||
cb.c_cc[VLNEXT] = _POSIX_VDISABLE;
|
||||
#endif
|
||||
/* SunOS 4.1.x & OSF/1 processes discard(flush) when ~icanon */
|
||||
#if defined(VDISCARD) && defined(_POSIX_VDISABLE)
|
||||
cb.c_cc[VDISCARD] = _POSIX_VDISABLE;
|
||||
#endif
|
||||
cb.c_cc[VTIME] = 0;
|
||||
cb.c_cc[VMIN] = 1;
|
||||
|
||||
tcsetattr(tty_fd, TCSADRAIN, &cb);
|
||||
|
||||
#ifdef _POSIX_VDISABLE
|
||||
/* Convert unset values to internal 'unset' value */
|
||||
@ -3249,8 +3231,6 @@ x_mode(bool onoff)
|
||||
bind_if_not_bound(0, edchars.quit, XFUNC_noop);
|
||||
} else
|
||||
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
|
||||
|
||||
return (prev);
|
||||
}
|
||||
|
||||
#if !MKSH_S_NOVI
|
||||
@ -5338,3 +5318,34 @@ vi_macro_reset(void)
|
||||
}
|
||||
}
|
||||
#endif /* !MKSH_S_NOVI */
|
||||
|
||||
void
|
||||
x_mkraw(int fd, struct termios *ocb, bool forread)
|
||||
{
|
||||
struct termios cb;
|
||||
|
||||
if (ocb)
|
||||
tcgetattr(fd, ocb);
|
||||
else
|
||||
ocb = &tty_state;
|
||||
|
||||
cb = *ocb;
|
||||
if (forread) {
|
||||
cb.c_lflag &= ~(ICANON) | ECHO;
|
||||
} else {
|
||||
cb.c_iflag &= ~(INLCR | ICRNL);
|
||||
cb.c_lflag &= ~(ISIG | ICANON | ECHO);
|
||||
}
|
||||
#if defined(VLNEXT) && defined(_POSIX_VDISABLE)
|
||||
/* OSF/1 processes lnext when ~icanon */
|
||||
cb.c_cc[VLNEXT] = _POSIX_VDISABLE;
|
||||
#endif
|
||||
/* SunOS 4.1.x & OSF/1 processes discard(flush) when ~icanon */
|
||||
#if defined(VDISCARD) && defined(_POSIX_VDISABLE)
|
||||
cb.c_cc[VDISCARD] = _POSIX_VDISABLE;
|
||||
#endif
|
||||
cb.c_cc[VTIME] = 0;
|
||||
cb.c_cc[VMIN] = 1;
|
||||
|
||||
tcsetattr(fd, TCSADRAIN, &cb);
|
||||
}
|
||||
|
Reference in New Issue
Block a user