Use _POSIX_VDISABLE directly instead of assigning it to a variable.
From: Todd C. Miller <millert@cvs.openbsd.org>
This commit is contained in:
parent
8f06ee02a7
commit
791337c8a3
44
edit.c
44
edit.c
@ -1,4 +1,4 @@
|
|||||||
/** $MirBSD: src/bin/ksh/edit.c,v 2.6 2004/12/28 22:32:08 tg Exp $ */
|
/** $MirBSD: src/bin/ksh/edit.c,v 2.7 2004/12/31 17:11:11 tg Exp $ */
|
||||||
/* $OpenBSD: edit.c,v 1.23 2004/12/18 22:12:23 millert Exp $ */
|
/* $OpenBSD: edit.c,v 1.23 2004/12/18 22:12:23 millert Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -21,7 +21,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "ksh_stat.h"
|
#include "ksh_stat.h"
|
||||||
|
|
||||||
__RCSID("$MirBSD: src/bin/ksh/edit.c,v 2.6 2004/12/28 22:32:08 tg Exp $");
|
__RCSID("$MirBSD: src/bin/ksh/edit.c,v 2.7 2004/12/31 17:11:11 tg Exp $");
|
||||||
|
|
||||||
#if defined(TIOCGWINSZ)
|
#if defined(TIOCGWINSZ)
|
||||||
static RETSIGTYPE x_sigwinch(int sig);
|
static RETSIGTYPE x_sigwinch(int sig);
|
||||||
@ -29,6 +29,10 @@ static volatile sig_atomic_t got_sigwinch;
|
|||||||
static void check_sigwinch(void);
|
static void check_sigwinch(void);
|
||||||
#endif /* TIOCGWINSZ */
|
#endif /* TIOCGWINSZ */
|
||||||
|
|
||||||
|
#if !defined(_POSIX_VDISABLE) || (_POSIX_VDISABLE < 0)
|
||||||
|
#define _POSIX_VDISABLE 0377
|
||||||
|
#endif
|
||||||
|
|
||||||
static int x_file_glob(int flags, const char *str, int slen,
|
static int x_file_glob(int flags, const char *str, int slen,
|
||||||
char ***wordsp);
|
char ***wordsp);
|
||||||
static int x_command_glob(int flags, const char *str, int slen,
|
static int x_command_glob(int flags, const char *str, int slen,
|
||||||
@ -36,9 +40,6 @@ static int x_command_glob(int flags, const char *str, int slen,
|
|||||||
static int x_locate_word(const char *buf, int buflen, int pos,
|
static int x_locate_word(const char *buf, int buflen, int pos,
|
||||||
int *startp, int *is_command);
|
int *startp, int *is_command);
|
||||||
|
|
||||||
static char vdisable_c;
|
|
||||||
|
|
||||||
|
|
||||||
/* Called from main */
|
/* Called from main */
|
||||||
void
|
void
|
||||||
x_init(void)
|
x_init(void)
|
||||||
@ -59,23 +60,6 @@ x_init(void)
|
|||||||
#endif /* TIOCGWINSZ */
|
#endif /* TIOCGWINSZ */
|
||||||
|
|
||||||
x_init_emacs();
|
x_init_emacs();
|
||||||
|
|
||||||
/* Bizarreness to figure out how to disable
|
|
||||||
* a struct termios.c_cc[] char
|
|
||||||
*/
|
|
||||||
#ifdef _POSIX_VDISABLE
|
|
||||||
if (_POSIX_VDISABLE >= 0)
|
|
||||||
vdisable_c = (char) _POSIX_VDISABLE;
|
|
||||||
else
|
|
||||||
/* 'feature not available' */
|
|
||||||
vdisable_c = (char) 0377;
|
|
||||||
#else
|
|
||||||
# if defined(HAVE_PATHCONF) && defined(_PC_VDISABLE)
|
|
||||||
vdisable_c = fpathconf(tty_fd, _PC_VDISABLE);
|
|
||||||
# else
|
|
||||||
vdisable_c = (char) 0377; /* default to old BSD value */
|
|
||||||
# endif
|
|
||||||
#endif /* _POSIX_VDISABLE */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TIOCGWINSZ)
|
#if defined(TIOCGWINSZ)
|
||||||
@ -218,11 +202,11 @@ x_mode(bool onoff)
|
|||||||
# endif
|
# endif
|
||||||
# ifdef VLNEXT
|
# ifdef VLNEXT
|
||||||
/* osf/1 processes lnext when ~icanon */
|
/* osf/1 processes lnext when ~icanon */
|
||||||
cb.c_cc[VLNEXT] = vdisable_c;
|
cb.c_cc[VLNEXT] = _POSIX_VDISABLE;
|
||||||
# endif /* VLNEXT */
|
# endif /* VLNEXT */
|
||||||
# ifdef VDISCARD
|
# ifdef VDISCARD
|
||||||
/* sunos 4.1.x & osf/1 processes discard(flush) when ~icanon */
|
/* sunos 4.1.x & osf/1 processes discard(flush) when ~icanon */
|
||||||
cb.c_cc[VDISCARD] = vdisable_c;
|
cb.c_cc[VDISCARD] = _POSIX_VDISABLE;
|
||||||
# endif /* VDISCARD */
|
# endif /* VDISCARD */
|
||||||
cb.c_cc[VTIME] = 0;
|
cb.c_cc[VTIME] = 0;
|
||||||
cb.c_cc[VMIN] = 1;
|
cb.c_cc[VMIN] = 1;
|
||||||
@ -269,17 +253,17 @@ x_mode(bool onoff)
|
|||||||
#endif /* __CYGWIN__ */
|
#endif /* __CYGWIN__ */
|
||||||
|
|
||||||
/* Convert unset values to internal 'unset' value */
|
/* Convert unset values to internal 'unset' value */
|
||||||
if (edchars.erase == vdisable_c)
|
if (edchars.erase == _POSIX_VDISABLE)
|
||||||
edchars.erase = -1;
|
edchars.erase = -1;
|
||||||
if (edchars.kill == vdisable_c)
|
if (edchars.kill == _POSIX_VDISABLE)
|
||||||
edchars.kill = -1;
|
edchars.kill = -1;
|
||||||
if (edchars.intr == vdisable_c)
|
if (edchars.intr == _POSIX_VDISABLE)
|
||||||
edchars.intr = -1;
|
edchars.intr = -1;
|
||||||
if (edchars.quit == vdisable_c)
|
if (edchars.quit == _POSIX_VDISABLE)
|
||||||
edchars.quit = -1;
|
edchars.quit = -1;
|
||||||
if (edchars.eof == vdisable_c)
|
if (edchars.eof == _POSIX_VDISABLE)
|
||||||
edchars.eof = -1;
|
edchars.eof = -1;
|
||||||
if (edchars.werase == vdisable_c)
|
if (edchars.werase == _POSIX_VDISABLE)
|
||||||
edchars.werase = -1;
|
edchars.werase = -1;
|
||||||
if (memcmp(&edchars, &oldchars, sizeof(edchars)) != 0)
|
if (memcmp(&edchars, &oldchars, sizeof(edchars)) != 0)
|
||||||
x_emacs_keys(&edchars);
|
x_emacs_keys(&edchars);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user