aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/trace/lib_tracebits.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/ncurses/trace/lib_tracebits.c')
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracebits.c63
1 files changed, 37 insertions, 26 deletions
diff --git a/contrib/ncurses/ncurses/trace/lib_tracebits.c b/contrib/ncurses/ncurses/trace/lib_tracebits.c
index 6dbb2f793ad0..a8cb343be59f 100644
--- a/contrib/ncurses/ncurses/trace/lib_tracebits.c
+++ b/contrib/ncurses/ncurses/trace/lib_tracebits.c
@@ -34,9 +34,9 @@
#include <curses.priv.h>
#include <term.h> /* cur_term */
-MODULE_ID("$Id: lib_tracebits.c,v 1.5 2000/02/13 01:01:55 tom Exp $")
+MODULE_ID("$Id: lib_tracebits.c,v 1.7 2000/09/02 18:08:37 tom Exp $")
-#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
@@ -153,30 +153,41 @@ _nc_tracebits(void)
lookup_bits(buf, cflags, "cflags", cur_term->Nttyb.c_cflag);
#if defined(CS5) && defined(CS8)
- switch (cur_term->Nttyb.c_cflag & CSIZE) {
-#if defined(CS5) && (CS5 != 0)
- case CS5:
- strcat(buf, "CS5 ");
- break;
-#endif
-#if defined(CS6) && (CS6 != 0)
- case CS6:
- strcat(buf, "CS6 ");
- break;
-#endif
-#if defined(CS7) && (CS7 != 0)
- case CS7:
- strcat(buf, "CS7 ");
- break;
-#endif
-#if defined(CS8) && (CS8 != 0)
- case CS8:
- strcat(buf, "CS8 ");
- break;
-#endif
- default:
- strcat(buf, "CSIZE? ");
- break;
+ {
+ static struct {
+ char *name;
+ int value;
+ } csizes[] = {
+ {
+ "CS5 ", CS5
+ },
+#ifdef CS6
+ {
+ "CS6 ", 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;
+ }
+ }
+ }
+ strcat(buf, result);
}
#endif