]>
git.saurik.com Git - wxWidgets.git/blob - src/regex/debug.c
bf40bbb3bd4722038226c7dd1148b1b6efabe261
14 - regprint - print a regexp for debugging
15 == void regprint(regex_t *r, FILE *d);
22 register struct re_guts
*g
= r
->re_g
;
28 fprintf(d
, "%ld states, %d categories", (long)g
->nstates
,
30 fprintf(d
, ", first %ld last %ld", (long)g
->firststate
,
33 fprintf(d
, ", USEBOL");
35 fprintf(d
, ", USEEOL");
39 fprintf(d
, ", nsub=%ld", (long)g
->nsub
);
41 fprintf(d
, ", must(%ld) `%*s'", (long)g
->mlen
, (int)g
->mlen
,
44 fprintf(d
, ", backrefs");
46 fprintf(d
, ", nplus %ld", (long)g
->nplus
);
49 for (i
= 0; i
< g
->ncategories
; i
++) {
51 for (c
= CHAR_MIN
; c
<= CHAR_MAX
; c
++)
52 if (g
->categories
[c
] == i
)
55 fprintf(d
, "cc0#%d", nincat
[0]);
56 for (i
= 1; i
< g
->ncategories
; i
++)
58 for (c
= CHAR_MIN
; c
<= CHAR_MAX
; c
++)
59 if (g
->categories
[c
] == i
)
61 fprintf(d
, ", %d=%s", i
, regchar(c
));
64 for (i
= 1; i
< g
->ncategories
; i
++)
66 fprintf(d
, "cc%d\t", i
);
68 for (c
= CHAR_MIN
; c
<= CHAR_MAX
+1; c
++) /* +1 does flush */
69 if (c
<= CHAR_MAX
&& g
->categories
[c
] == i
) {
71 fprintf(d
, "%s", regchar(c
));
87 - s_print - print the strip for debugging
88 == static void s_print(register struct re_guts *g, FILE *d);
92 register struct re_guts
*g
;
98 register int done
= 0;
100 register int col
= 0;
102 register sopno offset
= 2;
103 # define GAP() { if (offset % 5 == 0) { \
105 fprintf(d, "\n\t"); \
116 if (OP(g
->strip
[0]) != OEND
)
117 fprintf(d
, "missing initial OEND!\n");
118 for (s
= &g
->strip
[1]; !done
; s
++) {
126 if (strchr("\\|()^$.[+*?{}!<> ", (char)opnd
) != NULL
)
127 fprintf(d
, "\\%c", (char)opnd
);
129 fprintf(d
, "%s", regchar((char)opnd
));
147 fprintf(d
, "[(%ld)", (long)opnd
);
150 for (i
= 0; i
< g
->csetsize
+1; i
++) /* +1 flushes */
151 if (CHIN(cs
, i
) && i
< g
->csetsize
) {
153 fprintf(d
, "%s", regchar(i
));
167 fprintf(d
, "(\\<%ld>", (long)opnd
);
170 fprintf(d
, "<%ld>\\)", (long)opnd
);
174 if (OP(*(s
+opnd
)) != O_PLUS
)
175 fprintf(d
, "<%ld>", (long)opnd
);
178 if (OP(*(s
-opnd
)) != OPLUS_
)
179 fprintf(d
, "<%ld>", (long)opnd
);
184 if (OP(*(s
+opnd
)) != O_QUEST
)
185 fprintf(d
, "<%ld>", (long)opnd
);
188 if (OP(*(s
-opnd
)) != OQUEST_
)
189 fprintf(d
, "<%ld>", (long)opnd
);
193 fprintf(d
, "((<%ld>", (long)opnd
);
196 fprintf(d
, "<%ld>))", (long)opnd
);
200 if (OP(*(s
+opnd
)) != OOR2
)
201 fprintf(d
, "<%ld>", (long)opnd
);
204 if (OP(*(s
-opnd
)) != OOR1
&& OP(*(s
-opnd
)) != OCH_
)
205 fprintf(d
, "<%ld>", (long)opnd
);
210 if (OP(*(s
+opnd
)) != OOR2
&& OP(*(s
+opnd
)) != O_CH
)
211 fprintf(d
, "<%ld>", (long)opnd
);
214 if (OP(*(s
-opnd
)) != OOR1
)
215 fprintf(d
, "<%ld>", (long)opnd
);
219 fprintf(d
, "!%d(%d)!", OP(*s
), opnd
);
228 - regchar - make a character printable
229 == static char *regchar(int ch);
231 static char * /* -> representation */
237 if (isprint(ch
) || ch
== ' ')
238 sprintf(buf
, "%c", ch
);
240 sprintf(buf
, "\\%o", ch
);