+ int result = 0;
+#if USE_WIDEC_SUPPORT
+#endif
+
+#if USE_WIDEC_SUPPORT
+ while (getcchar(src++, NULL, NULL, NULL, NULL) > 0)
+ result++;
+#else
+ while (*src++)
+ result++;
+#endif
+ return result;
+}
+
+/*
+ * Allocate a string into an array of chtype's. If UTF-8 mode is
+ * active, translate the string accordingly.
+ */
+static NCURSES_CH_T *
+ch_dup(char *src)
+{
+ unsigned len = strlen(src);
+ NCURSES_CH_T *dst = typeMalloc(NCURSES_CH_T, len + 1);
+ unsigned j, k;
+#if USE_WIDEC_SUPPORT
+ wchar_t wstr[CCHARW_MAX + 1];
+ wchar_t wch;
+ int l = 0;
+ mbstate_t state;
+ size_t rc;
+ int width;
+#endif
+
+#if USE_WIDEC_SUPPORT
+ memset(&state, 0, sizeof(state));
+#endif
+ for (j = k = 0; j < len; j++) {
+#if USE_WIDEC_SUPPORT
+ rc = mbrtowc(&wch, src + j, len - j, &state);
+ if (rc == (size_t) -1 || rc == (size_t) -2)
+ break;
+ j += rc - 1;
+ if ((width = wcwidth(wch)) < 0)
+ break;
+ if ((width > 0 && l > 0) || l == CCHARW_MAX) {
+ wstr[l] = L'\0';
+ l = 0;
+ if (setcchar(dst + k, wstr, 0, 0, NULL) != OK)
+ break;
+ ++k;
+ }
+ if (width == 0 && l == 0)
+ wstr[l++] = L' ';
+ wstr[l++] = wch;
+#else
+ dst[k++] = src[j];
+#endif
+ }
+#if USE_WIDEC_SUPPORT
+ if (l > 0) {
+ wstr[l] = L'\0';
+ if (setcchar(dst + k, wstr, 0, 0, NULL) == OK)
+ ++k;
+ }
+ setcchar(dst + k, L"", 0, 0, NULL);
+#else
+ dst[k] = 0;
+#endif
+ return dst;
+}
+
+int
+main(int argc, char *argv[])
+{
+ int MAXLINES = 1000;
+ FILE *fp;
+ char buf[BUFSIZ];
+ int i;
+ int my_delay = 0;
+ NCURSES_CH_T **olptr;
+ int length = 0;
+ int value = 0;
+ bool done = FALSE;
+ bool got_number = FALSE;