- 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 {
+ const char *name;
+ int value;
+ } csizes[] = {
+ {
+ "CS5 ", CS5
+ },
+#ifdef CS6
+ {
+ "CS6 ", CS6
+ },
+#endif
+#ifdef CS7
+ {
+ "CS7 ", CS7
+ },
+#endif
+ {
+ "CS8 ", 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;
+ }
+ }
+ }
+ strcat(buf, result);