- regdump - dump a regexp onto stdout in vaguely comprehensible form */
| 1170 | - regdump - dump a regexp onto stdout in vaguely comprehensible form |
| 1171 | */ |
| 1172 | void |
| 1173 | regdump( regexp *r ) |
| 1174 | { |
| 1175 | register char *s; |
| 1176 | register char op = EXACTLY; /* Arbitrary non-END op. */ |
| 1177 | register char *next; |
| 1178 | |
| 1179 | |
| 1180 | s = r->program + 1; |
| 1181 | while (op != END) { /* While that wasn't END last time... */ |
| 1182 | op = OP(s); |
| 1183 | printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */ |
| 1184 | next = regnext(s); |
| 1185 | if (next == NULL) /* Next ptr. */ |
| 1186 | printf("(0)"); |
| 1187 | else |
| 1188 | printf("(%d)", (s-r->program)+(next-s)); |
| 1189 | s += 3; |
| 1190 | if (op == ANYOF || op == ANYBUT || op == EXACTLY) { |
| 1191 | /* Literal string, where present. */ |
| 1192 | while (*s != '\0') { |
| 1193 | putchar(*s); |
| 1194 | s++; |
| 1195 | } |
| 1196 | s++; |
| 1197 | } |
| 1198 | putchar('\n'); |
| 1199 | } |
| 1200 | |
| 1201 | /* Header fields of interest. */ |
| 1202 | if (r->regstart != '\0') |
| 1203 | printf("start `%c' ", r->regstart); |
| 1204 | if (r->reganch) |
| 1205 | printf("anchored "); |
| 1206 | if (r->regmust != NULL) |
| 1207 | printf("must have \"%s\"", r->regmust); |
| 1208 | printf("\n"); |
| 1209 | } |
| 1210 | |
| 1211 | /* |
| 1212 | - regprop - printable representation of opcode |