+static int
+skip_csi(const char *cap)
+{
+ int result = 0;
+ if (cap[0] == '\033' && cap[1] == '[')
+ result = 2;
+ else if (UChar(cap[0]) == 0233)
+ result = 1;
+ return result;
+}
+
+static bool
+same_param(const char *table, const char *param, size_t length)
+{
+ bool result = FALSE;
+ if (strncmp(table, param, length) == 0) {
+ result = !isdigit(UChar(param[length]));
+ }
+ return result;
+}
+
+static char *
+lookup_params(const assoc * table, char *dst, char *src)
+{
+ char *result = 0;
+ const char *ep = strtok(src, ";");
+
+ if (ep != 0) {
+ const assoc *ap;
+
+ do {
+ bool found = FALSE;
+
+ for (ap = table; ap->from; ap++) {
+ size_t tlen = strlen(ap->from);
+
+ if (same_param(ap->from, ep, tlen)) {
+ _nc_STRCAT(dst, ap->to, MAX_TERMINFO_LENGTH);
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found)
+ _nc_STRCAT(dst, ep, MAX_TERMINFO_LENGTH);
+ _nc_STRCAT(dst, ";", MAX_TERMINFO_LENGTH);
+ } while
+ ((ep = strtok((char *) 0, ";")));
+
+ dst[strlen(dst) - 1] = '\0';
+
+ result = dst;
+ }
+ return result;
+}
+