Writes "(a|b|c|...)" with `branches` one-letter alternatives into buf, which * must hold 2 * branches + 2 bytes. */
| 1172 | /* Writes "(a|b|c|...)" with `branches` one-letter alternatives into buf, which |
| 1173 | * must hold 2 * branches + 2 bytes. */ |
| 1174 | static void regex_one_letter_alternation(char *buf, int branches) { |
| 1175 | char *w = buf; |
| 1176 | *w++ = '('; |
| 1177 | for (int i = 0; i < branches; i++) { |
| 1178 | if (i) { |
| 1179 | *w++ = '|'; |
| 1180 | } |
| 1181 | *w++ = (char)('a' + i % 26); |
| 1182 | } |
| 1183 | *w++ = ')'; |
| 1184 | *w = '\0'; |
| 1185 | } |
| 1186 | |
| 1187 | /* Both regex backends expand `X{m,n}` into n copies of X at compile time, so |
| 1188 | * nested intervals multiply and a 25-byte pattern can ask for millions of |