diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-01-12 23:22:15 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-01-12 23:22:15 +0000 |
commit | 6ee254699bf787d78835419be2b3241fb037d444 (patch) | |
tree | 07fe67dab517e4990f344fe2c00e65cef4d25b81 /lib/libcurses/trace/lib_tracebits.c | |
parent | 0b62f5dc36fc7203a74cdc812c4234ae188fdfd2 (diff) |
Update to ncurses 5.7, with local changes reapplied.
This is around eight years worth of changes (previously we were around ncurses
5.2), too many to list - many bug fixes and also a few new functions.
A major bump for libcurses, libpanel, libform and libmenu.
ok deraadt
Diffstat (limited to 'lib/libcurses/trace/lib_tracebits.c')
-rw-r--r-- | lib/libcurses/trace/lib_tracebits.c | 124 |
1 files changed, 74 insertions, 50 deletions
diff --git a/lib/libcurses/trace/lib_tracebits.c b/lib/libcurses/trace/lib_tracebits.c index b1ad17da12c..4905807f11f 100644 --- a/lib/libcurses/trace/lib_tracebits.c +++ b/lib/libcurses/trace/lib_tracebits.c @@ -1,7 +1,7 @@ -/* $OpenBSD: lib_tracebits.c,v 1.9 2003/03/18 16:55:54 millert Exp $ */ +/* $OpenBSD: lib_tracebits.c,v 1.10 2010/01/12 23:22:07 nicm Exp $ */ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -31,12 +31,13 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * + * and: Thomas E. Dickey 1996-on * ****************************************************************************/ #include <curses.priv.h> #include <term.h> /* cur_term */ -MODULE_ID("$From: lib_tracebits.c,v 1.9 2000/12/10 03:02:45 tom Exp $") +MODULE_ID("$Id: lib_tracebits.c,v 1.10 2010/01/12 23:22:07 nicm Exp $") #if SVR4_TERMIO && !defined(_POSIX_SOURCE) #define _POSIX_SOURCE @@ -54,10 +55,27 @@ MODULE_ID("$From: lib_tracebits.c,v 1.9 2000/12/10 03:02:45 tom Exp $") #ifndef TOSTOP #define TOSTOP 0 #endif + #ifndef IEXTEN #define IEXTEN 0 #endif +#ifndef ONLCR +#define ONLCR 0 +#endif + +#ifndef OCRNL +#define OCRNL 0 +#endif + +#ifndef ONOCR +#define ONOCR 0 +#endif + +#ifndef ONLRET +#define ONLRET 0 +#endif + #ifdef TRACE typedef struct { @@ -84,7 +102,7 @@ lookup_bits(char *buf, size_t bufsize, const BITNAMES * table, const char *label } NCURSES_EXPORT(char *) -_nc_tracebits(void) +_nc_trace_ttymode(TTY * tty) /* describe the state of the terminal control bits exactly */ { char *buf; @@ -109,8 +127,13 @@ _nc_tracebits(void) }, oflags[] = { {OPOST, "OPOST"}, + {OFLAGS_TABS, "XTABS"}, + {ONLCR, "ONLCR"}, + {OCRNL, "OCRNL"}, + {ONOCR, "ONOCR"}, + {ONLRET, "ONLRET"}, {0, NULL} -#define ALLOUT (OPOST) +#define ALLOUT (OPOST|OFLAGS_TABS|ONLCR|OCRNL|ONOCR|ONLRET) }, cflags[] = { {CLOCAL, "CLOCAL"}, @@ -140,60 +163,55 @@ _nc_tracebits(void) }; bufsize = 8 + sizeof(iflags) + 8 + sizeof(oflags) + 8 + sizeof(cflags) + - 8 + sizeof(lflags) + 8; + 8 + sizeof(lflags) + 8; buf = _nc_trace_buf(0, bufsize); - if (cur_term->Nttyb.c_iflag & ALLIN) - lookup_bits(buf, bufsize, iflags, "iflags", cur_term->Nttyb.c_iflag); + if (buf != 0) { + + if (tty->c_iflag & ALLIN) + lookup_bits(buf, bufsize, iflags, "iflags", tty->c_iflag); - if (cur_term->Nttyb.c_oflag & ALLOUT) - lookup_bits(buf, bufsize, oflags, "oflags", cur_term->Nttyb.c_oflag); + if (tty->c_oflag & ALLOUT) + lookup_bits(buf, bufsize, oflags, "oflags", tty->c_oflag); - if (cur_term->Nttyb.c_cflag & ALLCTRL) - lookup_bits(buf, bufsize, cflags, "cflags", cur_term->Nttyb.c_cflag); + if (tty->c_cflag & ALLCTRL) + lookup_bits(buf, bufsize, cflags, "cflags", tty->c_cflag); #if defined(CS5) && defined(CS8) - { - static struct { - char *name; - int value; - } csizes[] = { - { - "CS5 ", CS5 - }, + { + static struct { + int value; + const char *name; + } csizes[] = { +#define CS_DATA(name) { name, #name " " } + CS_DATA(CS5), #ifdef CS6 - { - "CS6 ", CS6 - }, + CS_DATA(CS6), #endif #ifdef CS7 - { - "CS7 ", CS7 - }, -#endif - { - "CS8 ", CS8 - }, - }; - char *result = "CSIZE? "; - int value = (cur_term->Nttyb.c_cflag & CSIZE); - unsigned n; - - if (value != 0) { - for (n = 0; n < SIZEOF(csizes); n++) { - if (csizes[n].value == value) { - result = csizes[n].name; - break; + CS_DATA(CS7), +#endif + CS_DATA(CS8), + }; + const char *result = "CSIZE? "; + int value = (tty->c_cflag & CSIZE); + unsigned n; + + if (value != 0) { + for (n = 0; n < SIZEOF(csizes); n++) { + if (csizes[n].value == value) { + result = csizes[n].name; + break; + } } } + strlcat(buf, result, bufsize); } - strlcat(buf, result, bufsize); - } #endif - if (cur_term->Nttyb.c_lflag & ALLLOCAL) - lookup_bits(buf, bufsize, lflags, "lflags", cur_term->Nttyb.c_lflag); - + if (tty->c_lflag & ALLLOCAL) + lookup_bits(buf, bufsize, lflags, "lflags", tty->c_lflag); + } #else /* reference: ttcompat(4M) on SunOS 4.1 */ #ifndef EVENP @@ -230,18 +248,24 @@ _nc_tracebits(void) buf = _nc_trace_buf(0, 8 + sizeof(cflags)); - - if (cur_term->Nttyb.sg_flags & ALLCTRL) { - lookup_bits(buf, bufsize, cflags, "cflags", cur_term->Nttyb.sg_flags); + if (buf != 0) { + if (tty->sg_flags & ALLCTRL) { + lookup_bits(buf, cflags, "cflags", tty->sg_flags); + } } #endif return (buf); } + +NCURSES_EXPORT(char *) +_nc_tracebits(void) +{ + return _nc_trace_ttymode(&(cur_term->Nttyb)); +} #else NCURSES_EXPORT(char *) _nc_tracebits(void) { - static char tmp[] = ""; - return tmp; + return NULL; } #endif /* TRACE */ |