]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/trace/lib_tracebits.c
ncurses 5.2
[ncurses.git] / ncurses / trace / lib_tracebits.c
index 6dbb2f793ad0d1bbea81ace51c09edc9d110c0a7..a8cb343be59f3d72e3bdbca50300a198193dad5b 100644 (file)
@@ -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