+ for (q = strchr(p, '%'); q; q = strchr(p + 1, '%')) {
+ int n;
+
+ pos += m_strncpy(dst + pos, dlen - pos, p, q - p);
+
+ if (!isdigit((unsigned char)q[1])) {
+ p = q + (q[1] == '%');
+ continue;
+ }
+
+ n = strtol(q + 1, (char **)&p, 10); /* find pmatch index */
+ pos += m_strncpy(dst + pos, dlen - pos, s + pmatch[n].rm_so,
+ pmatch[n].rm_eo - pmatch[n].rm_so);
+ }
+
+ pos += m_strcpy(dst + pos, dlen - pos, p);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+rx_t **rx_lookup(rx_t **l, const char *pat)
+{
+ if (m_strisempty(pat))
+ return NULL;